Table of contents

Taipy out-of-the-box support of Jupyter Notebooks provides us with:
- Taipy full suite of data viz and interactivity tools in our notebooks and
- A sandbox for experimenting with Taipy’s many features.
Introduction
When working with Taipy in Python scripts (.py), we would usually rerun the script whenever we make modifications to our code. The Jupyter Notebook (.ipynb) equivalent would be to restart the kernel and rerun all cells, which would not make for a pleasant coding experience!
To remedy this and to effectively use Taipy in Jupyter Notebook, we should make use of two simple functions for updating the front-end after we make changes to our code:
- Page.set_content – After updating the contents of a page; and
- Gui.reload – After modifying a variable used in a page.
Modifying Page Content
The following code demonstrates creating a simple Taipy web application in Jupyter Notebook:
from taipy.gui import Gui, Markdown page_md = Markdown("Page content") gui = Gui(page=page_md) gui.run()
page_md
, we may be tempted to (incorrectly) modify and rerun our existing Page definition cell like so:# do NOT rerun this cell page_md = Markdown("Page content (updated)")
Doing so will NOT have the intended effect on our web page. Instead, what we should do is use the Page.set_content method (e.g. page_md.set_content(”New content”)
), like so:
from taipy.gui import Gui, Markdown page_md = Markdown("Page content") gui = Gui(page=page_md) gui.run() # this new cell is the only cell that needs to be run! page_md.set_content("Page content (updated)")

Modifying Variable
Another common thing we’d want to do is to modify the value of a variable that we’re using in our Page definition. Take the following Jupyter Notebook as an example:
from taipy.gui import Gui, Markdown title = "GUI in Notebooks" page_md = Markdown("<|{title}|>") gui = Gui(page=page_md) gui.run() # this new cell is the only cell that needs to be run! title = "Taipy GUI in Jupyter Notebook" gui.reload()
title
title = “Taipy GUI in Jupyter Notebook”).To inform Taipy of the changes, we must call Gui.reload (e.g.
gui.reload()
) so that the latest values of the variables are loaded from the Jupyter session namespace. After running the cell, refresh your browser to see the updated changes.
This applies not just to variables in pages, but also to callback functions (e.g. on_change or user-defined callbacks).
Conclusion
Taipy is committed to providing full-fledged web GUIs from both Python scripts and notebooks. As a recap, to efficiently use Taipy GUI within notebooks, be sure to use:
- Page.set_content – After updating the contents of a page; and
- Gui.reload – After modifying a variable used in a page.

Zaccheus Sia
Data Scientist at Knowledge Touch Pte Ltd