wxPython vs. Tkinter event loops

K

Kevin Walzer

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?
 
C

Chris Mellon

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.
 
S

star.public

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top