Op Wednesday 20 May 2015 19:03 CEST schreef Zachary Ware: > On Wed, May 20, 2015 at 11:01 AM, Cecil Westerhof <ce...@decebal.nl> 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? > > The way I would do it is as follows: > > try: > import tkinter as tk > from tkinter import ttk > except ImportError: > import Tkinter as tk > import ttk
When there goes something wrong with: from tkinter import ttk you will not understand what is happening. ;-) > If I may suggest, just write it in Python3 first, then when it does > what you want tack on whatever you need to make 2.7 happy. I find it > easier to do things that way, though you may find that the only > thing you have to adjust is the imports. That was what I thought (the imports), but maybe I am wrong. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof -- https://mail.python.org/mailman/listinfo/python-list