Package pycocoa :: Module menus
[frames] | no frames]

Module menus

Types Item, ItemSeparator, Menu and MenuBar, wrapping ObjC NSMenuItem and NSMenu.


Version: 18.08.16

Classes
  Item
Python menu Item Type, wrapping ObjC NSMenuItem.
  ItemSeparator
Python menu ItemSeparator Type, wrapping ObjC NSMenuItem.separatorItem.
  Menu
Python Menu Type, wrapping ObjC NSMenu.
  MenuBar
Python MenuBar Type, wrapping ObjC NSMenu.
Functions
 
ns2Item(ns)
Get the Python instance for an NSMenuItem.
 
title2action(title)
Convert a menu item title to a Python callback method name.
Function Details

ns2Item(ns)

 

Get the Python instance for an NSMenuItem.

Parameters:
  • ns - The ObjC instance (NSMenuItem).
Returns:
The instance (Item or Menu).
Raises:
  • TypeError - Invalid ns type.

Note: A Menu instance is returned if ns was an intermediate NSMenuItem, created internally to append or insert a Menu to a MenuBar.

title2action(title)

 

Convert a menu item title to a Python callback method name.

Parameters:
  • title - The item's title (str).
Returns:
Name for the Python callback method (str), menutitle_ with all non-alphanumeric characters except colon and underscore removed from the title.
Raises:
  • ValueError - If title can not be converted.