Hello all,
I wanted to revisit a discussion about auto completes to work on Slicer source code. I find myself always reading the source code to map many of the C++ code to python wrappers and etc. I visited this issue but it hasnt been discussed much further after 2023. Code autocompletion on VSCode fails
I know the debugger extension is there but its still very difficult how everything interacts
it being to get python.util function and seeing which function are available the in a text editor do work best.
Here are some questions i wanted to inquire:
If i build from source, does vscode support good LSP integration in the code base? Are there way’s to build this from source in a isolated environment. (I ran into soo many dependencies issues especially since im running this on a arm mac.)
Any advice on debugging code beside vscode debugger since the session always needs interupts and takes a long time to set up?
My current wrap around solution is using cursor to study the code base and really just control -f functions and using How to find a Python function for any Slicer features. However if you guys have any more tips, I would love to hear more!
My personal experience is that developing and debugging using the python console in Slicer is more productive than trying to use VSCode because you can run computations and explore the API of allocated variables and not just static symbols. It’s not perfect, and could be improved, but it’s valuable enough for me that I don’t bother with IDE debugging for the most part.
One feature people may not be aware of is that you can access the widget and logic of any scripted module at runtime. E.g.
Being able to run methods and work with the results can help you explore and understand the API in ways that most IDEs don’t support. Combining this with IDE support for searching the source code is usually the best approach for me.
I’d like to expand on a core frustration I have with my development workflow: the constant context-switching between the Slicer Python console and my text editor. I really wish I could have the live Python runtime—with its powerful autocompletion and access to object references—connected directly within my editor.
This leads to my second major challenge: the API can feel unintuitive, making it hard to map an objective to the correct sequence of steps espcially when you lack domain knowledge with VTK and how Slicer works.
Discovering this on my own feels nearly impossible without the FAQ. In scenarios where the documentation doesn’t have the exact answer, I often get stuck in a time-consuming and frustrating cycle of trial and error. Do you have any tips to overcome this?