You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's a snippet to add a new cell and insert the text i=1 into that next cell.
fromipylabimportJupyterFrontEndimporttimeapp=JupyterFrontEnd()
app.commands.execute("notebook:insert-cell-below")
time.sleep(0.1)
app.commands.execute("notebook:replace-selection", {"text": "i = 1"})
It also works without time.sleep(0.1), but then it happens that in about 1 out of 10 cases it only inserts the cell, but does not add the text. Probably because the notebook:replace-selection is called before the insert-cell-below is finished. With time.sleep(0.1) I did not experience any issue.
The text was updated successfully, but these errors were encountered:
I'm trying to do similar things. Is there any way to determine the current cell-cursor position? I want to update the text of a single cell repeatedly from a widget
Here's a snippet to add a new cell and insert the text
i=1
into that next cell.It also works without
time.sleep(0.1)
, but then it happens that in about 1 out of 10 cases it only inserts the cell, but does not add the text. Probably because the notebook:replace-selection is called before the insert-cell-below is finished. Withtime.sleep(0.1)
I did not experience any issue.The text was updated successfully, but these errors were encountered: