Tkinter is a graphical user interface (GUI) module for Python, you can make desktop apps with Python. You can make windows, buttons, show text and images amongst other things.

Tk and Tkinter apps can run on most Unix platforms. This also works on Windows and Mac OS X.
The module Tkinter is an interface to the Tk GUI toolkit.

Related course: Tkinter GUI Application Development Projects

Example

Tkinter module

This example opens a blank desktop window. The tkinter module is part of the standard library.
To use tkinter, import the tkinter module.

from tkinter import *

This is tkinter with underscore t, it has been renamed in Python 3.

Setup the window

Start tk and create a window.

root = Tk()
app = Window(root)

The window class is not standard, we create a Window. This class in itself is pretty basic.

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

Then set the window title and show the window:

# set window title
root.wm_title("Tkinter window")

# show window
root.mainloop()

tkinter window

Tkinter window example

The program below shows an empty tkinter window.
Run with the program below:

from tkinter import *

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

# initialize tkinter
root = Tk()
app = Window(root)

# set window title
root.wm_title("Tkinter window")

# show window
root.mainloop()

Download Tkinter examples