After#
Tkinter is single-threaded: long work blocks the event loop and freezes the UI.
The after methods schedule callbacks to run later on the event loop, which
is how you defer work, poll, or animate without threads. To run genuinely
blocking work off the main thread and marshal the result back, see
Run background work.
The canonical upstream reference is the Tcl after manual page (Tcl 8.6).
- after(ms, func=None, *args)
Schedule
func(*args)to run once, aftermsmilliseconds, on the event loop.
- after_idle(func, *args)
Schedule
func(*args)to run once the event loop next becomes idle (after pending events are processed).- Parameters:
func – the callback.
args – positional arguments passed to
func.
- Returns:
an id that can be passed to
after_cancel.- Return type:
- after_cancel(id)
Cancel a callback previously scheduled with
afterorafter_idle.- Parameters:
id – the id returned by the scheduling call.
- Returns:
None.
- after_info(id=None)
Report the callbacks scheduled with
after/after_idlethat have not yet run — useful when tracking down a timer that outlives the widget it updates.- Parameters:
id – an optional scheduling id to ask about.
- Returns:
with no argument, the ids of all pending callbacks; with an
id, that callback’s(script, type), where type is"timer"or"idle".- Return type: