Autocomplete code lines for slicer in an IDE?

new to slicer development, saw this tutorial and they seem to use an IDE that supports autocompleting statements unique to slicer as in the python interactor:

what IDE could i use for that feature ( or how to add slicer API support to IDEs like pycharm?)
Thanks for your help.

The easiest and most robust way of getting auto-complete in an IDE is to attach a Python debugger put a breakpoint in the code where you want to add more code, and make the code stop there.

Auto-complete without debugging relies on static code analysis, which does not work very well for the dynamically constructed Python-wrapped C++ objects that Slicer and its libraries use, but you can give it a try. Specify “PythonSlicer” executable as your Python interpreter for the IDE. I’ve found that Eclipse (LiClipse) auto-complete and documentation lookup works reasonable well. Last time I tried, PyCharm’s skeleton generation failed for many components. I have reported the issue, but there was no follow-up. The issue can be fixed manually by patching of the skeleton generator, but maybe Python wrapping of VTK should be improved instead to make it more friendly to current IDEs.

1 Like

i will try that, thanks a lot!!

Would have some more specific feedback regarding this ?

I think this is already on David Gobbi’s radar - see for example https://discourse.vtk.org/t/vtk-8-2-python-and-vscode/704/3

1 Like

Hello,

I understand that Slicer’s Python auto-complete is not fully supported. Through previous discussions and various configuration attempts, I was able to confirm that auto-completion works to some extent when Slicer is connected to a debugger. However, after resetting my VSCode settings to reproduce the setup, I found that while debugging still works fine, auto-completion no longer functions.

Would you happen to know if there are any additional settings required to enable auto-completion while debugging? Also, I would appreciate any suggestions on how to improve the development experience.

Thank you in advance for your guidance.

Personally I find the python console in Slicer the best way to debug and autocomplete. I don’t find existing IDEs as useful,

With some extra work, the ScriptEditor code could be made really powerful for development and debugging, since it has access to everything needed during the completion callback (it can introspect the python API in addition to already allocated variables). If people have time to invest that’s where I would focus.

1 Like