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

Class Menu

  object --+            
           |            
bases._Type0 --+        
               |        
    bases._Type1 --+    
                   |    
        bases._Type2 --+
                       |
                      Menu

Python Menu Type, wrapping ObjC NSMenu.

Instance Methods
 
__init__(self, title)
New Menu.
 
__len__(self)
 
append(self, *items)
Add one or more items or separators to this menu.
 
__getitem__(self, index)
Yield an or several items by index, by slice or by title.
 
item(self, title='', action='', dflt=missing())
Find an item by title or by action.
 
items(self, separators=False)
Yield the items in this menu.

Inherited from bases._Type2: __str__

Inherited from bases._Type0: __repr__, type2strepr

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Properties

Inherited from bases._Type2: tag, title

Inherited from bases._Type1: NSdelegate, app

Inherited from bases._Type0: NS, NSDelegate

Inherited from object: __class__

Method Details

__init__(self, title)
(Constructor)

 

New Menu.

Parameters:
  • title - The menu title (str).
Overrides: object.__init__

append(self, *items)

 

Add one or more items or separators to this menu.

Parameters:

__getitem__(self, index)
(Indexing operator)

 

Yield an or several items by index, by slice or by title.

Parameters:
  • index - Index (int, str or slice).
Returns:
Each item (Item or ItemSeparator).
Raises:
  • IndexError - If index out of range or if no item titled index exists.

item(self, title='', action='', dflt=missing())

 

Find an item by title or by action.

Parameters:
  • title - Item title to match (str).
  • action - Item action to match (str).
  • dflt - Optional, default return value.
Returns:
The first matching item (Item) or dflt if no title or action match found.
Raises:
  • ValueError - No dflt provided and no title or action match.

items(self, separators=False)

 

Yield the items in this menu.

Parameters:
Returns:
Each Item or ItemSeparator.