[Pythonmac-SIG] Dock menu

Dethe Elza delza at livingcode.org
Wed Sep 14 18:42:43 CEST 2005


Hi Simon,

You can certainly add items to a dock menu in OS X using Python.  For  
more info on the dock menu, see here:

http://developer.apple.com/documentation/Carbon/Conceptual/ 
customizing_docktile/index.html?http://developer.apple.com/ 
documentation/Carbon/Conceptual/customizing_docktile/concepts/ 
chapter_2_section_3.html

If you are just starting out with OS X, check out the PyObjC website,  
to learn how to map the Objective-C calls documented by Apple into  
Python calls.

http://pyobjc.sourceforge.net/

Note that doc menus are only active while an application is running.   
If you want a menu which is persistent without needing the UI of an  
application, take a look at the Apple docs for NSStatusBar, which is  
the area in the menu bar between an application's Help menu and the  
Spotlight icon (in Tiger, anyway).  I posted a simplistic example to  
this list a while back.

http://developer.apple.com/documentation/Cocoa/Reference/ 
ApplicationKit/ObjC_classic/Classes/NSStatusBar.html
http://mail.python.org/pipermail/pythonmac-sig/2005-April/013733.html

Apple itself doesn't use NSStatusItem, relying instead on something  
called Menu Extras, which are more reliable and powerful (they can be  
rearranged by dragging, for instance).  Apple doesn't want third  
party developers to use this API (which is undocumented and has been  
known to change between releases), but if you'd like to try anyway,  
there is documentation here:

http://cocoadevcentral.com/articles/000078.php

Best wishes!

--Dethe

When laws are outlawed, only outlaws will have laws.




More information about the Pythonmac-SIG mailing list