share
Stack OverflowIs Python any good for GUI development?
[+319] [22] David Arno
[2008-09-22 15:24:58]
[ python user-interface cross-platform ]
[ http://stackoverflow.com/questions/115495/is-python-any-good-for-gui-development ] [DELETED]

I am considering creating a GUI-based tool that I want to be cross-platform. I've dismissed Java, as I personally do not like Swing. I'm currently considering C# and using Mono to make it cross-platform. However I'm wondering if cross-platform languages like Python can offer me a decent GUI development environment.

(80) I wouldn't call Python "new-fangled" See en.wikipedia.org/wiki/Python_(programming_language)#History. I think it predates C# by many years. - S.Lott
(11) Fair point, if a little pedantic :) - David Arno
(22) The issue is that "new-fangled" usually == "risky", "goofy" or "subject to wild changes without notice". - S.Lott
(4) I was under the impression that "subject to wild changes without notice" was a valid criticism of Python. Am I wrong in this regard? That aside, your point is well made: "new fangled" was a poor choice of term. - David Arno
(44) Core Python is fairly conservative: 2 years per major release, no backward-incompatible changes without advance notice (several years in advance). Non-core libraries, of course, may have their own policies. - Constantin
[+203] [2008-09-22 15:45:03] Jon Cage [ACCEPTED]

I've made numerous UI's in wxPython [1] and would highly recommend it. I used to build in VisualC++/MFC, then discovered wxWidgets/C++ and finally moved onto wxPython. I find I'm able to get working GUIs in no time at all with wxPython compared to the other methods and with almost no effort, the same source works on Linux and the Mac* (sometimes you need some tweaks for visual anomalies).

*I generally develop under Windows in case you hadn't guessed.

  • There's a tool, wxDesigner [2], you can use to generate the layout for you or alternatively, you can play with it programmatically. Either way, layout under wxWidgets is done using Sizers [3]. They're quite a powerful way of laying out a GUI and once set up correctly, will automatically resize your controls appropriately for you.

  • There's a nice little tutorial on sourceforge [4] with some good examples of what you can do with sizers.

  • There's another tool, wxGlade [5], I've just discovered which does what wxDesigner does, but for free from a quick trial, might actually be better as well.

  • ..aaaand another tool - Dialog Blocks [6].

[1] http://wxpython.org/
[2] http://www.wxdesigner-software.de/
[3] http://docs.wxwidgets.org/2.8.6/wx_sizeroverview.html
[4] http://neume.sourceforge.net/sizerdemo/
[5] http://wxglade.sourceforge.net/
[6] http://www.dialogblocks.com/

(12) Too sad. Still no wxPython for Python 3. - riza
(3) The link to wxDesigner is dead. - Gabb0
(2) I've fixed the link. - Jon Cage
(2) I find the wx sizer thing odd. I'm used to VB/Delphi style GUI layout, and found the sizer thing almost unusable. It just goes to show that "any good for GUI programming" is pretty subjective. For me, I can not find anything I like using to make guis with python. I find tkinter glitchy, wx unintuitive, and everything else worse. - Warren P
@Warren P: Give wxDesigner a try; you can drag and drop elements onto the gui in the same way that you can in VB. - Jon Cage
(1) I tried wxglade.....its terrible. Its easier to edit code than use it. - eat_a_lemon
Id like to add wxFormBuilder its free , very easy to use , and doesn't look like something made in the 90's... ! #This a opinion of someone new to python , that just want's to make a quick GUI , with a minimum learning curve ! The only minor problem i have with it , is that you need to copy/paste the generated python code. A save as .py feature would save a few key strokes ! - andsoa
(4) @riza as of Dec 25th, 2013, wxPython is compatible with python 3.0! - nobillygreen
1
[+66] [2008-09-22 17:08:10] miya

wxPython is the best and most mature cross-platform GUI toolkit, given a number of constraints. The only reason wxPython isn't the standard Python GUI toolkit is that Tkinter was there first.

-- Guido van Rossum

From http://www.wxpython.org/quotes.php


(6) While I respect his opinion greatly, he doesn't strike me as the sort of person that does very much GUI programming. If I didn't do much GUI programming I'd vote for wxPython too. It has more eye candy, but I'm not convinced it's superior to Tkinter. - Bryan Oakley
2
[+50] [2008-09-22 15:27:45] David Dibben

You could try PyQt [1] This uses the Qt toolkit for the GUI but you write your program in python.

Qt Designer [2] can be used to create GUIs graphically for use with PyQt

[1] http://wiki.python.org/moin/PyQt
[2] http://www.diotavelli.net/PyQtWiki/Creating_GUI_Applications_with_PyQt_and_Qt_Designer

I don't see anything on that site that talks about the IDE working for GUI building, being written with PyQt and being an IDE for it are two different things. Have you used it to actually develop a GUI app? If so, how is it for that? - Joe Skora
(2) @Joe Skora Qt Designer is the GUI building application for Qt. The python bindings for Qt are fine. If you want to take a look at current Qt applications you may checkout Google Earth and Skype. - Vitor
I just know that Skype was built with Qt. Interesting.. - swdev
3
[+18] [2012-01-14 02:41:56] MRocklin

I'll go ahead and field a negative answer (there doesn't seem to be one yet).

Python is not ideal for GUI development. The development tools for GUI development haven't been built up around Python the same way that they have been around enterprise-targeted languages like C#.

There are easily accessible tools to facilitate the development of professional looking GUIs in C#. You can download Visual Studio .NET or Mono and figure out how to build a decent GUI within an hour. Getting the same level of professionalism with the Python toolchain requires substantially more investment.


4
[+17] [2008-10-18 13:51:00] Federico A. Ramponi

Another good wxPython tutorial:

http://zetcode.com/wxpython/


5
[+13] [2008-09-22 15:27:58] torial

There are excellent GUI options for Python. wxPython is a great place to start, pyQT is good if you have spare money.

The biggest issue I've seen is having a tool that lets you layout a form with the ease of Visual Studio -- but I think pyQT has that one resolved, and wxWindows has a version you can pay for.


(4) PyQt4 now has both FOSS and commercial licenses. I personally like it much better than wx. - Paul Du Bois
"...wxWindows has a version you can pay for" -- which is? There are also FOSS alternatives (BoaConstructor, etc). How good they are is open to interpretation. ;) - Adam Parkin
6
[+12] [2008-09-23 13:09:07] crystalattice

As others have said, wxPython is a good GUI library. One thing that isn't mentioned much is that you can combine wxPython with wxGlade to create many "drag and drop" programs.

wxGlade lets you quickly create the framework of your program; you don't have to worry about any of the working code at first. You can just create the visual look until you get it just right. Once that's done, then you start working on the actual coding, but you already have the GUI framework laid out for you. All you have to provide is the programming logic to make your application work.

One benefit of using Python for applications in general is the interpreted environment. You don't have to do the check/compile/run cycle everytime. You can quickly make changes and see them nearly instantaneously, which greatly speeds up development.

Additionally, if you need to speed up the program, you can always write certain parts in C/C++ and pre-compile them. The cPickle module is an example of this. But for many GUI programs, the application will be waiting on the user so speed is usually not an issue.


7
[+9] [2008-09-22 15:43:12] Martin Beckett

Python is excellent for gui development
Speed of execution is less important than speed of development, GUIs change a lot. GUIs generally involve dealing with text and storing state - ideal pythonisms
If your app is in c++/c#, then having the gui written in a different langauge enforces gui/logic separation.

Options are: wxpython/pyQT - equally good, all the functionality of wx/qt from python, both the designers can spit out native python implementations.

IronPython - .net implmentation of python so all winforms and wpf directly from python. You get all the .net libs but only a subset of the native python ones, but it is very easy to mix python gui with other parts of the app writen in c# etc.


How exactly does writing in C++/C# enforce GUI/logic seperation? - Jon Cage
(2) I mean't that having the gui written in a different language enforces separation (I clarified the post) - Martin Beckett
8
[+8] [2008-09-22 17:12:00] Eli Bendersky

To asnwer your question directly:

Yes, Python is excellent for GUI development. Python is dynamic and extremely flexible, traits that are very important for GUI development where one often needs to write a lot of boilerplate code. The bindings for some popular cross-platform GUI libraries (wx, Qt, etc.) are mature, stable, actively developed and well supported.

I've found performance of Python GUI bindings to be good (I'm personally using wxPython and have already written a few functional GUIs both for work and personal use). But if you want to improve it even further, I'm sure it's not too hard to combine the Python binding code with C++ code (using the wxWidgets C++ libarary itself, for instance). Anyhow, I suspect this won't be a problem for you.


9
[+8] [2008-09-22 20:11:21] user19883

Check out the Traits [1] library from Enthought. It's a way of describing different properties of objects, views of those properties, and dynamically updating views. I'm not really doing it justice, but it's an extremely flexible, rapid-development library. Plus, it leads to reusable and extensible code. I've written a couple minor scientific applications in Traits, and I have found it to be an absolute dream, as it lets me focus on the data model rather than the UI.

[1] http://code.enthought.com/projects/traits/

10
[+8] [2012-08-20 08:37:54] Mike Spadaru

This is a pretty old topic and some new frameworks have risen since then.

My personal favorite is PySide, the LGPL Python bindings for Qt. It has many cool features, it looks cool for cross-platform apps, and it has a nice WYSIWYG designer (QtDevelop, QtCreator).

You can find a nice tutorial here: http://zetcode.com/gui/pysidetutorial/ and another tutorial here: http://mspadaru.wordpress.com/youtube-player/ witch explains the development of a PySide app from setting up the tools to compiling the app for Linux and Windows


11
[+6] [2008-09-22 15:29:51] pdavis

Go for it. I think you will find it an easier cross platform route than C#+Mono. Check out Tkinter [1], the Python interface to Tcl/Tk. Tkinter is available for Unix, Windows and Macintosh. It has been a while but as I recall there were a couple of well done IDEs for development and GUI layout.

[1] http://docs.python.org/lib/module-Tkinter.html

(2) Tk is so easy you don't really need an IDE for doing GUI layout. Get yourself a piece of graph paper and a good pencil. That's not tongue-in-cheek: it really is easy to do layouts in Tk -- I've yet to find a toolkit that is easier (though admittedly, I've only used a half dozen or so professionally) - Bryan Oakley
12
[+6] [2008-09-22 17:58:35] Vasil

wxPython is full of bugs on anything besides Windows. PyGTK2 is probably the best GUI toolkit but I don't know on what platforms it is supported, probably everywhere gnome is.


(2) GTK looks horrible (or if you prefer, different) and is unintuitive on Windows and Mac. - Turtle
I like using PyGTK as well. Actually, pyGObject in now prefered (it merged recently with gi). They are working on some cool new features for Gtk+ 3 such as introspection. Also, Gtk is cross-platform. - AJ00200
13
[+4] [2008-09-22 15:32:07] Fostah

I've actually done similar research lately as many of the artist I work with work on Macs. What I found is that wxPython seems pretty robust. My goals were for internal tools development, so I was looking for a more efficient development language than C# and Java.

I'm not an expert in wxPython, but if you are interested in GUI development in Python, I would give this API a try, or at least some research time.


14
[+3] [2009-02-16 10:17:22] nachik

I made a similar/related question a while ago, might serve as reference:

http://stackoverflow.com/questions/520015/cross-platform-gui-toolkit-for-deploying-python-applications


15
[+3] [2011-04-07 15:24:11] Edwin Yip

I think at this moment (April 2011), PySide [1] developed by the QT owner - Nokia is the best choice, it just reached 1.0 release and it provides the same API as PyQt.

[1] http://www.pyside.org/

16
[+2] [2008-09-22 15:44:37] Sebastian Hoitz

You should take a look at IronPython. With it you can use the .NET Framework and I'm pretty sure somehow Mono too!

http://www.google.de/search?hl=en&pwst=1&sa=X&oi=spell&resnum=0&ct=result&cd=1&q=ironpython&spell=1 [1]

[1] http://www.google.de/search?hl=en&pwst=1&sa=X&oi=spell&resnum=0&ct=result&cd=1&q=ironpython&spell=1

(1) IronPython is excellent. Making a first class GUI in WinForms/WPF inside of Visual Studio and then using it with IronPython is just simply the best GUI solution out there. - Finglas
This is interesting. And when we area about to release the application , is it possibile for users wont'h have to know that it was built using Python / IronPython either? - swdev
17
[+2] [2008-10-18 13:41:06] Ed Leafe

Dabo is a Python framework for cross-platform GUI app development. It starts with wxPython for the UI, but completely wraps it in order to eliminate the ugliness and inconsistency that comes with wxPython.

Check out some of the screencasts of Dabo in action at http://dabodev.com/documentation


18
[+2] [2010-01-20 10:13:55] appusajeev

there are numerous GUI tool-kits available for python. Some examples are: tkinter, pyqt, pygtk, and wxwidgets.


19
[0] [2008-09-22 20:15:21] Roberto Bonini

I belive that Chandler ( the Calendar sharing app from Mitch Kapors Open Source Applications Foundation - http://www.chandlerproject.com) is written entirely in Python and wxWidgets.

Can't add anything else as I'm not a Python guy.


20
[0] [2008-10-18 13:45:01] johnstok

With jython you could use Java Swing. 100% cross platform and everybody loves swing - right ;-)


(4) Everybody loves Swing, except OP :) - Constantin
21
[0] [2011-10-29 16:49:25] Richard Johnson

Getting back to a dislike of swing, you can use swing "but not as we know it Jim" by using Groovy and the SwingBuilder, this is a very nice piece of kit and obviously works on any machine with a jvm.


22