473,722 Members | 2,337 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4490
"Erik Johnson" <sp**@nospam.or g> 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.or g> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jul 18 '05 #2
Mike Meyer <mw*@mired.or g> 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*****@python ware.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.or g> 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
4763
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 the others. wxPython seems to be the first-hand choice for people doing W32-programming (with MFC-experience). PyGtk seems to be a modern, very clean and nice approach, but with poor
11
23539
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 are the main criteria. thanks, leo
7
11905
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 wxPython. Mitchell Timin -- "Many are stubborn in pursuit of the path they have chosen, few in
0
1958
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 example below). Both apps run, but the Tkinter app's output doesn't appear. Can anyone see why this isn't working? Using wxPython-2.5.1/Python 2.3.3/Win98 and Win2000.
25
3350
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 Python GUI toolkit is that Tkinter was there first." - Guido van Rossum Guess, that answers my question, but isn't "Tkinter was there first" a very bad answer? :) It is kinda ugly too, so I wonder why it can't be replaced? Or maybe another GUI...
8
1531
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 using import wx nowadays, but I wonder if that advice is followed. Also, I'm still reading some Tkinter docs that seem to use 'from Tkinter import *' a lot. I understand the danger of doing this, but is it safer in these cases, given the more...
44
3695
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 comparison among them on easy coding, pythonish design, beautiful and generous looking, powerful development toolkit, and sufficient documentation, .etc. It's helpful for a GUI beginner. Thank you.
2
3960
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 asynchronous pipe to the external tool via os.popen(). Then, it dumps the output from the external process into a text display. Although threads are often recommended for use with GUI apps, I am able to keep the GUI responsive with Tkinter's event loop,...
5
1357
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 controls, 3D views and the like? Thanks in advance for your hints and advice. Joe
0
8739
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9383
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9236
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9088
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8051
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5995
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4502
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3207
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.