LicensePython license Edit this on Wikidata

Tkinter is a Python binding to the Tk GUI toolkit. It is the standard Python interface to the Tk GUI toolkit,[1] and is Python's de facto standard GUI.[2] Tkinter is included with standard Linux, Microsoft Windows and macOS installs of Python.

The name Tkinter comes from Tk interface. Tkinter was written by Steen Lumholt and Guido van Rossum,[3] then later revised by Fredrik Lundh.[4]

Tkinter is free software released under a Python license.[5]


As with most other modern Tk bindings, Tkinter is implemented as a Python wrapper around a complete Tcl interpreter embedded in the Python interpreter. Tkinter calls are translated into Tcl commands, which are fed to this embedded interpreter, thus making it possible to mix Python and Tcl in a single application.

There are several popular GUI library alternatives available, such as wxPython, PyQt, PySide, Pygame, Pyglet, and PyGObject.

Some definitions


This term has different meanings in different contexts, but in general it refers to a rectangular area somewhere on the user's display screen.

Top-level window

A window which acts as a child of the primary window. It will be decorated with the standard frame and controls for the desktop manager. It can be moved around the desktop and can usually be resized.


The generic term for any of the building blocks that make up an application in a graphical user interface.


In Tkinter, the Frame widget is the basic unit of organization for complex layouts. A frame is a rectangular area that can contain other widgets.

Child and parent

When any widget is created, a parent–child relationship is created. For example, if you place a text label inside a frame, the frame is the parent of the label.

A minimal application

Here is a minimal Python 3 Tkinter application with one widget:[9]

#!/usr/bin/env python3
from tkinter import *
root = Tk() 							# Create the root (base) window 
w = Label(root, text="Hello, world!") 	# Create a label with words
w.pack() 								# Put the label into the window
root.mainloop() 						# Start the event loop

For Python 2, the only difference is the word "tkinter" in the import command will be capitalized to "Tkinter".[10]


There are four stages to creating a widget[11]

create it within a frame
change the widgets attributes.
pack it into position so it becomes visible. Developers also have the option to use .grid() (row=int, column=int to define rows and columns to position the widget, defaults to 0) and .place() (relx=int or decimal, rely=int or decimal, define coordinates in the frame, or window).
bind it to a function or event.

These are often compressed, and the order can vary.

Simple application

Using the object-oriented paradigm in Python, a simple program would be (requires Tcl version 8.6, which is not used by Python on MacOS by default):

#!/usr/bin/env python3
import tkinter as tk

class Application(tk.Frame):

    def __init__(self, master=None):
        tk.Frame.__init__(self, master)

    def createWidgets(self):
        self.medialLabel = tk.Label(self, text='Hello World')
        self.quitButton = tk.Button(self, text='Quit', command=self.quit)

app = Application()
app.master.title('Sample application')

See also

IDLE — example of real usage
IDLE — example of real usage


  1. ^ "Tkinter — Python interface to Tcl/Tk — Python v2.6.1 documentation". Retrieved 2009-03-12.
  2. ^ "Tkinter - Pythoninfo Wiki".
  3. ^ tkinter—Python interface to Tcl/Tk—Python 3.9.10 Documentation
  4. ^ Shipman, John W. (2010-12-12), Tkinter reference: a GUI for Python, New Mexico Tech Computer Center, retrieved 2012-01-11
  5. ^ "Tkinter - Tkinter Wiki". Archived from the original on 2013-11-13. Retrieved 2013-11-13.
  6. ^ "Python issue #2983, "Ttk support for Tkinter"".
  7. ^ "Python subversion revision 69051, which resolves issue #2983 by adding the ttk module".
  8. ^ "Tkinter ttk widgets - Python Tutorial". CodersLegacy. Retrieved 2022-01-13.
  9. ^ "Tkinter 8.5 reference: a GUI for Python".
  10. ^ Fleck, Dan. "Tkinter – GUIs in Python" (PDF). CS112. George Mason University. Retrieved 18 August 2018.
  11. ^ Klein, Bernd. "GUI Programming with Python: Events and Binds". Retrieved 18 August 2018.
  12. ^ "PEP 397 — Python launcher for Windows —". Retrieved 2017-06-07.