Lifecycle#

Methods that create pauses in, force work through, or tear down the event loop for a widget — used to refresh the display mid-task, wait for something to happen, or destroy a widget.

destroy()

Destroy the widget and all of its descendants, unbinding their callbacks and releasing their resources. Referencing a destroyed widget afterward raises.

Returns:

None.

quit()

Stop the mainloop that is running, without destroying anything. Execution resumes after the mainloop() call; the widgets still exist, so the loop can be entered again.

To close an application you almost always want destroy on the root, which tears the widgets down and ends the loop with them. Reach for quit only when you deliberately want to leave the loop and keep the widget tree — for instance to hand control back to an embedding program.

Returns:

None.

update_idletasks()

Process pending idle work — geometry recalculation and redraws — without handling user input. The safe way to force the display to catch up in the middle of a task.

Returns:

None.

update()

Process all pending events, including user input and redraws. Powerful but easy to misuse: it can re-enter your own callbacks. Prefer update_idletasks unless you truly need input processed.

Returns:

None.

wait_variable(name)

Enter a local event loop until the given variable is written. Alias: waitvar.

Parameters:

name – a tkinter variable (StringVar, IntVar, …) to wait on.

Returns:

None.

wait_window(window=None)

Enter a local event loop until window is destroyed — the usual way to wait for a modal dialog to close.

Parameters:

window – the widget to wait for; defaults to this widget.

Returns:

None.

wait_visibility(window=None)

Enter a local event loop until window becomes visible on screen.

Parameters:

window – the widget to wait for; defaults to this widget.

Returns:

None.

bell(displayof=0)

Ring the system bell.

Parameters:

displayof – ring on the display of the given widget, if provided.

Returns:

None.