Re: [Pythonmac-SIG] Tkinter/Mac newbie query

2012-09-11 Thread Kevin Walzer

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
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG


[Pythonmac-SIG] Tkinter/Mac newbie query

2012-09-11 Thread William R. Wing (Bill Wing)
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

 
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG