Day 2074 / Developing a 3D Slicer extension
Debugging
-
SlicerRt/SlicerDebuggingTools: Extension for 3D Slicer containing various tools for module development and debugging1
- needs pycharm Pro
- SlicerDebuggingTools/PyDevRemoteDebug/PyDevRemoteDebug.py at master · SlicerRt/SlicerDebuggingTools
- source of the 3dslicer bits
-
pdb-attach · PyPI can attach to random programs,
-
and if I install pdbpp then I get pdbpp <3
-
os.getpid()
is my friend -
Documentation/4.5/Developers/FAQ/Python Scripting - Slicer Wiki at some point it was possible to use python-remote-pdb
-
ionelmc/python-remote-pdb: Remote vanilla PDB (over TCP sockets). 2y last commit
-
I can use these same instructions mostly for pdb-attach, I see no reason it shouldn’t work, python is python
-
it Kiiiinda works but breaks after the first button
- I think pdbpp is my way to go, the usual classic way
-
Giving up for now -
I could install
gnureadline
which then allows things likebreakpoint()
to drop to pdb(pp) from the Slicer python console.- I see colors in the terminal but can’t type, and the python console can’t do escape codes and it’s unreadable.
- and it doesn’t seem to read my ~/.pdbrc.py
- Deleting pdbpp, vanilla pdb debugger in console is OK
- Good enough for now.
- I see colors in the terminal but can’t type, and the python console can’t do escape codes and it’s unreadable.
Basics
Starting Slicer
Loads the module automatically (for some reason doing it manually doesn’t preserve it across restarts?..)
Slicer --additional-module-path /path/to/my/extension/one/lower/than/what/i/would/pick/in/Slicer/GUI
Logging
- Not directly mentioned because always better to have debugger allegedly2
- Slicer/Base/Python/slicer/slicerqt.py at main · Slicer/Slicer has the slicer setup
- I can do
logging.warning("test")
in the python console
CLI modules
Latency etc.
Solution: CLI module (not extension), which can be added to new extension from extension editor.
Now I understad this better: Module Overview — 3D Slicer documentation
- CLI modules are simple I/O, non-blocking, that’s where the networkig logic should go to
- scripted are python scripts with GUIs