Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def set_widget(self, jp_imgw):
"""Call this method with the Jupyter image widget (image_w)
that will be used.
"""
super(ImageViewEvent, self).set_widget(jp_imgw)
self.jp_evt = EventListener(source=jp_imgw)
self.jp_evt.watched_events = [
'keydown', 'keyup', 'mouseenter', 'mouseleave',
'mousedown', 'mouseup', 'mousemove', 'wheel',
'contextmenu'
]
self.jp_evt.prevent_default_action = True
self.jp_evt.on_dom_event(self._handle_event)
self.logger.info("installed event handlers")
return self.make_callback('map')
from .core import BaseWWTWidget
from .layers import ImageLayer
from .jupyter_server import serve_file
from . import __version__
__all__ = ['WWTJupyterWidget']
_npm_version = (__version__.replace('.alpha', '-alpha.')
.replace('.beta', '-beta.')
.replace('.dev', '-dev.')
.replace('.rc', '-rc.'))
VIEW_MODULE_VERSION = _npm_version
MODEL_MODULE_VERSION = _npm_version
dom_listener = DOMListener()
@widgets.register
class WWTJupyterWidget(widgets.DOMWidget, BaseWWTWidget):
"""
An AAS WorldWide Telescope Jupyter widget.
"""
_view_name = Unicode('WWTView').tag(sync=True)
_model_name = Unicode('WWTModel').tag(sync=True)
_view_module = Unicode('pywwt').tag(sync=True)
_model_module = Unicode('pywwt').tag(sync=True)
_view_module_version = Unicode(VIEW_MODULE_VERSION).tag(sync=True)
_model_module_version = Unicode(MODEL_MODULE_VERSION).tag(sync=True)
_ra = Float(0.0).tag(sync=True, wwt=None)
def __init__(self, scene_proxy, bridge, *args, **kw):
super(IPyRemoteWidget, self).__init__(scene_proxy, bridge, *args, **kw)
self.image = Image(format='PNG')
self.event = Event(
source=self.image,
watched_events=[
'dragstart', 'mouseenter', 'mouseleave',
'mousedown', 'mouseup', 'mousemove', 'wheel',
'keyup', 'keydown'
],
prevent_default_action=True
)
self.event.on_dom_event(self.handle_ipyevent)
self._update_image()