Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I use ttk in Python?

When I type from Tkinter import ttk it says that there is no module named ttk, and also on many websites online the t in tkinter is always lowercase, but when I type tkinter in Python it throws an error. Why is that?

like image 560
G.SINGH Avatar asked Jun 20 '10 20:06

G.SINGH


2 Answers

There is nothing wrong with the case. As other answer specified - its Tkinter in Python 2.x and tkinter in Python 3.x version.

In addition ttk was a separate module in Python 2.x and its a submodule of Tkinter in Python 3.x

So in Python 2.x you would import ttk as

from Tkinter import *
import ttk

And in Python 3.x you would import ttk as

from tkinter import *
from tkinter.ttk import *

or

from tkinter import ttk
like image 96
bhaskarc Avatar answered Oct 06 '22 05:10

bhaskarc


Tkinter in python 2.6 is capitalized, in python 3 it is lowercase, tkinter

like image 45
pygabriel Avatar answered Oct 06 '22 04:10

pygabriel