Introduction

The GUI is an interface that presents graphical elements / widgets for the user to interact with the computer. For example, Textboxes, Buttons, Checkboxe, Sliders, etc. are graphical elements, and by interacting with them you can perform various behaviors like interacting with physical objects like radio with some buttons and knobs.

There are many GUI libraries / toolkit available depending on the platform. All main widgets are built on top level window objects. This object is created by the Tk class of Tkinter. Within this window, individual widgets or multiple components are grouped together to form a GUI.

Top Level Container

Before getting started with GUI programming, we first discuss Tkinter as Python’s default UI toolkit. Tkinter is not necessarily on by default, so we start by looking at the installation.

What are Tcl, Tk, Tkinter?

Tkinter is a standard Python interface to the Tk GUI toolkit, Python’s de facto standard GUI. It was originally based on the Tk toolkit designed for the Tool Command Language (Tcl), due to Tk’s popularity it has been ported to a variety of other scripting languages including Perl (Perl/Tk), Ruby (Ruby/Tk) and Python (Python/Tk).

Tkinter provides a powerful object-oriented interface to the Tk GUI toolkit. Creating a GUI application using Tkinter is really a simple task.

Install and run Tkinter

Tkinter is not always turned on by default. You can determine if Tkinter is available in the Python interpreter or not by importing it in your python program. If Tkinter is available no error occurs, otherwise an import error will occur.

Try to import Tkinter

import tkinter