This page is a work in progress.

Choosing between wxPython and Tkinter.

Often newbies (including me ;-) ) want to know the differences between Tkinter (the Python included GUI framework) and the add-on wxPython framework. Here's the consensus of people in mailing list:

David Woods:

Cliff Wells:

wxPython (used interchangeably with wxWidgets for this discussion) and Tkinter take two different approaches to cross-platform compatibility. wxPython recognizes that most GUIs have very similar features but widely vary in the API used to access them. As such it provides a wrapper around the native GUI so as to provide a common API on all platforms. The advantage of this is a native look-and-feel for wxPython apps. A wxPython app running on Windows looks like any other Windows app. The *same* application running on GNOME will look like any other GNOME app (including picking up the default theme).

Tkinter takes an entirely different approach. Rather than rely on the native widget set, Tkinter solves the cross-platform problem by implementing its *own* from scratch, using the drawing primitives available on each platform. The downside to this is that Tkinter apps tend to look like misfits on every desktop. I can tell just by looking at a screenshot if a program was written using Tkinter.

Bryan Oakley:

Some of the above information is outdated. Tkinter uses native widgets when possible and has done so for many years. Also, with recent builds of Tkinter (python 2.7+) it comes with themed widgets which provide even more native look and feel and the ability to implement themes.

I view the difference between Tkinter and wxPython as the difference between Home Depot (a US based home improvement store) and IKEA (a home furnishings store). With Tkinter you've got the nuts and bolts and lumber to do the job but you sometimes have to do more work. On the other hand, a master craftsman can build just about anything he/she wants with Tkinter.

The greatest strength to Tkinter is the binding mechanism which is more flexible than wxPython's. Also, the fact that there are only three geometry managers to do the work of all the wxPython sizers means geometry management is (in the eye of the beholder) much more simplified and straight-forward while having all of the power and more of wxPython sizers.

wxPython, OTOH, has many more widgets that are very customizable. Arguably, wxPython apps look better out of the box than Tkinter apps. wxPython's AUI module has a lot to offer. It's possible to do the same AUI-like features in Tkinter but it would require a fair amount of work.

In my experience Tkinter is much more stable than wxPython.

Pros and Cons of each

For the developer, there are several things to consider:

Tkinter

Pros:

  1. Mature, stable.
  2. Widely ported.
  3. De facto default GUI toolkit for Python (included with distro).
  4. Simple API is easy to learn.

Cons:

  1. Non-native look-and-feel.
  2. Simplistic model is easy to learn, but becomes cumbersome with complex interfaces.
  3. To be truly usable, requires downloading extra toolkits (PMW for example).
  4. Probably a dead-end technology, as toolkits such as wxPython gain mindshare.

wxPython

Pros:

  1. Large library of widgets
  2. Native look-and-feel.
  3. Very flexible.
  4. Very helpful user community (which you've found =)

Cons:

  1. Very active development (although this is a pro as well ;) ) means that there are quite often bugs and, less often, API changes.

  2. Requires downloading and installing (not included with Python).
  3. Once you start using it, you'll find yourself evangelizing as much as you program ;)

And Again by Cliff:

Yes, with wxPython you pay the price up front, in the learning curve. With Tk you pay it later, when you're developing applications with real interface requirements.

Will Sadkin injected his experiences:

There was also a consensus that the "native Tk look" was being done through some native work and some work within the library to make things look right.

One of the features not listed that I think might be important is that wxPython can be used with wxWidgets as a RAD (Rapid Application Development) tool. Things will look similar if you want to go C++ for speed/size issues.

Also available is a page from 'Python Programming on Win32', from O'Reilly which goes into much greater detail than we have here and compares Tkinter, PythonWin and wxWidgets (formerly known as wxWindows).

Comments...

I would love to see a comparison between wxPython and PyQt. Is there not anyone out there who has used both toolkits for real work who can write a page like this, but for wxPython vs. PyQt?

--Jan Persson

I'll create ComparingWxPythonAndPyQt for this purpose.

Should we add that one of the Pros of Tkinter is the Canvas widget? I am working on a medium size Python application (15K+ lines) and I use the Canvas widget extensively. Recently wanted to refactor the GUI and perhaps switch from Tkinter to wx or PyGTK but I still have not found any widget that is as powerful as the Tkinter's Canvas in the wx toolkit. --Nick Vatamaniuc

Choosing wxPython over Tkinter (last edited 2010-11-09 20:58:30 by pat1)

NOTE: To edit pages in this wiki you must be a member of the TrustedEditorsGroup.