Python Tkinker events [duplicate]
I would want to use time to enable event's callback function in Tkinter.
How do I do something like this using Tkinter
ftime = time()
while 1:
if ftime - time开发者_运维技巧() > 2000:
dosomething
ftime = time()
Note that all I wanted is being able to use time passed to call callback function
Janus
You can use the Tkinter method after to schedule a command to run after a given number of milliseconds. That's considerably better than implementing a tight loop. Remember: the event loop is already an infinite loop, nesting a long running loop inside it causes performance problems.
If you want something to be called more than once after a given period of time you can have a job call itself at regular intervals. There is an example in this answer to the question How to create a timer using tkinter?
精彩评论