GUI and Desktop Modules

tkinter

Python interface to Tcl/Tk for desktop widgets, geometry management, callbacks and event dispatch. Tk() initializes a graphical root; create widgets and enter mainloop() in a desktop application with display support. Tcl() can run Tcl commands without loading Tk. Keep long operations out of event callbacks to maintain responsiveness.

Formal Syntax & Structure

python syntaxpython
import tkinter

Return Value

module

Module namespace available through import; import is a statement, not a value-returning expression.

Working Example

Example Snippetpython
import tkinter as tkinterpreter = tk.Tcl()print(interpreter.eval("expr {2 + 3}"))
Python Reference