# Easiest way to create a very simple set of widgets?

**URL:** <https://discourse.slicer.org/t/easiest-way-to-create-a-very-simple-set-of-widgets/8400>\
**Category:** Development\
**Tags:** python, gui\
**Created:** [September 12, 2019, 12:58pm UTC](https://discourse.slicer.org/t/easiest-way-to-create-a-very-simple-set-of-widgets/8400 "2019-09-12T12:58:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christine\_Choirat](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/christine_choirat/32/4711_2.png) [@Christine\_Choirat](https://discourse.slicer.org/u/Christine_Choirat)\
**Post date:** [September 12, 2019, 12:58pm UTC](https://discourse.slicer.org/t/easiest-way-to-create-a-very-simple-set-of-widgets/8400/1 "2019-09-12T12:58:00Z")

</div>

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](https://pythonprogramminglanguage.com/pyqt5-hello-world/) 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

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [September 12, 2019, 1:35pm UTC](https://discourse.slicer.org/t/easiest-way-to-create-a-very-simple-set-of-widgets/8400/2 "2019-09-12T13:35:21Z")

</div>

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:

```auto
>>> 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](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Python_scripting#Start_Here)

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

-Steve

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 12, 2019, 1:45pm UTC](https://discourse.slicer.org/t/easiest-way-to-create-a-very-simple-set-of-widgets/8400/3 "2019-09-12T13:45:59Z")

</div>

There are some more Slicer module development tutorials [here](https://www.slicer.org/wiki/Documentation/Nightly/Training#PerkLab.27s_Slicer_bootcamp_training_materials) that reflect recent developments (e.g., use Qt Designer to create module GUI).

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [September 12, 2019, 1:59pm UTC](https://discourse.slicer.org/t/easiest-way-to-create-a-very-simple-set-of-widgets/8400/4 "2019-09-12T13:59:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Christine\_Choirat](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/christine_choirat/32/4711_2.png) [@Christine\_Choirat](https://discourse.slicer.org/u/Christine_Choirat)\
**Post date:** [September 13, 2019, 2:48pm UTC](https://discourse.slicer.org/t/easiest-way-to-create-a-very-simple-set-of-widgets/8400/5 "2019-09-13T14:48:46Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 13, 2019, 3:09pm UTC](https://discourse.slicer.org/t/easiest-way-to-create-a-very-simple-set-of-widgets/8400/6 "2019-09-13T15:09:11Z")

</div>

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.
