jtpio / ipylab

Control JupyterLab from Python Notebooks with Jupyter Widgets 🧪 ☢️ 🐍

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

list_commands() not working

smith558 opened this issue · comments

image

The command returns an empty list [].

Right, this is because the frontend might not be ready since everything is being executed in a single execute request.

Maybe using on_ready can help: https://github.com/jtpio/ipylab/blob/main/examples/commands.ipynb

@jtpio Thanks! Will try that.

commented

@jtpio
I've recently found a way of doing this without needing the callback and waits for the frontend to be ready in a single request.

from ipylab import JupyterFrontEnd
from jupyter_ui_poll import run_ui_poll_loop
app = JupyterFrontEnd()
func = lambda: None if app.commands.list_commands() == [] else app.commands.list_commands()
print (run_ui_poll_loop(func))