I want to programmatically create several cells in a Jupyter notebook in JupyterLab.
The idea is that a user can select some experimental data and depending on the selection e.g. serveral plots will be added to the notebook (so that the user can manually change e.g. fit parameters …).
Right now I am using this code to add cells and it is working fine in a classic Jupyter notebook, but it is only creating one cell in JupyterLab (2.1.2):
def create_new_cell(contents): from IPython.core.getipython import get_ipython shell = get_ipython() payload = dict( source='set_next_input', text=contents, replace=False, ) shell.payload_manager.write_payload(payload, single = False)
for x in [‘a’, ‘b’, ‘c’]:
Does anybody have any suggestions what a solution might be?
Is there also a way to add markdown cells to the current Notebook in JupyterLab?