Hi everybody.
How can i install ttk module on linux?
When i try to import and use it on my Tkinter window, the error says sth like there is no module named ttk. So it means i should install it right?! I'm using python 2. I want to use ttk to make buttons more nicely.

In python 2 in kubuntu, I can import it directly

import ttk

In python 3 it is

from tkinter import ttk

ttk.py should be in the folder lib-tk in your python2 library. Try to run

locate ttk

in a terminal to see where it is.

This is a simple example:

from Tkinter import ttk

window = Ttk()
button = ttk.Button(window, text='hi')

Ande the error:

Traceback (most recent call last):
  File "ttk.py", line 1, in <module>
    from Tkinter import ttk
ImportError: cannot import name ttk

Simply cover both Python2 and Python3:

    # Python2
    import Tkinter as tk
    import ttk
except ImportError:
    # Python3
    import tkinter as tk
    import tkinter.ttk as ttk

window = tk.Tk()
button = ttk.Button(window, text='hi')
This question has already been answered. Start a new discussion instead.