Difference between tkinter and Tkinter

The main difference between Tkinter and tkinter is the Python version compatibility. Tkinter (capital T) was used in Python 2, while tkinter (lowercase t) is used in Python 3 and later versions.

Python 2 vs Python 3 Import Syntax

In Python 2, the tkinter module was named with a capital T ?

from Tkinter import *

In Python 3 and later, the module name uses lowercase ?

from tkinter import *

Example: Python 3 Error with Capital T

If you try to use the old Python 2 syntax in Python 3, you'll get an error ?

# This will cause an error in Python 3
from Tkinter import *

win = Tk()
win.geometry("650x200")
win.mainloop()
ModuleNotFoundError: No module named 'Tkinter'

Correct Python 3 Example

Here's the proper way to import and use tkinter in Python 3 ?

# Correct import for Python 3
from tkinter import *

# Create an instance of tkinter window
win = Tk()
win.geometry("400x200")
win.title("Python 3 Tkinter Example")

# Add a simple label
label = Label(win, text="Hello, Tkinter!", font=("Arial", 16))
label.pack(pady=50)

win.mainloop()

Alternative Import Methods

You can also import tkinter using these methods ?

# Method 1: Import as alias
import tkinter as tk

root = tk.Tk()
root.title("Using tk alias")
root.geometry("300x150")
root.mainloop()
# Method 2: Import specific components
from tkinter import Tk, Label, Button

window = Tk()
window.title("Specific imports")
label = Label(window, text="Specific Import Example")
label.pack()
window.mainloop()

Cross-Version Compatibility

For code that needs to work with both Python 2 and 3, use a try-except block ?

try:
    # Python 2
    from Tkinter import *
except ImportError:
    # Python 3
    from tkinter import *

# Rest of your code works with both versions
root = Tk()
root.title("Cross-compatible")
root.mainloop()

Key Differences Summary

Aspect Python 2 Python 3
Module Name Tkinter tkinter
Import Statement from Tkinter import * from tkinter import *
Case Sensitivity Capital T Lowercase t

Conclusion

The difference between Tkinter and tkinter is simply the Python version: use Tkinter for Python 2 and tkinter for Python 3. Always use lowercase tkinter for modern Python development.

Updated on: 2026-03-25T18:31:01+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements