PyGTK custom timing
I need to have a custom timing for a component of my program (essentially i'm counting turns, at the rate of around 20 turns per second). Each turn i need to p开发者_开发技巧rocess some information.
However, I have to do this so that it could work with PyGTK. Any ideas on how to accomplish this?
The simplest solution is to use glib.timeout_add
, which can periodically run code in the GLib main thread.
If your calculation is time-consuming and needs to be run in a different thread, you can use Python's threading.Timer
instead. When you're ready to update the GUI, use glib.idle_add
.
精彩评论