Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self._touch_cancel_callbacks([(touch['x'], touch['y']) for touch in content['touches']])
class MultiCanvas(_CanvasBase):
"""Create a MultiCanvas widget with n_canvases Canvas widgets.
Args:
n_canvases (int): The number of canvases to create
width (int): The width (in pixels) of the canvases
height (int): The height (in pixels) of the canvases
"""
_model_name = Unicode('MultiCanvasModel').tag(sync=True)
_view_name = Unicode('MultiCanvasView').tag(sync=True)
_canvases = List(Instance(Canvas)).tag(sync=True, **widget_serialization)
def __init__(self, n_canvases=3, *args, **kwargs):
"""Constructor."""
super(MultiCanvas, self).__init__(*args, _canvases=[Canvas() for _ in range(n_canvases)], **kwargs)
def __getitem__(self, key):
"""Access one of the Canvas instances."""
return self._canvases[key]
def __setattr__(self, name, value):
super(MultiCanvas, self).__setattr__(name, value)
if name in ('caching', 'width', 'height'):
for layer in self._canvases:
setattr(layer, name, value)
def __setattr__(self, name, value):
super(Canvas, self).__setattr__(name, value)
canvas_attrs = ['fill_style', 'stroke_style', 'global_alpha', 'font', 'text_align',
'text_baseline', 'direction', 'global_composite_operation',
'line_width', 'line_cap', 'line_join', 'miter_limit', 'line_dash_offset',
'shadow_offset_x', 'shadow_offset_y', 'shadow_blur', 'shadow_color']
if name in canvas_attrs:
command = {
'name': 'set',
'attr': to_camel_case(name),
'value': value
}
self._send_command(command)