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

Class MenuBar

          object --+                    
                   |                    
internals._Objectype --+                
                       |                
        baseTypes._Type0 --+            
                           |            
            baseTypes._Type1 --+        
                               |        
                baseTypes._Type2 --+    
                                   |    
                         _Menu_Type2 --+
                                       |
                                      MenuBar

Python MenuBar Type, wrapping ObjC NSMenu.

Instance Methods
 
__init__(self, app=None)
New MenuBar.
 
append(self, *menus)
Add one or more sub-menus to this menu bar.
 
find(self, menu)
Return the index of a menu in this menu bar.
 
__getitem__(self, index)
Return the menu at index or with title or several by slice.
 
highlight(self, menu)
Highlight a menu.
 
index(self, menu)
Return the index of a menu in this menu bar.
 
insert(self, index, *menus)
Insert one or more menus into this menu bar.
 
main(self, app=None)
Make this menu bar the app's main menu.
 
menu(self, title='', dflt=missing)
Find a menu by title.
 
menus(self)
Yield the menus of this menu bar.
 
pop(self, index=-1)
Remove a menu by index.
 
remove(self, *menus)
Remove one or several menus from this menu bar.

Inherited from _Menu_Type2: __contains__, __len__, removeAll

Inherited from baseTypes._Type2: __str__

Inherited from baseTypes._Type0: __repr__, type2strepr

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

Properties
  height
Get this menu bar's height (float).
  highlightedMenu
Get the menu's highlightedMenu property (Menu or None).
  isVisible
Get the menu bar's menuBarVisible property (bool).
  tag
Get the MenuBar tag (None always).

Inherited from _Menu_Type2: action, autoEnables, isAttached, isTornOff, minWidth, parent, showsState, size, tags

Inherited from baseTypes._Type2: title

Inherited from baseTypes._Type1: NSdelegate, app

Inherited from baseTypes._Type0: NS, NSDelegate

Inherited from internals._Objectype: typename

Inherited from object: __class__

Method Details

__init__(self, app=None)
(Constructor)

 

New MenuBar.

Parameters:
  • app - The application (App or None).
Raises:
  • TypeError - If app not an App.
Overrides: object.__init__

See Also: Method MenuBar.main.

append(self, *menus)

 

Add one or more sub-menus to this menu bar.

Parameters:
  • menus - The menus to add (Menu).

find(self, menu)

 

Return the index of a menu in this menu bar.

Parameters:
  • menu - The menu to locate (Menu).
Returns:
The index (int) or -1 if not found.

__getitem__(self, index)
(Indexing operator)

 

Return the menu at index or with title or several by slice.

Parameters:
  • index - The index (int, str or slice).
Returns:
The menu (Menu) or menus.
Raises:
  • IndexError - If index out of range or if no menu titled index exists.

highlight(self, menu)

 

Highlight a menu.

Parameters:
  • menu - The menu to hightlight (Menu).
Raises:
  • ValueError - No menu in this menu bar.

index(self, menu)

 

Return the index of a menu in this menu bar.

Parameters:
  • menu - The menu to locate (Menu).
Returns:
The index (int).
Raises:
  • ValueError - If menu not found.

insert(self, index, *menus)

 

Insert one or more menus into this menu bar.

Parameters:
  • index - Insert menus before this index (int).
  • menus - The menus (Menu) to insert.
Raises:
  • IndexError - If index out of range.
  • TypeError - If index not int or a menu not Menu.

main(self, app=None)

 

Make this menu bar the app's main menu.

Parameters:
  • app - The application (App or None).
Raises:
  • TypeError - If app not an App.
  • ValueError - If app missing.

menu(self, title='', dflt=missing)

 

Find a menu by title.

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

menus(self)

 

Yield the menus of this menu bar.

Returns:
Each menu (Menu).

pop(self, index=-1)

 

Remove a menu by index.

Parameters:
  • index - The menu's index (int) or default, the last menu.
Returns:
The removed menu (Menu).
Raises:
  • IndexError - Invalid index.
  • TypeError - Invalid index.

remove(self, *menus)

 

Remove one or several menus from this menu bar.

Parameters:
  • menus - The menus to remove (Menu).
Raises:
  • TypeError - Invalid menu.
  • ValueError - If menu not present.

Property Details

height

Get this menu bar's height (float).

Get Method:
height(self) - Get this menu bar's height (float).
Set Method:
Read_Only(inst, value) - Throws an AttributeError, always.

highlightedMenu

Get the menu's highlightedMenu property (Menu or None).

Get Method:
highlightedMenu(self) - Get the menu's highlightedMenu property (Menu or None).
Set Method:
Read_Only(inst, value) - Throws an AttributeError, always.

isVisible

Get the menu bar's menuBarVisible property (bool).

Get Method:
isVisible(self) - Get the menu bar's menuBarVisible property (bool).
Set Method:
isVisible(self, visible) - Set the menu bar's menuBarVisible property (bool).

tag

Get the MenuBar tag (None always).

Get Method:
tag(self) - Get the MenuBar tag (None always).
Set Method:
Read_Only(inst, value) - Throws an AttributeError, always.