Difference between tkinter and Tkinter


In order to install tkinter in a local computer, we use several commands on the basis of our OS architecture. There are two ways to import the tkinter library in our Window-based machine which are based on the Python version. Earlier, for lower versions of Python, we generally used to import the tkinter library using the following command −

from Tkinter import *

However, for Python 3 or later, we generally import the Tkinter library in the environment using the following command −

from tkinter import *

The only difference between Tkinter and tkinter is that Tkinter was initially used with Python 2 and tkinter is used for working with Python 3 or later versions.

Example

Try to run this simple code in Python 3 or higher, it will display an error message.

#Import the tkinter library
from Tkinter import *

#Create an instance of tkinter frame
win = Tk()

#Set the geometry
win.geometry("650x200")

win.mainloop()

Output

ModuleNotFoundError: No module named 'Tkinter'

Updated on: 27-Mar-2021

949 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements