vatlab / sos-notebook

Multi-language Jupyter Notebook
http://vatlab.github.io/SoS
BSD 3-Clause "New" or "Revised" License
176 stars 17 forks source link

Hide console panel by default for slide presentation #319

Closed BoPeng closed 3 years ago

BoPeng commented 3 years ago

@csemken on gitter

I am using it in a workshop on programming paradigms and tools for scientific programming. Specifically, I am using sos-notebook and RISE slideshow to run code during the presentations. It works great. The only problem I am having is that the Console opens automatically, interfering with the slides wherever I cannot close it manually first. This happens with the RISE presenter view (see screenshot above) and decktape pdf export. Is there a way to disable the console view by default?

BoPeng commented 3 years ago

A patch has been pushed basically, you will need to

  1. Check out the master branch
  2. Install sos-notebook, probably using pip install -e .
  3. Install sos kernel, with an updated install script, python -m sos_notebook.install. The output of this command will let you know the location of a configuration file.
  4. Go to the configuration file, change
    "sos_notebook_console_panel": "auto"

    to

    "sos_notebook_console_panel": "false"

Then start jupyter notebook.

Remaining problems:

  1. The panel is displayed and then toggled off, which can be improved.
  2. I very rarely use sos notebook with the side panel off, so the css for the notebook without panel is bad. Ideally the notebook should be centered like other notebooks with more margins, but I do not have time to work on this.

@csemken Please let me know if this works for you.

csemken commented 3 years ago

Thank you @BoPeng!

Turning the panel off via the configuration file works. However, while the panel disappears, it leaves a blank void to the left of the notebook container (see below). This is the same in presentation mode, so that it doesn’t fix the original problem unfortunately.

sos-notebook_noconsole_spacing

I had a quick look at where this comes from. At the end of the toggle the width of the container is $("#notebook").width() - 40 but then suddenly the width and margin-left are reset in this timeout.

Would it be possible to fix this? Toggling the console via the button works as expect, so maybe a quick fix could be to just execute the initial toggle a bit later?

BoPeng commented 3 years ago

This is the 2nd problem I talked about. I will try to restore the location to the default (center with large margins) when the panel is hidden.

BoPeng commented 3 years ago

@csemken Could you test the console_css branch and let me know if it works for you?

csemken commented 3 years ago

@csemken Could you test the console_css branch and let me know if it works for you?

It works! See screenshots below for the presenter view and decktape-generated pdf. Thank you so much!

Screenshot from 2021-05-27 10-15-33 Screenshot from 2021-05-27 10-26-14

csemken commented 3 years ago

I do have one small additional suggestion, although the current solution works perfectly and so is sufficient for my purposes.

I noticed that you save the state of the console in the notebook’s metadata as nb.metadata["sos"]["panel"].displayed. Would it be difficult to use this variable to decide if the console should be shown when sos_notebook_console_panel is set to auto?

This would allow users to turn the panel off (permanently) for individual notebooks.

It is also how the built-in TOC sidebar works: toggling it changes the value of nb.metadata["toc"].toc_window_display and the side bar is shown when the notebook is loaded if this variable is set to true.

BoPeng commented 3 years ago

Will do, but then the configuration option is not needed, right? All you need to do is to create the notebook, turn off console panel, save it, and open again for presentation.

BoPeng commented 3 years ago

Pushed another change to enable this. As I said, this makes the configuration option less useful since you can simple close the console panel, save, and the notebook will be opened next time without console panel.

I will keep the mechanism though since it can be used later to configure things such as shortcuts.

csemken commented 3 years ago

Pushed another change to enable this.

Thank you @BoPeng. I just tested it and it works perfectly.

As I said, this makes the configuration option less useful since you can simple close the console panel, save, and the notebook will be opened next time without console panel.

For this particular application, yes. Sorry I didn’t think of this earlier, it occurred to me yesterday. I hope it wasn’t too much extra work.

I will keep the mechanism though since it can be used later to configure things such as shortcuts.

Great. I also think it is useful to be able to turn the panel off globally. I, for one, don’t currently use it in my workflow.

BoPeng commented 3 years ago

I have merged the branch and released sos notebook 0.22.5.