Save notebook widget state AND allow widget interaction after reloading notebook - jupyter-notebook

I am using interactive widgets to create plotly traces from dropdown menus. After creating a few traces and using Save Notebook Widget State and saving the notebook, I am able to reopen the notebook and still have my previous traces reload. However, the interactive widgets are no longer active and I am not able to add more traces after reloading the notebook. An icon also shows up next to the dropdowns and I don't know what it means.
I don't want to have to rebuild the plots from scratch every time. I also often need to save the plots and come back at various times to add more plots (traces).
How can I reactivate the interactive widgets (dropdowns) without losing my previously created traces?
Saved widget state output example after reloading notebook

Related

How can I display a markdown reference/cheatsheet within JupyterNotebook

I could swear that several times when working in a Jupyter Notebook, I inadvertently hit some shortcut key that popped up a markdown cheatsheet, within the Notebook window, but I cannot figure out how to access this cheatsheet intentionally, via shortcut or menu. I've searched the Jupyter Notebook docs, but I'm not finding anything.
I am able to access a Markdown guide on GitHub, in a separate page, but not the cheatsheet that appears within the Notebook, similar to the way the "command palette" opens within the Notebook, as a pop-up. The latter is much handier, as it doesn't involve jumping back and forth between browser tabs.

how to print something in a new window in jupyter notebook?

I have seen that in some IDEs, when you print something , a new window opens up.
my question is that is it possible to have the same thing for jupyter notebook ?
P.s:
It would be better if it was customizable; like being able to change the background color of the new window.
You'd want the newer generation of Jupyter interface, JupyterLab. (At least if you want this soon. I don't know what will be possible as Jupyter notebook 7 starts using more of the underlying machinery that JupyterLab uses.)
Default JupyterLab
Using default current JupyterLab, you can make a separate window for any output that you can drag around and arrange how you want. Right-click on an output cell and select from the menu 'Create New View for Output'. That will open a new window that respects the current JupyterLab theme. (There's a lot of theme adapting abilities so maybe that can provide what you need as far as background.) Once the new window is generated you can click and drag it around the JupyterLab window to arrange it relative to the notebook and then release when you have it outlined the way you want. You can try it right in your browser by clicking this link and letting the session spin up.
(This ability was covered in an answer to a similar question 'How to display Jupyterlab output in new tab?'.)
Similarly, you can have a window that keeps updating with the most recent output by using an attached console and toggling on 'Show All Kernel Activity'. When you have a notebook open, either right-click and select 'New Console for Notebook' or go under the main 'File' menu and select 'New Console for Notebook'. This will open a console and you can then right-click on the console pane and toggle on 'Show All Kernel Activity'. As you run things in the notebook, the output will show at the bottom of this window as well. Even rich output like plots and dataframe displays. You can click on the tab and drag to arrange this window as you wish in the main JupyterLAb pane. See some example images using this here and here.
Related:
It's not a separate window; however, a nice feature of JupyterLab is switching to 'View' to 'Render Side-by-Side' where the output goes to the side of the code cell and not below. Alternatively, you can modify the output cell in some ways like you could do in the classic notebook interface, see here.
Sidecar extension of JupyterLab
There's an extension called sidecar for Jupyterlab that I believe has more options. I wonder if you could combine widgets to control the background as you seek. Don't know about the layering possibilities there.
ipylab extension of JupyterLab
ipylab has even more abilities than sidecar for customization, with 'SplitPanel' and 'DockPanel'. Scroll through the examples shown to get an idea of the possibilities. There's also a 'launch binder' badge so you can try it out.
(You may also want to see Related projects listed at the bottom of ipylab's github page.)

Efficiently get rid of all or some objects in RStudio Script pane

I open dataframes all the time in RStudio using View(df) or View(list) which pops open a window in my RStudio script pane as with MASTERstat1 MASTERextract and MASTERbackout1 in the image below:
Is there a way to close all the windows that are NOT SCRIPTS? I inevitably forget to close them and get a ton of them, and stuff gets cluttered.
It looks like it's not currently possible in RStudio, at least as of a month ago.
One sub-optimal workaround mentioned in this answer is to make sure your script tabs are saved and then to close all tabs using Ctrl+Shift+W.
My personal preferred method for closing a lot of unwanted tabs quickly is to use Ctrl+Tab/Ctrl+Shift+Tab for navigating between tabs and Ctrl+W for closing the current tab.
Edit: also potentially useful is Shift+Ctrl+Alt+W, which closes all but the current tab.

"Save and Checkpoint": What notebook state info is "saved"?

I am curious about exactly what notebook state information is saved whenever one clicks "save and checkpoint" in a Jupyter notebook. I know any python changes are saved, but I am wondering if the state of widgets/html that is "displayed" is also saved. For instance: Let's say I have button in the notebook that runs display(HTML(html)) when clicked. If I click that button, display the html, and then save my notebook, will the state of display be saved? Is the state of the notebooks "cells" saved, so that html that is displayed in a new cell is also saved?
Any direction to documentation about the "save and checkpoint" behavior is appreciated. Having trouble finding a detailed description in the Jupyter docs. Thanks!
"Save and checkpoint" is the same as using "Autosave" except that it makes a hidden backup copy on disk (in case you have a later autosave and want to revert). Some plugins can do more with save and checkpoint, like having many checkpoints, but that's not the default behavior.
As for whether it saves the widget state, the answer will sadly be: it depends. For simple, well-written widgets that for example just use #interact; it should. For more complex widgets, it may not because saving arbitrary state is not always feasible.
The best way to know is the following: Write your code in a notebook, save and refresh the page. If it's still there it was saved, otherwise it's not.

Bokeh - Adding a new plot on click of a button

I am using bokeh to plot some graphs. I will be using bokeh serve to serve a python notebook. My use case is as follows:
The page will load with a text box and button. Based on the data that is entered into the text box , I need to show different graphs on button click.
What is the best way to go about it. I have tried adding the plot to the current doc and such. but none of them seem to be working.
I am using bokeh 0.11.1

Resources