Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FigureWidget doesn't allow draggable polygon #4374

Open
itepifanio opened this issue Oct 5, 2023 · 0 comments
Open

FigureWidget doesn't allow draggable polygon #4374

itepifanio opened this issue Oct 5, 2023 · 0 comments

Comments

@itepifanio
Copy link

Using the following minimal code I wasn't able to draw a closed path and then drag and drop the polygon. Check the full error code.

from plotly.graph_objs._figurewidget import FigureWidget

FigureWidget(
    layout={
        'modebar': {
            "add": [
                "drawclosedpath",
                "eraseshape",
            ]
        },
    }
)
Full error code
ValueError                                Traceback (most recent call last)
File ~/micromamba/envs/streetsurface/lib/python3.10/site-packages/ipywidgets/widgets/widget.py:773, in Widget._handle_msg(self, msg)
    771         if 'buffer_paths' in data:
    772             _put_buffers(state, data['buffer_paths'], msg['buffers'])
--> 773         self.set_state(state)
    775 # Handle a state request.
    776 elif method == 'request_state':

File ~/micromamba/envs/streetsurface/lib/python3.10/site-packages/ipywidgets/widgets/widget.py:650, in Widget.set_state(self, sync_data)
    645         self._send(msg, buffers=echo_buffers)
    647 # The order of these context managers is important. Properties must
    648 # be locked when the hold_trait_notification context manager is
    649 # released and notifications are fired.
--> 650 with self._lock_property(**sync_data), self.hold_trait_notifications():
    651     for name in sync_data:
    652         if name in self.keys:

File ~/micromamba/envs/streetsurface/lib/python3.10/contextlib.py:142, in _GeneratorContextManager.__exit__(self, typ, value, traceback)
    140 if typ is None:
    141     try:
--> 142         next(self.gen)
    143     except StopIteration:
    144         return False

File ~/micromamba/envs/streetsurface/lib/python3.10/site-packages/traitlets/traitlets.py:1502, in HasTraits.hold_trait_notifications(self)
   1500 for changes in cache.values():
   1501     for change in changes:
-> 1502         self.notify_change(change)

File ~/micromamba/envs/streetsurface/lib/python3.10/site-packages/ipywidgets/widgets/widget.py:701, in Widget.notify_change(self, change)
    698     if name in self.keys and self._should_send_property(name, getattr(self, name)):
    699         # Send new state to front-end
    700         self.send_state(key=name)
--> 701 super().notify_change(change)

File ~/micromamba/envs/streetsurface/lib/python3.10/site-packages/traitlets/traitlets.py:1517, in HasTraits.notify_change(self, change)
   1515 def notify_change(self, change):
   1516     """Notify observers of a change event"""
-> 1517     return self._notify_observers(change)

File ~/micromamba/envs/streetsurface/lib/python3.10/site-packages/traitlets/traitlets.py:1564, in HasTraits._notify_observers(self, event)
   1561 elif isinstance(c, EventHandler) and c.name is not None:
   1562     c = getattr(self, c.name)
-> 1564 c(event)

File ~/micromamba/envs/streetsurface/lib/python3.10/site-packages/plotly/basewidget.py:644, in BaseFigureWidget._handler_js2py_relayout(self, change)
    640     relayout_data.pop("lastInputTime")
    642 # Perform relayout
    643 # ----------------
--> 644 self.plotly_relayout(relayout_data=relayout_data, source_view_id=source_view_id)
    646 self._js2py_relayout = None

File ~/micromamba/envs/streetsurface/lib/python3.10/site-packages/plotly/basedatatypes.py:2612, in BaseFigure.plotly_relayout(self, relayout_data, **kwargs)
   2608     msg_kwargs = {}
   2610 # Perform relayout operation on layout dict
   2611 # -----------------------------------------
-> 2612 relayout_changes = self._perform_plotly_relayout(relayout_data)
   2613 if relayout_changes:
   2614     # The relayout operation resulted in a change to some layout
   2615     # properties, so we dispatch change callbacks and send the
   2616     # relayout message to the frontend (if any)
   2617     self._send_relayout_msg(relayout_changes, **msg_kwargs)

File ~/micromamba/envs/streetsurface/lib/python3.10/site-packages/plotly/basedatatypes.py:2648, in BaseFigure._perform_plotly_relayout(self, relayout_data)
   2644         for key_path_str, v in relayout_data.items():
   2646             if not BaseFigure._is_key_path_compatible(key_path_str, self.layout):
-> 2648                 raise ValueError(
   2649                     """
   2650 Invalid property path '{key_path_str}' for layout
   2651 """.format(
   2652                         key_path_str=key_path_str
   2653                     )
   2654                 )
   2656             # Apply set operation on the layout dict
   2657             val_changed = BaseFigure._set_in(self._layout, key_path_str, v)

ValueError: 
Invalid property path 'shapes[0].path' for layout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant