By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,315 Members | 1,672 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,315 IT Pros & Developers. It's quick & easy.

wxPython vs. Tkinter event loops

P: n/a
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,
i.e. with regular calls to self.update(); I am still able to update the
GUI as needed. When I tried the same functions using threads, I noticed
no measurable improvement in application responsiveness or performance.
Thus, the application currently runs in a single thread and is updated
via Tkinter's event loop only.

Does wxPython's event loop function as smoothly as Tkinter's with an
asynchronous process, i.e. is the wx.UpdateUIEvent() class analogous to
Tkinter.update(), or are threads absoutely essential to keeping a wx GUI
updated with a long-running background process?
--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
Jul 11 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 7/11/07, Kevin Walzer <kw@codebykevin.comwrote:
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,
i.e. with regular calls to self.update(); I am still able to update the
GUI as needed. When I tried the same functions using threads, I noticed
no measurable improvement in application responsiveness or performance.
Thus, the application currently runs in a single thread and is updated
via Tkinter's event loop only.

Does wxPython's event loop function as smoothly as Tkinter's with an
asynchronous process, i.e. is the wx.UpdateUIEvent() class analogous to
Tkinter.update(),
No. It provides a totally different purpose - it's an idle event thats
used to do things like ensure that menu items and toolbar buttons are
kept in sync.
>or are threads absoutely essential to keeping a wx GUI
updated with a long-running background process?
No again. wxPython provides a Process class for executing external
applications and providing events in response to input, app exit, and
similar. You can also implement it in a similar way to your Tkinter
implementation, but backwards - poll the pipe repeatedly using
wx.CallAfter or wx.CallLater calls.
Jul 11 '07 #2

P: n/a
On Jul 11, 11:17 am, "Chris Mellon" <arka...@gmail.comwrote:
No again. wxPython provides a Process class for executing external
applications and providing events in response to input, app exit, and
similar. You can also implement it in a similar way to your Tkinter
implementation, but backwards - poll the pipe repeatedly using
wx.CallAfter or wx.CallLater calls.
You can also set up a callback on the idle event and do a little
processing every time it's called, though that can be odd because it
tends to e.g. update more often when the mouse is moving over the
window and such. There may be other ways, too, I don't have access to
my docs or the demo here (just poked my head in because I'm waiting
for my work program to stop being frozen ...).

-Weaver

Jul 11 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.