What does calling Tk() actually do?

Tkinter is a Python package which comes with many functions and methods that can be used to create an application. In order to create a tkinter application, we generally create an instance of tkinter frame, i.e., Tk(). It helps to display the root window and manages all the other components of the tkinter application. We can initialize the tkinter instance by assigning the variable to it.


In the following example, we will create an instance of tkinter frame and create a label widget.

#Import tkinter library
from tkinter import *
#Create an instance of tkinter frame or window
win= Tk()
#Set the geometry of tkinter frame
#Create a Label widget
label= Label(win, text="Open Source Learning is Awesome!", font= ('Courier 20 underline'))