开发者

PyGTK custom timing

开发者 https://www.devze.com 2023-04-07 09:20 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消