Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between tkinter and Tkinter

When I answer Tkinter questions I usually try and run the code myself, but sometimes I get this error:

Traceback (most recent call last):   File "C:\Python27\pygame2.py", line 1, in <module>     from tkinter import * ImportError: No module named tkinter 

When I look at the question I see they import tkinter with a lower-case t:

from tkinter import * 

I always import Tkinter with a capital T:

from Tkinter import * 

Which always works for me. What is the difference between using tkinter and Tkinter?

like image 732
Serial Avatar asked Jul 24 '13 19:07

Serial


People also ask

What is the difference between tkinter and tkinter TTK?

Tkinter widgets are used to add Buttons, Labels, Text, ScrollBar, etc., however, tkinter. ttk supports a variety of widgets as compared to tkinter widgets. Tkinter. ttk doesn't support Place, Pack() and Grid(), thus it is recommended to use tkinter widget with ttk.

What is Tk () in tkinter Python?

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.

Why is it called tkinter?

The name Tkinter comes from Tk interface. Tkinter was written by Steen Lumholt and Guido van Rossum, then later revised by Fredrik Lundh. Tkinter is free software released under a Python license.


1 Answers

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 * 
like image 188
alecxe Avatar answered Oct 05 '22 21:10

alecxe