We have two scripted module templates now: scripted and scripteddesigner. The “scripted” template has several limitations: GUI widgets are created from code, parameter node is not used (user choices are not saved in the scene), logic is not created in the widget (so it is not accessible from other modules).
What do you think about replacing “scripted” template by the new “scripteddesigner” template?
It would be nice to have just one template that supported both approaches.
I can certainly add an example in the template that shows how to add a widget using Python code.
I think it is a good idea to retire the old scripted module template. I don’t see any advantages for using that. Besides, it tends to confuse people at bootcamps, so I imagine that it would confuse any non-expert Slicer developer as well. Better to not have any obsolete options exposed.
Now under Extension Wizards there are all 4 options of scripted, scriptededitoreffect, scriptedsegmenteditoreffect, and scripteddesigner. If scripteddesigner is recommended, is there a tutorial link for this? Thank you.
I’m sorry if this is a dumb question but I can’t seem to find the scripteddesigner template. Can someone offer a hand by any chance?
The “scripteddesigner” template has been replaced by just the “scripted” template. There are currently the following module template options when using the Extension Wizard:
Also see where-can-i-find-the-extension-templates.
Oh okay thanks. There’s this one section of code that comes with the template that I’d like clarification on:
uiWidget = slicer.util.loadUI(self.resourcePath('UI/DisplayData.ui'))
self.ui = slicer.util.childWidgetVariables(uiWidget)
There’s a tutorial on youtube that doesn’t seem to be using the same template, and doesn’t have three lines of code above. Is the code above required, or is it a place holder that I can replace by writing something similar to what’s shown in the video?
Coding up user interface in python was the old recommendation, but using a UI file which you can manipulate using the Qt Designer is the easier and the current recommendation. The above code that you wrote is the current recommendation so you should continue with that.
I’m very new to this (this is my second week of using 3D Slicer) so I apologize if these questions sound dumb. I googled Qt Designer and it appears to be a separate program. Do I install this, create a widget app, and then specify the file path where
'UI/DisplayData.ui' currently is in the first line of the code I pasted above? Do I then need to add a folder named “UI” inside the directory for the module?
For developers convenience, Qt Designer is bundled with Slicer. You can find a Slicer programming tutorial that uses the designer here.
Thanks so much! This helps a lot.