Page 17 - Phyton_GUIprogrammingwithTkinter
P. 17
P a ge | 8
2.4 Widgets in Tkinter
Tkinter is the most popular way to create Graphical User Interfaces (GUIs) in
Python. For building GUIs, Tkinter provides developers with a set of widgets.
In general, Widget is an element of Graphical User Interface (GUI) that
displays/illustrates information or gives a way for the user to interact with the OS. In
Tkinter, Widgets are objects; instances of classes that represent buttons, frames, and
so on.
The Tk widget exposes various window properties, such as the text within the
top bar of the application, the size of the application, its position on screen, whether
it can be resized, and even the icon which appears in the top right-hand corner (on
Windows only) (David, 2018).
Each separate widget is a Python object. When creating a widget, you must
pass its parent as a parameter to the widget creation function. The only exception is
the “root” window, which is the top-level window that will contain everything else,
and it does not have a parent. The list of python widgets is based on the Table 2.2
below.
Table 2.2: Python Widgets
Widget Description
Label Display text or messages
Button Used in toolbars, application windows, pop-up windows, and
dialogue boxes
Checkbutton Used to implement on-off selections.
Entry Widget Used to enter or display a single line of text
Scale widget Used instead of an Entry widget when you want the user to
input a bounded numerical value.
List box Used to display a list of alternatives.
Radiobutton Used to offer many possible selections to the user but lets the
(alternate) user choose only one of them.
Text Widget Used where a user wants to insert multiline text fields.
Canvas Rectangular area intended for drawing pictures or other
complex layouts. You can place graphics, text, widgets, or
frames on a Canvas.
LabelFrame A simple container widget and act as a spacer or container for
complex window layout.