Show and hide code in Jupyter Notebook Web App
You can control whether to show or hide code of your notebook in Mercury App.
It is done by setting show_code
argument when contructing App
object.
Required packages
You need to install mercury
package to run this example.
Notebook
Please import required package in the first cell:
import mercury as mr
We will add Checkbox
to control code visibility:
show_code = mr.Checkbox(value=True, label="Show code")
The widget will be displayed in the notebook. The next step, is to add app
object:
app = mr.App(title="Show or hide code",
description="You can show and hide code in this app",
show_code=show_code.value)
We setup:
title
- will be used in the sidebar,description
- will be used in the home view,show_code
- control code visibility.
Let's add some example code:
print("Example code ...")
The screenshot with notebook's code in Jupyter Notebook:
Mercury App
Let's run Mercury in the same directory as our notebook:
mercury run
Please open web browser at address http://127.0.0.1:8000
. You should be able to open Mercury App.
You can play with show_code
checkbox: