4 ms·
The pomodoro example seems to be updating the UI from a background thread. The TkDocs tutorial [1] advices against this and suggests posting a custom event to t
by ptx 3y ago
The pomodoro example seems to be updating the UI from a background thread. The TkDocs tutorial [1] advices against this and suggests posting a custom event to the main thread instead.
Using the after or after_idle methods [2] to post a callback to the main thread also works, and seems easier to me since it allows you to pass arguments.
In this particular example, where the background thread is just used as a timer, you could remove the threading entirely if you use after to let Tkinter handle the timer.
[1] https://tkdocs.com/tutorial/eventloop.html#threads https://tkdocs.com/tutorial/eventloop.html#threads
[2] https://tkdocs.com/shipman/universal.html https://tkdocs.com/shipman/universal.html
- spapas82 3y agoThank you for the suggestion I'll update my code to use after instead!