[Pythonmac-SIG] cross platform GUI?

Jon Moody jbmoody@oakland.edu
Fri, 1 Jun 2001 07:22:03 -0400


On Thu, May 31, 2001 at 04:00:03PM -0700, Russell E Owen wrote:
> - I haven't been able to get menus to work reliably (under Tk or 
> Tkinter), so I stick with the default ones. I'd love to know if 
> anyone else has this problem or it's just me.

I spent (wasted) some time on this; adding menus (using Pmw) worked
fine, but adding items to the standard `About' (apple) and `Help'
menus didn't.  

The only way `About'/`Help' worked for me is if I called Tk directly
with Tkinter's tk.call() method which looks hideous but works.  (This
was using a Pmw.MainMenuBar object, but the same thing should work
using Tkinter.Menu directly):

# create an `About ...' apple menu and an entry in `Help' menu
self.menuBar = self.createcomponent('menubar', (), None,
	Pmw.MainMenuBar, (self._hull,), hull_relief=RAISED,
	hull_borderwidth=1, balloon=self.balloon())
menu = self.menuBar.component('hull')  # Tkinter.Menu object
main = str(menu)
help = main + '.help'
apple = main + '.apple'
self.root.tk.call(main, 'add', 'cascade', '-menu', help)
self.root.tk.call('menu', help, '-tearoff', '0')
self.root.tk.call(main, 'add', 'cascade', '-menu', apple)
self.root.tk.call('menu', apple, '-tearoff', '0')

helpopts = {'label':'MyProgram help', 'command':self.showHelp}
appleopts = {'label':'About MyProgram . . .', 'command':self.showAbout}

apply(self.root.tk.call, (help, 'add', 'command') + 
	menu._options(helpopts))
apply(self.root.tk.call, (apple, 'add', 'command')+
	menu._options(appleopts)) 




--
Jon