Python 3.0+Input & outputterm
tkinter
module
The standard interface to Tcl/Tk for desktop GUI programs: windows, buttons, entry fields, canvas.
Syntax
import tkinter
tkinter is the only widget toolkit shipped with Python, so a simple window or a classroom game needs no extra installs; modern-looking widgets live in tkinter.ttk. In Python 2 the module was called Tkinter, with a capital letter. Some Linux builds and cloud environments lack it or cannot open a window without a display, and the program blocks in mainloop() until the window is closed.
Examples
import importlib.util
has_tk = importlib.util.find_spec("tkinter") is not None
print(has_tk) # → ? True, если Python собран с Tk
try:
import tkinter
print(tkinter.TkVersion >= 8.5) # → ? True, если библиотека Tk на месте
except ImportError:
print("Tk не установлен") # → ? пакет есть, а _tkinter нет
See also
Open in the full glossarydocs.python.orgReport an inaccuracy