[Pygui] Getting idle events, or periodic time from the event loop

Casey Duncan casey.duncan at gmail.com
Fri Feb 18 01:22:28 CET 2011


Hi PyGUI!

I got a little inspiration to write a terminal emulator app today, and
I want to give PyGUI a spin as well. My first crack is to just write a
dumb terminal that can print the output of the shell process to a
window, and then take some input. Later on this is going to get more
sophisticated, so this will actually make sense to use a GUI, but bear
with me for now.

I found a module to handle the actually text part of the terminal
handling, so that's nice. It doesn't seem too hard to use a Label or
something to draw some text on the screen for a first try, though
truth be told, a lower-level font rendering api would be very nice,
which is something I could possibly help with at some point, if I get
that far.

So my PyGUI program creates a window with a view in it. It spawns a
subprocess to run the shell that will be displayed in the window. The
GUI needs to listen to user events, of course, but it must also poll
the subprocess to see if it has generated any output to display. Once
I start the application main loop, I don't know how to do this
polling. I could do it in a separate thread, but that seems bogus plus
I don't know how the thread would communicate back to the main loop, I
just want to check the output several times a second, most of the time
there will be none. I'm going to be careful not to block the main
process by reading from the subprocess only when I know there's data
to be read.

What I'd like are either idle events, an idle callback hook, or a way
to schedule some callable to be executed in the future (like pyglet's
clock). Looking at the code, I don't see any way to do this. Any
ideas?

Thanks.

-Casey


More information about the Pygui mailing list