Difference between tkinter and Tkinter Difference between tkinter and Tkinter tkinter tkinter

Difference between tkinter and Tkinter


It's simple.

For python2 it is:

from Tkinter import *

For python3 it is:

from tkinter import *

Here's the way how can you forget about this confusion once and for all:

try:    from Tkinter import *except ImportError:    from tkinter import *


Tkinter is Python 2.x's name for the Tkinter library. In Python 3.x however, the name was changed to tkinter. To avoid running into this problem, I usually do this:

from sys import version_infoif version_info.major == 2:    # We are using Python 2.x    import Tkinter as tkelif version_info.major == 3:    # We are using Python 3.x    import tkinter as tk


The capitalization of Tkinter and tkinter widget, method and option names is significantly different across the board. In some cases, the names themselves are different. Some features of Tkinter do not exist in tkinter, and vice-versa. But, as already stated, the main difference is that Tkinter is a module in Python 2x while tkinter is a module in Python 3x.