No ttk in 2.7
Ned Batchelder
ned at nedbatchelder.com
Wed May 20 12:47:01 EDT 2015
On Wednesday, May 20, 2015 at 12:43:29 PM UTC-4, Ned Batchelder wrote:
> On Wednesday, May 20, 2015 at 12:35:40 PM UTC-4, Cecil Westerhof wrote:
> > I want to start playing with tkinter, but there are some differences
> > between 2 and 3. For this I use at the moment the following code:
> > import sys
> >
> > if sys.version_info[0] < 3:
> > import Tkinter as tk
> > import ttk
> > else:
> > import tkinter as tk
> > from tkinter import ttk
> > or can it better be done in another way?
>
> Are you sure you want this program to run under both 2.x and 3.x?
> That will add a layer of complexity to your project. If your
> goal is to learn how to use Tkinter, you might be better off just
> picking one version of Python, and sticking with it.
>
> Deciding what versions of Python to support is not always a simple
> decision. It should be based on a realistic assessment of who will
> be using your program, and what requirements they will have.
>
> --Ned.
Oh, and I meant to include this: if you *do* want to support both 2.x
and 3.x, the six module can make it easier. It helps smooth over
modules that have been moved. You can use this line, for example:
from six.moves import tkinter_ttk as ttk
--Ned.
More information about the Python-list
mailing list