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
?
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.
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.
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.
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 *
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With