Skip to content

Commit

Permalink
chore: type view_data traitlet
Browse files Browse the repository at this point in the history
  • Loading branch information
iisakkirotko authored and maartenbreddels committed Dec 23, 2024
1 parent daeaca7 commit d724298
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion bqplot_image_gl/viewlistener.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@
from ipywidgets.widgets import widget_serialization
from traitlets import Unicode, Dict, Instance
from bqplot_image_gl._version import __version__
from typing import TypedDict, cast, Dict as DictType

__all__ = ['ViewListener']


class ViewDataEntry(TypedDict):
x: float
y: float
width: float
height: float


@widgets.register
class ViewListener(widgets.DOMWidget):
_view_name = Unicode('ViewListener').tag(sync=True)
Expand All @@ -17,7 +25,7 @@ class ViewListener(widgets.DOMWidget):

widget = Instance(widgets.Widget).tag(sync=True, **widget_serialization)
css_selector = Unicode(None, allow_none=True).tag(sync=True)
view_data = Dict().tag(sync=True)
view_data = Dict(value_trait=cast(DictType[str, ViewDataEntry], {})).tag(sync=True)

def __init__(self, **kwargs):
super().__init__(**kwargs)
Expand Down

0 comments on commit d724298

Please sign in to comment.