|
@@ -13,22 +13,23 @@ register_component('interactive_image', __file__, 'interactive_image.js')
|
|
class InteractiveImage(SourceElement, ContentElement):
|
|
class InteractiveImage(SourceElement, ContentElement):
|
|
|
|
|
|
def __init__(self, source: str = '', *,
|
|
def __init__(self, source: str = '', *,
|
|
|
|
+ content: str = '',
|
|
on_mouse: Optional[Callable] = None, events: List[str] = ['click'], cross: bool = False) -> None:
|
|
on_mouse: Optional[Callable] = None, events: List[str] = ['click'], cross: bool = False) -> None:
|
|
"""Interactive Image
|
|
"""Interactive Image
|
|
|
|
|
|
Create an image with an SVG overlay that handles mouse events and yields image coordinates.
|
|
Create an image with an SVG overlay that handles mouse events and yields image coordinates.
|
|
- It's also the best choice for non-flickering image updates.
|
|
|
|
- If the url changes of source faster than images can be loaded by the browser, some images are simply skipped.
|
|
|
|
|
|
+ It is also the best choice for non-flickering image updates.
|
|
|
|
+ If the source URL changes faster than images can be loaded by the browser, some images are simply skipped.
|
|
Thereby a stream of images automatically adapts to the available bandwidth.
|
|
Thereby a stream of images automatically adapts to the available bandwidth.
|
|
See `OpenCV Webcam <https://github.com/zauberzeug/nicegui/tree/main/examples/opencv_webcam/main.py>`_ for an example.
|
|
See `OpenCV Webcam <https://github.com/zauberzeug/nicegui/tree/main/examples/opencv_webcam/main.py>`_ for an example.
|
|
|
|
|
|
:param source: the source of the image; can be an URL or a base64 string
|
|
:param source: the source of the image; can be an URL or a base64 string
|
|
- :param content: svg content which should be overlayed; viewport has the same dimensions as the image
|
|
|
|
|
|
+ :param content: SVG content which should be overlayed; viewport has the same dimensions as the image
|
|
:param on_mouse: callback for mouse events (yields `type`, `image_x` and `image_y`)
|
|
:param on_mouse: callback for mouse events (yields `type`, `image_x` and `image_y`)
|
|
:param events: list of JavaScript events to subscribe to (default: `['click']`)
|
|
:param events: list of JavaScript events to subscribe to (default: `['click']`)
|
|
:param cross: whether to show crosshairs (default: `False`)
|
|
:param cross: whether to show crosshairs (default: `False`)
|
|
"""
|
|
"""
|
|
- super().__init__(tag='interactive_image', source=source, content='')
|
|
|
|
|
|
+ super().__init__(tag='interactive_image', source=source, content=content)
|
|
self._props['events'] = events
|
|
self._props['events'] = events
|
|
self._props['cross'] = cross
|
|
self._props['cross'] = cross
|
|
|
|
|