0

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

4
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by Aiban
Featured Replies
0

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 by snippsat: n/a

0

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.

1

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

0

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.