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

Hold sync during update from front-end is very un-ipywidgets like #3635

Closed
maartenbreddels opened this issue Nov 15, 2022 · 1 comment · Fixed by #3642
Closed

Hold sync during update from front-end is very un-ipywidgets like #3635

maartenbreddels opened this issue Nov 15, 2022 · 1 comment · Fixed by #3642
Assignees

Comments

@maartenbreddels
Copy link
Member

Description

In #3271 we added the behavior that updates from the frontend will wrap the update of traits in a hold_sync() (which is released in >7, <=8.0.2). This behavior feels to me un-ipywidget like (update a property, and the frontend reflects it).

As a response to an event from the front end, very often, some calculation occurs, which takes a bit of time. Before and after that calculation, we often want to give the user some indicator that work is being done.

Now with 8.x we cannot set such an indicator (by changing a property, like description or disabled) on the widget that triggered the original event due to the hold_sync() context manager. Note that it is possible to change any other widget, just not the one we received the event from. This feels (as a user) very inconsistent.

Reproduce

Code

import ipywidgets as widgets
import time

def do_work():
    time.sleep(3)

def on_value(change):
    buttons.description = "Working..."
    buttons.style
    buttons.disabled = True
    do_work()
    buttons.disabled = False
    buttons.description = "Item (restored)"

buttons = widgets.ToggleButtons(options=["foo", "bar"], description="Item")
buttons.observe(on_value, "value")
buttons

7.x behaviour

In 7.x, this works as expected:
hold-sync-issue-7 x

8.x behaviour

In 8.x, this does not work anymore:
hold-sync-issue-8 x

Solution

I think we should no do a hold_sync, and do a new release that removes this, considering this a bug.

@maartenbreddels
Copy link
Member Author

As discussed in the weekly widget meeting, the plan is to:

  • open a PR to revert this
  • open an issue to describe the issue this is trying to solve
  • (optionally) open a PR to re-enable this in a backward-compatible way.

maartenbreddels added a commit to maartenbreddels/ipywidgets that referenced this issue Nov 29, 2022
If we do, we get very inconsistent behaviour, see jupyter-widgets#3635 for more
details and jupyter-widgets#3271 for the reasons to implement this.
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

Successfully merging a pull request may close this issue.

1 participant