Threads in PyGTK: keep typing while ping-ing

Jean-Paul Calderone exarkun at
Mon Feb 16 15:44:36 CET 2009

On Mon, 16 Feb 2009 05:47:22 -0800 (PST), Mamahita Sela <mamahitasela at> wrote:
>Dear All,
>I have read several howtos for threading in PyGTK. I have tried some but with no luck.
>What i want is: i can keep typing in gtk.TextView while periodically doing ping some hosts.

You don't need threads for this.  The GTK mainloop supports socket event
sources.  This lets you deal with the GUI and with the network in a single
thread without blocking anything.

>I think, the thread part is working since i can ping so fast (even for not reply host, around 3 s for 27 no-reply-host). But, when the ping action is running, i can not typing in textview. What i type while pinging will show up after ping action is done.

This is because you're joining the threads in the GTK thread.  Joining
blocks until the thread being joined exits.  While you're blocking the
GTK thread like this, the GTK GUI is not updated.  If you want to keep
using threads, then you need a way to avoid joining the threads until
you know they're done.


More information about the Python-list mailing list