-
Notifications
You must be signed in to change notification settings - Fork 947
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
Pickle an ipywidget #2879
Comments
I'm also interested in this — would be great to be able to pickle/restore ipywidgets, if that's at all possible? |
Not sure if this solves it, but you can pickle the state: |
How to solve it?
|
I'm not sure if send_state is the right function. Is there a set_state()? |
I tried |
Is there any other way to download the entire widget (including the children widgets) as a file, so that it can be loaded again next time? |
The exception raised when attempting to pickle an ipywidget is very ambiguous. In my case the widget was one attribute of a larger class instance, so it took me days to find this page. I think it would be very helpful if a custom, more descriptive exception was raised @kirk0306 the workaround to pickle a set of widgets is to just pickle a class instance that has a .create_and_display_widgets() method. You just need to make sure to overide the attribute that stores the displayed widgets created by that call before calling pickle.dump(). This workaround solved the problem for my use case. |
It would be amazing if it was possible to pickle an ipywidget. I can pickle and unpickle a plotly.graph_objects.FigureWidget with no problem, so why not ipywidgets?
If I attempt to pickle an ipywidget.Button for example, I get this:
Log
To reproduce
My environment
The text was updated successfully, but these errors were encountered: