manzt / anywidget

reusable widgets made easy
https://anywidget.dev
MIT License
490 stars 39 forks source link

Stateful property not syned between javascript and python in the demo #550

Closed johnowhitaker closed 6 months ago

johnowhitaker commented 6 months ago

Screenshot 2024-04-26 123549 The counter example doesn't work as expected for me - the count increments when being clicked but accessing and setting counter.count shows an unrelated value and doesn't change the displayed count in the button.

This is in VSCode on windows. Trying in jupyter notebook v6 gives "Failed to load model class 'AnyModel' from module 'anywidget'" error.

johnowhitaker commented 6 months ago

(In case it isn't clear in the screenshot, I clicked the button 3 times)

manzt commented 6 months ago

Hi there, I'm not able to reproduce this in VS Code. If you can provide a minimal reproducible example (how you created the Python environment and exactly what you ran, that would be very helpful).

Trying in jupyter notebook v6 gives "Failed to load model class 'AnyModel' from module 'anywidget'" error.

This was a bug and I just now pushed a fix in #553. Please pip install anywidget==0.9.10.

manzt commented 6 months ago

Correction: There is a bug in your code snippet.

The traitlet is named value not count. You need to update the example.

counter = CounterWidget()
-- counter.count = 42
++ counter.value = 42
counter
-- counter.count
++ counter.value
johnowhitaker commented 6 months ago

Gah sorry about that, figured it out and came to see you'd already beat me to it.