Mark Summerfield | 15 Jun 2012 13:07

a couple of mac menu problems

Hi,

I'm trying to develop a cross-platform Tkinter app.

Here's a bit of code used to create the Help menu:

    if MAC:
	self.master.createcommand("tkAboutDialog", self.about_action)
	self.master.createcommand("::tk::mac::ShowHelp",
		self.help_action)
    helpMenu = tk.Menu(self.menubar, name="help")
    helpMenu.add_command(label="Help", underline=0,
	    command=self.help_action)
    if not MAC:
	helpMenu.add_command(label="About", underline=0,
		command=self.about_action)
    self.menubar.add_cascade(label="Help", underline=0,
	    menu=helpMenu)

I end up with these menus:

    ActivePython3.2 
	About ActivePython3.2 # correctly invokes my about action
	...

    Help
	Search # some apple-specific thing that just appears
	ActivePython3.2 Help # invokes my help action
	Help                 # invokes my help action

(Continue reading)

Kevin Walzer | 15 Jun 2012 15:45
Favicon

Re: a couple of mac menu problems

Hi Mark,

Please see my answers below:

> Here's a bit of code used to create the Help menu:
>
>      if MAC:
> 	self.master.createcommand("tkAboutDialog", self.about_action)
> 	self.master.createcommand("::tk::mac::ShowHelp",
> 		self.help_action)
>      helpMenu = tk.Menu(self.menubar, name="help")
>      helpMenu.add_command(label="Help", underline=0,
> 	    command=self.help_action)
>      if not MAC:
> 	helpMenu.add_command(label="About", underline=0,
> 		command=self.about_action)
>      self.menubar.add_cascade(label="Help", underline=0,
> 	    menu=helpMenu)

There's some magic in the Tk-Cocoa help menu--if you define the 
tk::mac::showHelp command and map it to your function that calls user 
help, you don't need to add a separate entry for help. (There's already 
an entry hard-coded for help, along with the search field.) So the 
helpMenu.add_Command(label="Help")... stuff is redundant.

> I end up with these menus:
>
>      ActivePython3.2
> 	About ActivePython3.2 # correctly invokes my about action

(Continue reading)

Lynn Oliver | 15 Jun 2012 20:06
Picon

Re: a couple of mac menu problems

Along the same lines, I managed to get application/preferences to work on the Mac, but while
application/about shows the name of my Python app (built with pyinstaller), it displays the 'Tcl & Tk'
dialog.  

The TkDocs-TK Tutorial on menus shows this as a TODO item
(http://www.tkdocs.com/tutorial/menus.html).  While I was able to figure out the preferences menu by
looking at the idlelib sources, I couldn't get the application/about menu to work.

Any suggestions?

Lynn
On Jun 15, 2012, at 6:45 AM, Kevin Walzer wrote:

> Hi Mark,
> 
> Please see my answers below:
> 
> 
>> Here's a bit of code used to create the Help menu:
>> 
>>     if MAC:
>> 	self.master.createcommand("tkAboutDialog", self.about_action)
>> 	self.master.createcommand("::tk::mac::ShowHelp",
>> 		self.help_action)
>>     helpMenu = tk.Menu(self.menubar, name="help")
>>     helpMenu.add_command(label="Help", underline=0,
>> 	    command=self.help_action)
>>     if not MAC:
>> 	helpMenu.add_command(label="About", underline=0,
>> 		command=self.about_action)
(Continue reading)

Kevin Walzer | 15 Jun 2012 20:32
Favicon

Re: a couple of mac menu problems

What version of OS X?

Sent from my iPhone

On Jun 15, 2012, at 2:06 PM, Lynn Oliver <raycores <at> gmail.com> wrote:

> Along the same lines, I managed to get application/preferences to work on the Mac, but while
application/about shows the name of my Python app (built with pyinstaller), it displays the 'Tcl & Tk'
dialog.  
> 
> The TkDocs-TK Tutorial on menus shows this as a TODO item
(http://www.tkdocs.com/tutorial/menus.html).  While I was able to figure out the preferences menu by
looking at the idlelib sources, I couldn't get the application/about menu to work.
> 
> Any suggestions?
> 
> Lynn
> On Jun 15, 2012, at 6:45 AM, Kevin Walzer wrote:
> 
>> Hi Mark,
>> 
>> Please see my answers below:
>> 
>> 
>>> Here's a bit of code used to create the Help menu:
>>> 
>>>    if MAC:
>>>    self.master.createcommand("tkAboutDialog", self.about_action)
>>>    self.master.createcommand("::tk::mac::ShowHelp",
>>>        self.help_action)
(Continue reading)

Lynn Oliver | 15 Jun 2012 20:53
Picon

Re: a couple of mac menu problems

I'm testing on 10.7.4, but it needs to work on 10.6 as well.

On Jun 15, 2012, at 11:32 AM, Kevin Walzer wrote:

> What version of OS X?
> 
> Sent from my iPhone
> 
> On Jun 15, 2012, at 2:06 PM, Lynn Oliver <raycores <at> gmail.com> wrote:
> 
>> Along the same lines, I managed to get application/preferences to work on the Mac, but while
application/about shows the name of my Python app (built with pyinstaller), it displays the 'Tcl & Tk'
dialog.  
>> 
>> The TkDocs-TK Tutorial on menus shows this as a TODO item
(http://www.tkdocs.com/tutorial/menus.html).  While I was able to figure out the preferences menu by
looking at the idlelib sources, I couldn't get the application/about menu to work.
>> 
>> Any suggestions?
>> 
>> Lynn
>> On Jun 15, 2012, at 6:45 AM, Kevin Walzer wrote:
>> 
>>> Hi Mark,
>>> 
>>> Please see my answers below:
>>> 
>>> 
>>>> Here's a bit of code used to create the Help menu:
>>>> 
(Continue reading)

Kevin Walzer | 15 Jun 2012 22:59
Favicon

Re: a couple of mac menu problems

On 6/15/12 2:53 PM, Lynn Oliver wrote:
> I'm testing on 10.7.4, but it needs to work on 10.6 as well.

>>> Along the same lines, I managed to get application/preferences to work on the Mac, but while
application/about shows the name of my Python app (built with pyinstaller), it displays the 'Tcl&  Tk' dialog.

What does "CFBundleName" in your info.plist file show? I've seen this 
bug on the system version of Tcl/Tk installed with Snow Leopard, but not 
more recently.

--

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
Kevin Walzer | 16 Jun 2012 03:17
Favicon

Re: a couple of mac menu problems

On 6/15/12 2:06 PM, Lynn Oliver wrote:
> While I was able to figure out the preferences menu by looking at the idlelib sources, I couldn't get the
application/about menu to work.

Here's how I get the correct application dialog in the 'about myapp" menu:

self.createcommand('tkAboutDialog', self.aboutProgram)
     #dialog for 'about program'
     def aboutProgram(self):
         self.tk.call('tk::mac::standardAboutPanel')
(You can substitute any Python bits here that you want--the key is to 
map the 'tkAboutDialog' command to some kind of Python function or method.)

--

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
Mark Summerfield | 18 Jun 2012 10:23

Re: a couple of mac menu problems

Hi Kevin,

On Fri, 15 Jun 2012 09:45:58 -0400
Kevin Walzer <kw <at> codebykevin.com> wrote:
> Hi Mark,
[snip]
> This is how I set up my help menu is one of my Python apps:
> 
> 	        self.createcommand('::tk::mac::ShowHelp', self.runHelp)
> 
>         self.helpmenu = Menu(self.mb, name='_help')
>          self.mb.add_cascade(label='Help', menu=self.helpmenu)
>          self.helpmenu.add_command(label='Phynchronicity Help', 
> command=self.runHelp)
>          self.helpmenu.add_command(label='Contact Code by Kevin', 
> command=self.getHelp)
>          self.helpmenu.add_command(label='Web Site', 
> command=self.getWebSite)
>          self.helpmenu.add_command(label='User Forum', 
> command=self.getUserForum)
>          self.helpmenu.add_command(label='Newsletter', 
> command=self.getNewsletter)
> 
> Hope this helps,

Yes, it was very helpful -- thanks!

--

-- 
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
    C++, Python, Qt, PyQt - training and consultancy
(Continue reading)


Gmane