wxpython tkinter_Choosing wxPython over Tkinter

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: wxPython is easier to work with than Tkinter. You can get things up and running more easily and with less "voodoo" code.

Both platforms claim to be cross-platform, but both still have issues on Mac OS-X, a platform I must support. In my (admittedly somewhat superficial) evaluation, wxPython, through MachoPython, seems more stable and more workable on Mac OSX. It seems more cross-platform-ish, at least as far as Mac development goes.

In my perception, wxPython is a rising tool with an active development community, while Tcl/tk and Tkinter are old, worn out, and falling out of favor. It strikes me as the tool of the future, the one with the momentum.

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:Mature, stable.

Widely ported.

De facto default GUI toolkit for Python (included with distro).

Simple API is easy to learn.

Cons:Non-native look-and-feel.

Simplistic model is easy to learn, but becomes cumbersome with complex interfaces.

To be truly usable, requires downloading extra toolkits (PMW for example).

Probably a dead-end technology, as toolkits such as wxPython gain mindshare.

wxPython

Pros:Large library of widgets

Native look-and-feel.

Very flexible.

Very helpful user community (which you've found =)

Cons:Very active development (although this is a pro as well

) means that there are quite often bugs and, less often, API changes.

Requires downloading and installing (not included with Python).

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 are GUI development environments available for it, (eg. wxDesigner, boa constructor, and reportedly others), making it easier to construct, tweak and maintain applications over time. (We use wxDesigner.)

The resulting applications loaded and appeared much more quickly (at least under MSW), presumably due to the native implementation details.

There's a great store of usage examples in the wxPython demo (thanks to Robin Dunn et. al!) that help you figure out the tricky bits for most GUI elements, included as part of the distribution. While not a substitute for written documentation, I'd rather examine working code than pour over a tome to do this any day!

The users group is one of the most attentive, responsive and helpful communities I've ever run across on the net, and the signal to noise ratio has remained quite high over the time that I've been following it. (Kudos to all of you, and particularly to Robin, who is just phenomenal!)

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值