Reputation: 95
In Jupiter lab, can I have an ipywidgets "Save" and "Load" buttons which call the save/load of the notebook?
And can I access the is_saved attribute of the notebook?
Much thanks!
Upvotes: 1
Views: 161
Reputation: 429
Yes, just use the ipywidget button with the module ipylab. This module make a connection with the jupyterlab's backend/frontend.
from ipylab import JupyterFrontEnd
from ipywidgets import widgets
def save_button_func(button):
app = JupyterFrontEnd()
app.commands.execute('docmanager:save')
save_button = widgets.Button()
save_button.description = 'Save this notebook'
save_button.on_click(save_button_func)
save_button
to load notebook is the same logic, you can find the code with element inspect on the browser or search in git project.
Upvotes: 1