IPythonPanel

For conceptual usage, see:

class pyrogue.pydm.widgets.IPythonPanel(parent=None, init_channel=None)[source]

An IPython session with a connected Rogue client, in a detachable tab.

A pseudo-terminal running IPython, with pyrogue.interfaces.VirtualClient already connected and bound as client, and the tree root as root. It is the session the Rogue server suggests at startup, opened for the user instead of typed out.

The console runs on the machine displaying the GUI as the user who launched it, not on the Rogue server, and it reaches the tree the same way any other client does, over ZMQ. Anyone who can reach the GUI window can run arbitrary Python, and anything Python can reach, with that user’s privileges, which is why the feature is opt-in.

The connection is its own client in its own process, not the one the PyDM channels share, so a session that is stopped or wedged from the prompt cannot take the rest of the GUI’s channels with it.

IPython starts on first display rather than on construction, so enabling the feature costs nothing until the tab is opened, and the up to five second connection attempt never delays the GUI coming up. Exiting the session starts a fresh, reconnected one.

Parameters:
  • parent (QWidget | None, default: None) – Parent Qt widget.

  • init_channel (str | None, default: None) – Rogue channel whose server the client connects to. Defaults to rogue://0/root, the first entry of ROGUE_SERVERS.

pyrogue.pydm.widgets.ipython_core.ipythonArgv(addr, port, executable=None)[source]

Return the argv that starts IPython with the client already connected.

Started as -m IPython on the interpreter running the GUI rather than through an ipython found on PATH. A console that runs on a different interpreter would import a different, or no, pyrogue, and would not see the PYTHONPATH of a local Rogue build.

-i is what keeps the session alive after the -c code has run, so the connected client stays in the namespace the user types into.

Parameters:
  • addr (str) – Rogue server host name or address.

  • port (int) – Rogue server base ZMQ port.

  • executable (str | None, default: None) – Interpreter to run. Defaults to the running interpreter.

Returns:

Argument vector suitable for pyrogue.pydm.widgets.terminal_core.spawnShell().

Return type:

list[str]

pyrogue.pydm.widgets.ipython_core.startupCode(addr, port)[source]

Return the code IPython runs before handing over the prompt.

Connects a pyrogue.interfaces.VirtualClient and leaves it bound as client, with the tree root as root, which is the naming the Rogue server itself suggests when it starts and the one the notebooks and docs use.

A failure to connect is caught rather than left to propagate. The console is still useful without a link, and the user gets the exact line to retry with once the server is up. VirtualClient prints its own connection banner, so the success path only names what is now in scope.

Parameters:
  • addr (str) – Rogue server host name or address.

  • port (int) – Rogue server base ZMQ port.

Returns:

Python source, passed to IPython as a single -c argument.

Return type:

str