[FAQ] "Best" GUI toolkit for python

Mark Summerfield list at qtrac.plus.com
Tue Oct 18 04:33:28 EDT 2016


On Tuesday, October 18, 2016 at 9:04:48 AM UTC+1, pozz wrote:
> Il 18/10/2016 09:42, Mark Summerfield ha scritto:
[snip]
> Why don't you use a GUI design tool?  Better... how can you design a GUI 
> without seeing it?  For me it's very difficult to "code the GUI".

When I started out I used Qt Designer to produce .ui files (XML) and then used the Qt uic tool to convert this to C++ (although you can convert to Python using pyuic). I then studied the code and learnt from that. And it turns out that it isn't very hard. There is QVBoxLayout - widgets one above the other; QHBoxLayout; widgets side by side; QGridLayout - widgets in a grid. The only complication is when you nest these, say a QVBoxLayout inside a QHBoxLayout inside a QGridLayout; but in practice, once you've done it a few times it isn't hard to picture. However, I know highly skilled people who prefer to use Qt Designer, so it is no big deal either way.

> > Gtk/PyGObject/PyGI
> >
> > Windows is in no way a first class platform for this, so I wouldn't
> > use it. (I wouldn't use it on any other platform either: I think the
> > introspection idea is excellent and wish Qt had done it; but I
> > personally really dislike the direction Gtk has gone in recent
> > years.)
> 
> Could you explain those... "directions" that you don't like?

I'll give you two examples.

Gtk introduced a really useful feature: scrollbar warp. This meant that if you clicked the scrollbar you would be taken to that position proportionally in the list. This is brilliant for very long lists (e.g., in a huge email folder). However, I had to switch the feature off (and that wasn't easy). Why get rid of something so useful? Because they put scrollbar warp on the left click. But I use applications that are built with Gtk 2, Gtk 3, Qt, Motif, etc., and all except for Gtk 3 use left click to scroll down one 'page'. So, depending on the underlying toolkit a left click would do different things and this inconsistency was too annoying to live with. The solution would have been to put scrollbar warp on the right click and left the left click to work like every other scrollbar.

If you use many modern Gtk applications they no longer have a menu bar but instead a menu button. This is due to the influence of mobile. But for desktop users with big screens it now means that to say, open a file, instead of clicking File, then Open, you now have to click Menu button, then File, then Open. So you need an extra click for *everything* you want to do. Thankfully, Firefox allows you to get the menu bar back; but I can't get Evince to do that so I had to switch to Okular (these are PDF viewers). I have no problem with making things nice for mobile users, but at least either detect a big screen and act accordingly, or give the user the choice (as Firefox does although the default of no scrollbar on the desktop version still seems wrong to me).

[snip]

Incidentally, I'm not "picking on Gtk"; I could give lots of criticisms of Qt and other GUI toolkits too.

I really wish there was a "native" pure Python cross-platform toolkit - and people have tried, e.g., http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ but sadly, none has reached the point of being able to replace Tkinter.



More information about the Python-list mailing list