Hi Everyone.

I want to use this thread for some help as i'm sure this will not be the only question as i have just over 300 lines of code from my old python 3.1 script. I'm now using 2.6.4 and it is obvious some code isn't backwards compatible.

Soooo .. i kept getting this error from a line of code saying

"import tkinter.ttk as ttk"

which i understand from some searching is a unique time saving shortcut built into 3.1 but i can't find what the command for 2.6.4 is?

Help appreciated
Thankyou

Tkinter has change import name in python 3.
Put this first then tkinter import correct for python 2.x and 3.x

try:
    # for Python2
    import Tkinter as tk   
except ImportError:
    # for Python3
    import tkinter as tk

Edited 7 Years Ago by snippsat: n/a

Here is the story:

In Python2 Tkinter is a Python module file named Tkinter.py a wrapper for the TCL code Tkinter is written in.

With the advent of Python3 Tkinter became a more modern package called tkinter. Python version 3.1 started to include a wrapper for the Tkinter Tile Expansion ttk also written in TCL.

I don't think the ttk wrapper is included with any Python2 version.

It isn't vegaseat. Aiban, this means you will probably need to change the code or install ttk

For the time being to get a working program i have commented out the lines where errord appeared and the function of the program is intact.

This question has already been answered. Start a new discussion instead.