Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if content.get('event', '') == 'mouse_up':
self._mouse_up_callbacks(content['x'], content['y'])
if content.get('event', '') == 'mouse_out':
self._mouse_out_callbacks(content['x'], content['y'])
if content.get('event', '') == 'touch_start':
self._touch_start_callbacks([(touch['x'], touch['y']) for touch in content['touches']])
if content.get('event', '') == 'touch_end':
self._touch_end_callbacks([(touch['x'], touch['y']) for touch in content['touches']])
if content.get('event', '') == 'touch_move':
self._touch_move_callbacks([(touch['x'], touch['y']) for touch in content['touches']])
if content.get('event', '') == 'touch_cancel':
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)
@property
def size(self):
"""Get the canvas size."""
return (self.width, self.height)
@size.setter
def size(self, value):
"""Set the size of the canvas, this is deprecated, use width and height attributes instead."""
warnings.warn(
'size is deprecated and will be removed in a future release, please use width and height instead.',
DeprecationWarning
)
(self.width, self.height) = value
class Canvas(_CanvasBase):
"""Create a Canvas widget.
Args:
width (int): The width (in pixels) of the canvas
height (int): The height (in pixels) of the canvas
caching (boolean): Whether commands should be cached or not
"""
_model_name = Unicode('CanvasModel').tag(sync=True)
_view_name = Unicode('CanvasView').tag(sync=True)
#: (valid HTML color) The color for filling rectangles and paths. Default to ``'black'``.
fill_style = Color('black')
#: (valid HTML color) The color for rectangles and paths stroke. Default to ``'black'``.
stroke_style = Color('black')