TK Inter
TK Inter
Python GUI
To develop GUI application in Python, there are multiple options in terms of python packages. The most
generally used package is tkinter.
In this Python GUI Tutorial, we will use tkinter to learn how to develop GUI applications. You may be wondering
on why we are using tkinter. The answer is quite simple. There is a large tkinter community online that can help
you, through forums and other websites.
While tkinter provides the widgets with the all the functionality and behavior aspects, there is another module
named tkinter.ttk which provides themed widget set.
import tkinter as tk
import tkinter as tk
main_window = tk.Tk()
main_window.mainloop()
Output
You can change the title of the window by using title function on the root or main window widget.
import tkinter as tk
main_window = tk.Tk()
main_window.title('Python GUI Tutorial - by TutorialKart')
main_window.mainloop()
Output
You can add widgets into the window. Also note that there are a wide variety of widgets you can use from
tkinter. In this Tkinter Tutorial, we will cover all these widgets. Following are the list of Tkinter widgets.
Button
Canvas
Checkbutton
Radiobutton
Entry
Frame
Label
Listbox
Menu
MenuButton
Message
Scale
Scrollbar
Text
TopLevel
SpinBox
PannedWindow
After creating a GUI window using Tk() and before calling the mainloop() function on the window, you can add
as many widgets as required.
gui = Tk()
# add widgets here
gui.mainloop()
where master is the window to which you would like to add this button, and you may provide different options to
the button constructor. The options available for button are:
Option Description
In this example, we will create a simple button with values provided for some of the options,
Python Program
from tkinter import *
#widgets start
#widgets end
gui.mainloop()
Output
Conclusion
In this Python Tutorial, we learned about Tkinter library and the widgets it provides to build a GUI application in
Python.
Python Programming
⊩ Python Tutorial
⊩ Install Python
⊩ Python Variables
⊩ Python Comments
Control Statements
⊩ Python If
⊩ Python If Else
Python String
Functions
⊩ Python Functions
Python Collections
⊩ Python List
⊩ Python Dictionary
Advanced
⊩ Python Multithreading
Useful Resources