开发者

wxPython Equivalent to Tkinter .after()

开发者 https://www.devze.com 2023-02-14 18:58 出处:网络
Is there an 开发者_如何学Goequivalent to Tkinter\'s .after() in wxPython? For those that don\'t know .after() allows the running of functions at some point in the future. This can be used to make lo

Is there an 开发者_如何学Goequivalent to Tkinter's .after() in wxPython?

For those that don't know .after() allows the running of functions at some point in the future. This can be used to make loops with functions.

I'm attempting to make a clock, so this would be handy for making it tick.


To answer your specific question, you can use wx.CallAfter and wx.CallLater. The former is roughly equivalent to tkinter's after_idle command, and the latter is the same as after (ie: it takes a number of milliseconds to wait as an argument)

As a third option you can use wx.Timer, upon which wx.CallLater is based. This gives you more control over the scheduled jobs, allowing you to cancel or restart them (similar to what you can do with tkinter's after_cancel)


There are several functions in wx.Python to do that. You should check the "Process and events" section of the wxPython demos, More especifically those related with wx.Timer

The wx.Timer class allows you to execute code at specified intervals from within the wxPython event loop. Timers can be one-shot or repeating. This demo shows the principle method of using a timer (with events) as well as the convenient wx.FutureCall class.

0

精彩评论

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