python GUI compared to Swing?

mike rodent picture mike rodent · Oct 17, 2011 · Viewed 10.3k times · Source

I wanted to say "best python GUI compared to Swing"... but was sternly told my question was "too subjective". I apologise to the deterministic ghost in the machine.

I'm currently using Jython... have been using it for maybe 6 months now following years of Java. I love Jython's ability to call on all the Java classes, and also to ease the transition from a Java way of doing things to a Python way.

But thinking about it I realise that by far the most common Java packages I'm using are the Swing ones. I have spent many years wrestling with Swing and finally think I have the beast under some kind of body-lock. I also think Swing is wonderful, by the way, and I have to say that I am something of a keyboard fanatic, for example, so wouldn't want to switch to a GUI where you don't have power akin to that lurking in ActionMap-InputMap, which maybe not many people care that much about. It would also be a shame really to turn my back on JTree and JTable, having spent so much time tearing out what was left of my hair about them. Seriously, they are fiendishly powerful...

But at the same time I'm fast becoming hooked on the Python way of doing things. I can and intend to stick with Jython. But I was just wondering what the various CPython GUIs are like... and specifically how their power and versatility compare with Swing?

added: I have been asked to provide some specifics: OK, what about a tree GUI object sitting on a scroll pane where it is possible, if you want to, to control navigation and collapsing/expanding of nodes using the keyboard... where the scrolling happens automatically (if you want it to) and where you have control over look and feel, etc. Or tables where you have comprehensive control over resizing, over what happens when individual cells gain/lost focus. Where you can subclass renderers and editors. As I said in my comment, someone who is/was keen on, and a big user of, Swing but nonetheless made a transition to a CPython GUI and was happy/unhappy... might be the ideal person to answer this.

Answer

Petr Viktorin picture Petr Viktorin · Oct 17, 2011

I never done much with Swing, but Qt (and its bython bindings, PySide or PyQt4), matches all of your criteria as far as I can understand them.

Qt focuses on doing things as it's customary on the underlying OS. So the most obvious thing to do is usually the “right” thing to do, but if you want control you can go and override the look or behavior.

As for the pythonic way of doing things... The bindings are getting there. They still feel somewhat C++-ey, to be honest.

Also read some other questions on comparison between the two.