Tkinter in Python

By | April 6, 2020

In this tutorial, we will learnĀ Tkinter in Python. Tkinter is a library which allows us to create Graphical User Interface. We can create desktop-based applications with the help of Tkinter. In this Tkinter tutorial series, we will learn various widgets in Tkinter along with Example programs.

Steps to use Tkinter in your Application:

  • Import Tkinter in your program
  • Create the main application window.
  • Add the widgets like in your main application window
  • Add actions to different widgets in your applications

Example Program of Tkinter in Python:

#importing tkinter lib
from tkinter import *  
#creating the main window.   
mainWindow = Tk()  
#event main loop  
mainWindow.mainloop()  

Output:

Tkinter in Python

Widgets in Tkinter:

WidgetDescription
ButtonThis widget is used to add button in Python application.
CanvasThis widget is used to make a canvas in Python application.
Check ButtonThis widget is used to show options with checkboxes in python application.
EntryThis widget is used to get a single line entry from the user.
LabelThis widget is used to show caption with other widgets.
FrameThis widget is used for grouping of other Tkinter Widgets.
ListBoxThis widget helps up to show list of items in application.
MenuButtonThis widget used to show the drop-down menu.
MenuThis widget helps us to add a menu in the application.
MessagePython Tkinter Message works same as Lable expect it can automatically wrap up text.
RadioButtonThis widget is used to show multiple options to the user.
ScaleTkinter Scale widget is used to the graphical slider.
ScrollBarScrollBar widget is used to make the content of other widgets scroll-able.
TextThe Tkinter Text widget is used to show multi-line text in the application