How to send python code from an external application?

Hi,
I was wondering how to send python code from an external application ?

There’s not a standard way to send arbitrary python commands to slicer (and it might be considered unsafe in general). You could set up a socket to listen for strings and then execute them as python code. I have done experiments with embedding a web server in slicer and it can work.

We have been experimenting with using “Slicer” (or more generally application that are qt+pythonqt+ctk based as a jupyter/ipython kernel).

See https://github.com/commontk/QEmbedIPython and http://jupyter.org/

That said, there is nothing like this readily available in 3D Slicer.

Here what I envision:

  • install a jupyter extension (e.g pip install slicer-jupyter-bridge) in the jupyter interface.
  • install an extension in 3D Slicer using the extension manager
  • and optionally you could even install something like itk-jupyter-widgets to visualize images directly in jupyter

Let us know if you have any questions

Cc: @thewtex

1 Like

It would be awesome to have all these. Can QEmbedIPython be already used with Slicer or there are still some unresolved issues?