pickle.dump
does not save ipywidgets. I tried to use get_state
and send_state
, but it does not work. How to solve it?
w_is = widgets.IntSlider(
value=7,
min=0,
max=10,
step=1,
description='Test:',
disabled=False,
continuous_update=False,
orientation='horizontal',
readout=True,
readout_format='d'
)
# pickle.dump(w_is,open('w_is.pkl','wb'))
# PicklingError: Can't pickle <function <lambda> at 0x0000023391B3FEE0>: attribute lookup <lambda> on jupyter_client.session failed
w_is_state = w_is.get_state()
pickle.dump(w_is_state,open('w_is_state.pkl','wb'))
w_is_state = pickle.load(open('w_is_state.pkl','rb'))
type(w_is_state) # dict
w_is_new = widgets.IntSlider()
w_is_new.send_state(w_is_state)
w_is_new # does not recieve arguments from w_is_state