[FAQ] "Best" GUI toolkit for python

Michael Torrie torriem at gmail.com
Tue Oct 18 11:07:37 EDT 2016


On 10/18/2016 01:16 AM, pozz wrote:
>> I am also learning Python so my experience is limited.  I have
>> tried pyGTK and Tkinter.  GTK's concept of the hbox and vbox
>> gave me of difficulty.  I couldn't get the GUI to look the way
>> I wanted.
> 
> Yes, it's exactly my situation.  I understand boxes give a lot of 
> flexibility, but for simple GUI they are very complex.
> Did you try Glade GUI builder applcation?

Using hbox, vbox, and tables within Glade should give you a good idea
how they work and how to use them I think. They are not complex, even
for simple GUIs.  Get familiar with how the various packing flags work
(expand, fill, pack type).  And you feel free to use several kinds of
nested packing managers. It's not uncommon to have an hbox inside of a
vbox inside of an hbox, for example.

>> OTOH, Tkinter offers a way to place widgets on a
>> window/frame in a precise way:  self.widget.place(x=#, y=#)
>> That is similar to VB's move statement.  GTK may have such a
>> feature but I was not able to find it.
> 
> Yes, it seems GTK has a similar feature.  It is the container GtkFixed 
> (https://developer.gnome.org/gtk3/stable/GtkFixed.html).
> 
>        The GtkFixed widget is a container which can place child
>        widgets at fixed positions and with fixed sizes, given in
>        pixels. GtkFixed performs no automatic layout management.
> 
> At the moment, I didn't tested GtkFixed yet, but it seems very simple to 
> use. I hope Glade gives a good support for it.

Glade does support the use of GtkFixed, but I highly recommend avoiding
the temptation to use it. It's there because there are the occasional
cases where you need pixel-perfect placing, but you should never use it
for general GUI use.  Why would you want your GUI to not be able to
resize or adapt to HiDPI screens?  I think Visual Studio and Windows did
us all a huge disfavor promoting fixed layouts.  There's simply no need
for them.  I've yet to see a layout that didn't work with a combination
of vboxes, hboxes, and table layouts. If you posted a fixed layout, I
would be willing to show you how to do it with a dynamic layout.




More information about the Python-list mailing list