473,407 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

GUIs: wxPython vs. Tkinter (and others)


I am looking for some input on GUI libraries. I want to build a
Python-driven GUI, but don't really understand the playing field very well.
I have generally heard good things about wxPython. I happen to already own
John Grayson's book about Tkinter programming, so that is rather handy if I
decide to use Tkinter. I have done some things slightly more involved than
"Hello World" in Tkinter - I have never used wxPython. So, basically the
points I am looking to have illuminated are:

o What features does wxPython offer that Tkinter cannot (and vice
versa)?
o Is the general programming methodology pretty much the same between
the two (e.g., the general program structure - using callbacks & Frames,
etc. is the same, it's just a question of calling different widgets with
their own arguments)?
o Do you have a strong preference for one over the other (or some other
toolkit)? Why?
o Are there any platform and/or performance issues I should be aware of?
o Is animation and graphics particularly better suited to one over the
other?
o Other important contrasts/similarities I should be aware of?

So... I know this question must come up fairly often. I did do a search
for "wxPython" and "Tkinter" - of the articles I currently have visibility
of, I saw one bug in wxPython discussed and nothing about Tkinter. Anything
else than can contribute to a "bird's eye view" understanding of the two (or
other) toolkits would be appreciated.

Thanks for taking the time to read my post.

Sincerely,
-ej
Jul 18 '05 #1
8 4453
"Erik Johnson" <sp**@nospam.org> writes:
I am looking for some input on GUI libraries.
Since you said others, I'll recommend PyQt. Major downside with it is
that it costs money on Windows.
o What features does wxPython offer that Tkinter cannot (and vice
versa)?
I don't know about wxPython, but PyQt includes it's own threading
facility, plus hooks to talk to databases. It also has a widget for
creating Windows "wizards" for walking through a set of options.
o Is the general programming methodology pretty much the same between
the two (e.g., the general program structure - using callbacks & Frames,
etc. is the same, it's just a question of calling different widgets with
their own arguments)?
Not for Qt. It has the notion of SLOTs and SIGNALs. You connect a
signal from an object to a slot or signal on another (or the same)
object. You can, for example, connect a signal from a slider widget to
a slot on a digital display widget, thus causing the display to change
as you move the slider.

At the python level, slots are just callable objects. At the
C++ level, slots are magic methods of objects. Signals are usually
associated with GUI events, but Python can emit them for whatever
reason it wants. It's possible to connect C++ signals to C++
slots/signals in Python, meaning that Python won't be involved when
that signal is emitted.
o Do you have a strong preference for one over the other (or some other
toolkit)? Why?
I strongly prefer PyQt TkInter. PyQt provides a higher level of
abstraction.
o Is animation and graphics particularly better suited to one over the
other?


I've never tried doing animation in TkInter. Qt provides timer devices
that you can use to drive animations. I suspect that doing the same in
TkInter would be noticably more difficult.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jul 18 '05 #2
Mike Meyer <mw*@mired.org> writes:
I've never tried doing animation in TkInter. Qt provides timer devices
that you can use to drive animations. I suspect that doing the same in
TkInter would be noticably more difficult.


Tkinter supports some kind of event that runs n millisecond (n is a
parameter) after you call the method. You can use that to create a
timing loop. That's more or less what you have to do anyway, if you
want to run your tkinter gui in a separate thread from the rest of
your application. Tkinter isn't thread-safe, so you have to do
something like periodically check a queue from the tkinter thread.
Jul 18 '05 #3
Mike Meyer wrote:
I don't know about wxPython, but PyQt includes it's own threading
facility, plus hooks to talk to databases.
That would of course be a great argument if Python didn't already have
a threading facility, and a standard API for talking to databases with
implementations for all major players.
It also has a widget for creating Windows "wizards" for walking
through a set of options.
Besides the fact that wizards isn't really that great (read Cooper), if your
toolkit doesn't let you create a dialogue with a couple of buttons and a
swappable frame, it's not a very good toolkit. (that's very easy, in both
Tkinter and wxPython. You can probably find ready-made modules on
the net if you look around a little)
o Is the general programming methodology pretty much the same between
the two (e.g., the general program structure - using callbacks & Frames,
etc. is the same, it's just a question of calling different widgets with
their own arguments)?


Not for Qt. It has the notion of SLOTs and SIGNALs. You connect a
signal from an object to a slot or signal on another (or the same)
object. You can, for example, connect a signal from a slider widget to
a slot on a digital display widget, thus causing the display to change
as you move the slider.

At the python level, slots are just callable objects. At the
C++ level, slots are magic methods of objects. Signals are usually
associated with GUI events, but Python can emit them for whatever
reason it wants. It's possible to connect C++ signals to C++
slots/signals in Python, meaning that Python won't be involved when
that signal is emitted.


That's would of course be a great argument if you didn't have Python.
(even if Python's slower than C++, it's a lot faster than a user).

If you want bind an event source (signal) to a slot (method) in one line,
use a lambda. If you need to add more behaviour (you usually do), use
a function.
PyQt provides a higher level of abstraction.
Whan what? C++ plus a low level UI API, sure. But Tkinter+Python?
wxPython+Python? You gotta be kidding.

(or you're borrowing it from Trolltech's marketing material; I notice that
the phrase "higher level of abstraction" is very popular amont Qt fans, but
Trolltech themselves only seem to use it when they talk about lower-level
libraries like X/Xt/Motif and the native Win32 API)
I've never tried doing animation in TkInter. Qt provides timer devices
that you can use to drive animations. I suspect that doing the same in
TkInter would be noticably more difficult.


Eh? You don't know how to do a loop in Python? Or register a callback?
wxPython contains both timers and a low-level graphics API; for Tkinter,
you the "after" facility and the Canvas; if you need lower-level drawing
with tighter Python intergration, use the WCK.

(for more advanced drawing, I'd recommend OpenGL, which is available
for them all)

</F>

Jul 18 '05 #4
Fredrik Lundh wrote:
I don't know about wxPython, but PyQt includes it's own threading
facility, plus hooks to talk to databases.


That would of course be a great argument if Python didn't already have
a threading facility, and a standard API for talking to databases with
implementations for all major players.


Python threading is not perfect in many cases in GUI programming -- you
have to implement your own notification mechanism (eg. using queue
polling), as usually you can communicate with GUI only from main
application's thread. While this is the case also for Qt, QThread
instances have ability to post events to any arbitrary Qt objects, thus
making life a bit easier.

Anyway, all of above mentioned toolkits have its own pros and cons and
in most of cases choice is a matter of personal taste.

--
Jarek Zgoda
http://jpa.berlios.de/ | http://www.zgodowie.org/
Jul 18 '05 #5
Jarek Zgoda wrote:
Fredrik Lundh wrote:
I don't know about wxPython, but PyQt includes it's own threading
facility, plus hooks to talk to databases.


That would of course be a great argument if Python didn't already have
a threading facility, and a standard API for talking to databases with
implementations for all major players.


Python threading is not perfect in many cases in GUI programming -- you
have to implement your own notification mechanism (eg. using queue
polling), as usually you can communicate with GUI only from main
application's thread.


With wxPython, PostEvent (which is what CallAfter also uses) is
threadsafe and can be used from any thread, allowing you to
communicate (in this direction, at least) with the GUI thread
from any regular Python thread. No need for special threads
provided by the framework and, in fact, even though wxWidgets
(on which wxPython is built) provides a wxThread class, it
is not exposed in wxPython because it is redundant there.

-Peter
Jul 18 '05 #6
"Fredrik Lundh" <fr*****@pythonware.com> writes:
Mike Meyer wrote:
It also has a widget for creating Windows "wizards" for walking
through a set of options.

Besides the fact that wizards isn't really that great (read Cooper), if your
toolkit doesn't let you create a dialogue with a couple of buttons and a
swappable frame, it's not a very good toolkit. (that's very easy, in both
Tkinter and wxPython. You can probably find ready-made modules on
the net if you look around a little)


While I'm not a big fan of wizards, for some applications they are
just the ticket, as you're walking down a tree of options. Presenting
the user the options at each node is exactly the way to go. Sure, it
may be easy to roll your own in TkInter, but in PyQt you don't have to.
At the python level, slots are just callable objects. At the
C++ level, slots are magic methods of objects. Signals are usually
associated with GUI events, but Python can emit them for whatever
reason it wants. It's possible to connect C++ signals to C++
slots/signals in Python, meaning that Python won't be involved when
that signal is emitted.


That's would of course be a great argument if you didn't have Python.
(even if Python's slower than C++, it's a lot faster than a user).


It's still nice to be able to let the C++ code handle it all. After
all, having the compiled layer do things for you is what makes for
fast python code.
PyQt provides a higher level of abstraction.


Whan what? C++ plus a low level UI API, sure. But Tkinter+Python?
wxPython+Python? You gotta be kidding.


No, I'm not kidding. I'm stating my general impression after having
done programming with both TkInter and PyQt. Note, that's *Py*Qt, not
Qt.
I've never tried doing animation in TkInter. Qt provides timer devices
that you can use to drive animations. I suspect that doing the same in
TkInter would be noticably more difficult.


Eh? You don't know how to do a loop in Python? Or register a callback?
wxPython contains both timers and a low-level graphics API; for Tkinter,
you the "after" facility and the Canvas; if you need lower-level drawing
with tighter Python intergration, use the WCK.


Sure, you can roll a loop together with a sleep and do animation. You
can throw in threading and queues so you can keep the GUI active while
you're doing it. With Qt, you tie the timer's signal to the
object-moving function, and you're done. Since you have to use the
threaded version to get the same functionality, I'd say noticably more
difficult isn't an overstatement.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jul 18 '05 #7
Hi, I had very bad experience with Tkinter when using input servers(for
CJK languages like scim, xcin...) on Linux (doesn't work), so you might
consider this.

Jul 18 '05 #8
in**@klubko.net wrote:
Hi, I had very bad experience with Tkinter when using input servers(for
CJK languages like scim, xcin...) on Linux (doesn't work), so you might
consider this.


Eh? I use (not frequently, I admit...) kinput2 with canna and wnn servers with
Tkinter on Linux and it works quite smoothly. Can you describe what happens to
you exactly?
--
- Eric Brunel <eric (underscore) brunel (at) despammed (dot) com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com
Jul 18 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: carljohan.rehn | last post by:
I would like like to start doing some GUI-programming in Python, but don't know which library to choose. Tkinter seems a bit old. Correct me if I am wrong! The layout doesn't look as nice as for...
11
by: Leo | last post by:
hi there for somebody who wants tostart small/medium GUI apps with python: what's the best toolkit: tkinter, wxPython or what? stability, ease of use and portability between mac and windows...
7
by: SeeBelow | last post by:
Do many people think that wxPython should replace Tkinter? Is this likely to happen? I ask because I have just started learning Tkinter, and I wonder if I should abandon it in favor of...
0
by: Richard Townsend | last post by:
I've been experimenting with passing a window handle from a wxPython app to a Tkinter app. The Tkinter app should embed a Toplevel window containing a Canvas widget in the wxPython app's Frame (see...
25
by: BJörn Lindqvist | last post by:
See: http://www.wxpython.org/quotes.php. especially: "wxPython is the best and most mature cross-platform GUI toolkit, given a number of constraints. The only reason wxPython isn't the standard...
8
by: John Salerno | last post by:
Hi all. Quick question (but aren't they all?) :) Do you think it's a good idea to use the 'from <name> import *' statement when using a GUI module? It seems on wxPython's site, they recommend...
44
by: jiang.haiyun | last post by:
Now i began to learn GUI programming. There are so many choices of GUI in the python world, wxPython, pyGTK, PyQT, Tkinter, .etc, it's difficult for a novice to decide, however. Can you draw a...
2
by: Kevin Walzer | last post by:
I'm porting a Tkinter application to wxPython and had a question about wxPython's event loop. The Tkinter app provides a GUI to a command-line tool. It gathers user input, and opens an...
5
by: Joe P. Cool | last post by:
So far I have a little experience with Tkinter and wxPython. I wonder which of the numerous Python GUI kits would be the best choice for a multi platform application that makes heavy use of custom...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.