Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'importerror:': 0.07; 'python3': 0.07; 'sys': 0.07; 'tkinter': 0.07; 'subject:2.7': 0.09; 'try:': 0.09; 'cc:addr:python-list': 0.11; '2.7': 0.14; 'happy.': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'wed,': 0.18; 'import': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'first,': 0.26; 'code:': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'easier': 0.31; 'way?': 0.31; 'another': 0.32; 'moment': 0.34; 'except': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'adjust': 0.36; 'done': 0.36; 'follows:': 0.38; 'whatever': 0.38; 'does': 0.39; 'between': 0.67; '20,': 0.68; '2015': 0.84; 'differences': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=M13QMK1ot+7VR6EebMOTatVsgRHYW3HT7fWZglPAE/A=; b=pTF195njgjF6BPC262DHTExwLYNe7Au6hhFFKFsGM0LBs+b28Vu+9s6GiUJBK998WY mcv/AgamrVQfWFD4aqbiqt6IgzguDifZv4d3KRjOtoFAwdE25Sr86MVYBdG1poHuVcWa UQ9BHHggKF+hZYyJQaDOuQXtRu9aqBf+H4kWt2C35l1HAAHllc9tpHguRaHd8BlK36V0 pFAIEaW6naD+IcG/120fvWi46Hl+dGyRKlma2CxWvoR0jsPS1qrgr1+YtOVyqmY6UuGl c5q9InetmwRLwZzLR81ER+aYOm+Z6HVquyK3+LUlrNcCLv+RNtWp8kRSghNgHdPIb1qi /j2Q== X-Received: by 10.60.101.137 with SMTP id fg9mr29541009oeb.83.1432141443470; Wed, 20 May 2015 10:04:03 -0700 (PDT) MIME-Version: 1.0 Sender: zachary.ware@gmail.com In-Reply-To: <87r3qbqlve.fsf@Equus.decebal.nl> References: <87r3qbqlve.fsf@Equus.decebal.nl> From: Zachary Ware Date: Wed, 20 May 2015 12:03:39 -0500 X-Google-Sender-Auth: C2AlSSY_svhHQrg6Ejn8__WPrsA Subject: Re: No ttk in 2.7 To: Cecil Westerhof Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1432141452 news.xs4all.nl 2955 [2001:888:2000:d::a6]:55467 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:90971 On Wed, May 20, 2015 at 11:01 AM, 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? 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 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. -- Zach