Size of buttons in user interface

Hello all,

I am writing my own custom module in python but I have some problem to create a custom user interface.
I have some (basic) questions about it:

  • Is it possible to define the size (width and height) of a QPushButton ?
  • How can I set several buttons side by side in a same row ?
  • How can I display an icon/logo into a QPushButton ?

Is it possible to do all these things without using Qt Designer? only with basic python code?

Thank you for your help,
Best

Yes, all this is possible with python. Best thing to do is read through the related Qt documentation - for the most part the entire public API is available through python in slicer with just small syntax differences from the C++ examples. Also you can look at the python code in any scripted modules and copy any patterns for interfaces you like.

2 Likes

Here is an example of a module (not a simple one, but still may be useful) that uses style sheets that make buttons and other widgets larger so that Slicer can be used on a touch-screen tablet: https://github.com/PerkLab/CentralLineTutor/tree/master/CentralLineTutor

Thank you for your help.

Iā€™m interested in examples of GUI customized for touch-screen applications. Are there any examples available? (The link you posted earlier is not working)

That repository seems to be private, but this one is public: GitHub - SlicerIGT/LumpNav: Slicer extension for ultrasound-guided breast tumor resection (lumpectomy)

1 Like