简体   繁体   中英

wxPython Equivalent to Tkinter .after()

Is there an equivalent 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM