Easiest way to create a very simple set of widgets?

Dear All:

What would the the easiest way to create a very simple GUI, basically a couple of buttons, each button being associated with a user-defined Python function? In other words, is there any way to use snippets such as PyQt5 hello world example, Python GUI - Python from the Slicer’s Python interpreter?

With the dev version, I’m running into: “Reason: Incompatible library version: QtWidgets.so requires version 5.13.0 or later, but QtWidgets provides version 5.10.0.”

Thank you!
Christine

Hi Christine -

Slicer provides everything you need for this - it comes with python and Qt already installed.

Here’s an example of what you can do at the python prompt in Slicer:

>>> b = qt.QPushButton("click me")
>>> b.connect('clicked()', lambda : print('clicked!'))
True
>>> b.show()

There’s a lot more of course, but here’s the starting point:

https://www.slicer.org/wiki/Documentation/Nightly/Developers/Python_scripting#Start_Here

Let us know if you don’t find what you need.

-Steve

There are some more Slicer module development tutorials here that reflect recent developments (e.g., use Qt Designer to create module GUI).

Yes, the Perk lab tutorials are great too - I updated the Start Here wiki page to point there as well.

1 Like

Dear Steve and Andras:

Thank you so much, these are exactly the pointers I was looking for. To put things into context, I had students over summer working on an image segmentation project (not under my direct supervision, so I am somehow familiar with the project, but not aware of all the technical aspects): https://github.com/EricaMoreira/SlicerSemSeg.

My sense was that a (Slicer-based) very simple GUI could be built to wrap Step 6 --> Step 20 of their project and make the user experience more pleasant. I need some time to go through the resources that you suggested, but my sense is that it shouldn’t take too much effort!

Thanks again for your help!
Christine

1 Like

Your results look very nice and it should not be hard to package everything nicely in a Slicer extension so that you don’t need any manual installation/configuration. If you need any help with this then feel free to post specific questions as new topics.