SwapOff

Python hacking, redux. 
Filed under

threads

 

Multi-threading and PyGTK

The "easiest" way of integrating threads with PyGTK applications seems to be by using gobject.

Initialisation before starting the GTK main loop:

import gobject
gobject.threads_init()

Schedule any rendering functions from your thread with:

gobject.idle_add(window.queue_draw)

Also useful is the timeout_add function, which schedules periodic callbacks:

gobject.timeout_add(250, window.queue_draw)

Filed under  //   gtk   multicore   python   threads  

Comments [6]