how to import tkinter in python

how to import tkinter in python


Tkinter module is the most used, beginner-friendly and well-documented module for making GUIs in python. Tkinter comes preinstalled with Python so you don't need to install or configure anything.


There are actually two ways of importing Tkinter in python


1. Import Everything from Tkinter

from tkinter import *

 

2. Import only modules which you are going to use actually

from tkinter import Tk, Frame



Example No 1 Import Everything ( * )

from tkinter import *

root = Tk()

root.mainloop()

which creates a simple window


Example No 2 Import what you need

from tkinter import Tk

root = Tk() 

root.mainloop()

which imports only window class or module in this case


Previous Post Next Post