[Pythonmac-SIG] Tkinter/Mac newbie query

William R. Wing (Bill Wing) wrw at mac.com
Tue Sep 11 18:53:43 CEST 2012


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.

Does anyone have any thoughts as to what I might be doing wrong?

I've pasted a typical bit of code in below.

#!/usr/bin/env python
from Tkinter import *
class App:
    def __init__(self, master):
        frame = Frame(master)
        frame.pack()
        self.button = Button(frame, text="QUIT", fg="red", command=frame.quit)
        self.button.pack(side=LEFT)
        self.hi_there = Button(frame, text="Hello", command=self.say_hi)
        self.hi_there.pack(side=LEFT)
    def say_hi(self):
        print "hi there, everyone!"
root = Tk()
app = App(root)
root.mainloop()

And yes, the version of python I get via !usr/bin/env is the same one I get at the terminal prompt.

Thanks,
Bill

 


More information about the Pythonmac-SIG mailing list