[Pythonmac-SIG] Tkinter/Mac newbie query

Kevin Walzer kw at codebykevin.com
Tue Sep 11 23:12:51 CEST 2012


On 9/11/12 12:53 PM, William R. Wing (Bill Wing) wrote:
> Mac OSX 10.8.1, 2 x quad processor Intel MacPro, Python 2.7.3 from python.org.
>
> I've been programming in python for a couple of years (off and on), and I'm getting more and more comfortable with it.
> I'd like to start putting GUIs in front of some of my code, and have been looking at wx, Tkinter, and PyQt.
>
> Everything I read says that starting with Tkinter version 8.2 (or something like that) it is "themed" and Tkinter applications should look native on the various platforms.  The version of Tkinter I have is 8.5, but when I code up some of the Tkinter demos, they all come out looking more like X11 applications than like native Mac apps.
>
> I assume the problem is because I'm not doing SOMETHING right in the initialization, but I'm scratching my head over what.

The themed widgets use the ttk prefix, so you'll need to include an 
"import ttk" statement early on, and then (to avoid collisions with the 
standard Tk widgets) I suggest using dot notation, cf. ttk.Button.

Also, remember that the ttk widgets are not drop-in replacements for the 
traditional Tk widgets; they have a similar API, but they are not 
identicial (cf. you can't set the foreground for them without creating 
an entirely custom stule;  they pick up platform defaults much better, 
though).

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com


More information about the Pythonmac-SIG mailing list