6 January, 2022
GUI stands for Graphical user interface. Unlike text based interfaces (terminals), GUI uses graphical and interactive components for the user to interact with.
The topics covered in this tutorial are:
Make sure that the following requirements are installed:
The 3 basic widgets in tkinter are:
The Label widget in tkinter can be used to display text of various sizes and styles. Here is the code to use Label widget in a window:
The major properties of a Label widget are:
Text
Background colour
Foreground colour
Font family and size
Here is the code to make a Label widget with custom properties:
The Button widget in tkinter can be used to call a command when clicked. Here is the code to use Button widget in a window:
The major properties of a Button widget are:
Text
Background colour
Foreground colour
Font
Command
Usage is the same as Label widget. Arguements can be passed.
The Entry widget in tkinter can be used to get user input graphically. The text entered in an Entry widget can be obtained by get()
method. Here is the code to use Entry widget along with Button widget in a window:
The major properties of an Entry widget are:
Background colour
Foreground colour
Font family and size
Usage is the same as Label widget. Arguements can be passed.
Other than widgets, Message boxes can be used in tkinter for basic prompts. Message boxes cannot be used without a main window. The Message boxes available in tkinter can be classified into two types based on usage:
There are three message boxes for showing information. The code below explains them.
There are two message boxes for asking questions. The code below explains them.
Simple dialogs are like Message boxes and they too require a main window to run. Unlike Message boxes, Simple dialogs are used for getting input(strings, integers and floats). The code below explains how to get input using a simpledialog.
Thank you!
Copyright © 2022 Jothin Kumar