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

Class Item

  object --+                
           |                
bases._Type0 --+            
               |            
    bases._Type1 --+        
                   |        
        bases._Type2 --+    
                       |    
             _Item_Type2 --+
                           |
                          Item

Python menu Item Type, wrapping ObjC NSMenuItem.

Instance Methods
 
__init__(self, title, action=None, key='', alt=False, cmd=True, ctrl=False, shift=False, **props)
New menu Item.
 
__str__(self)
str(x)

Inherited from bases._Type0: __repr__, type2strepr

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

Class Variables
  _SEL_ = <SEL_t(handleMenuItem:)>
Properties
  action
Get the action name (str).
  allowsKeyWhenHidden
Get the item's allows property (bool).
  alt
Get the alt or option key modifier (bool).
  cmd
Get the command key modifier (bool).
  ctrl
Get the control key modifier (bool).
  font
Get the item's font (Font) or None.
  hasSubmenu
Has this item's a submenu (bool).
  indentationLevel
Get the item's indentation (int).
  isAlternate
Get the item's Altenate property (bool).
  isEnabled
Get the item's Enabled property (bool).
  isHidden
Get the item's Hidden property (bool).
  isHighlighted
Get the item's Highlighted property (bool).
  keyEquivalent
Get the item's shortcut key (str).
  key
Get the item's shortcut key (str).
  keyEquivalentModifiers
Get the item's shortcut key modifiers (dict).
  keyModifiers
Get the item's shortcut key modifiers (dict).
  nsTarget
Get the item's target (NS...) or None for the default target, _NSApplicationDelegate.
  parent
Get a submenu item's parent item (Item) or None.
  shift
Get the shift key modifier (bool).
  state
Get the item's state (int).
  subMenu
Get the item's submenu (Menu) or None.
  toolTip
Get the item's toolTip (str) or ''.

Inherited from _Item_Type2: isSeparator, nsMenu

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, action=None, key='', alt=False, cmd=True, ctrl=False, shift=False, **props)
(Constructor)

 

New menu Item.

Parameters:
  • title - Item title (str).
  • action - Callback method (str ending with ':' or _', callable or SEL_t) or None, see note.
  • key - The shortcut key, if any (str or bytes).
  • alt - Hold alt or option down with key (bool).
  • cmd - Hold command down with key (bool).
  • cntl - Hold control down with key (bool).
  • shift - Hold shift down with key (bool).
  • props - Optional, settable Item property=value pairs.
Raises:
  • TypeError - Callable action not a method or function.
  • ValueError - Invalid action or title for None action.
Overrides: object.__init__

Note: A None action is set to the menu.<title> with spaces and dots removed, see function title2action. A callable action must be a (bound) Python method with signature (self, item, ...) or a Python function with signature (item, ...).

__str__(self)
(Informal representation operator)

 

str(x)

Overrides: object.__str__
(inherited documentation)

Property Details

action

Get the action name (str).

Get Method:
action(self) - Get the action name (str).

allowsKeyWhenHidden

Get the item's allows property (bool).

Get Method:
allowsKeyWhenHidden(self) - Get the item's allows property (bool).
Set Method:
allowsKeyWhenHidden(self, allows) - Set the item's allows property (bool).

alt

Get the alt or option key modifier (bool).

Get Method:
alt(self) - Get the alt or option key modifier (bool).

cmd

Get the command key modifier (bool).

Get Method:
cmd(self) - Get the command key modifier (bool).

ctrl

Get the control key modifier (bool).

Get Method:
ctrl(self) - Get the control key modifier (bool).

font

Get the item's font (Font) or None.

Get Method:
font(self) - Get the item's font (Font) or None.
Set Method:
font(self, font) - Set the item's font (Font).

hasSubmenu

Has this item's a submenu (bool).

Get Method:
hasSubmenu(self) - Has this item's a submenu (bool).

indentationLevel

Get the item's indentation (int).

Get Method:
indentationLevel(self) - Get the item's indentation (int).
Set Method:
indentationLevel(self, indent) - Set the item's indentation (int).

isAlternate

Get the item's Altenate property (bool).

Get Method:
isAlternate(self) - Get the item's Altenate property (bool).
Set Method:
isAlternate(self, alternate) - Set the item's Altenate property (bool).

isEnabled

Get the item's Enabled property (bool).

Get Method:
isEnabled(self) - Get the item's Enabled property (bool).
Set Method:
isEnabled(self, enable) - Set the item's Enabled property (bool).

isHidden

Get the item's Hidden property (bool).

Get Method:
isHidden(self) - Get the item's Hidden property (bool).
Set Method:
isHidden(self, hidden) - Set the item's Hidden property (bool).

isHighlighted

Get the item's Highlighted property (bool).

Get Method:
isHighlighted(self) - Get the item's Highlighted property (bool).

keyEquivalent

Get the item's shortcut key (str).

Get Method:
key(self) - Get the item's shortcut key (str).

key

Get the item's shortcut key (str).

Get Method:
key(self) - Get the item's shortcut key (str).
Set Method:
key(self, key) - Set the item's shortcut key (str).

keyEquivalentModifiers

Get the item's shortcut key modifiers (dict).

Get Method:
keyModifiers(self) - Get the item's shortcut key modifiers (dict).

keyModifiers

Get the item's shortcut key modifiers (dict).

Get Method:
keyModifiers(self) - Get the item's shortcut key modifiers (dict).
Set Method:
keyModifiers(self, modifiers) - Get/set the item's shortcut key modifiers (dict).

nsTarget

Get the item's target (NS...) or None for the default target, _NSApplicationDelegate.

Get Method:
nsTarget(self) - Get the item's target (NS...) or None for the default target, _NSApplicationDelegate.
Set Method:
nsTarget(self, ns_target) - Set the item's target (NS...).

parent

Get a submenu item's parent item (Item) or None.

Get Method:
parent(self) - Get a submenu item's parent item (Item) or None.

shift

Get the shift key modifier (bool).

Get Method:
shift(self) - Get the shift key modifier (bool).

state

Get the item's state (int).

Get Method:
state(self) - Get the item's state (int).
Set Method:
state(self, state) - Set the item's state (int).

subMenu

Get the item's submenu (Menu) or None.

Get Method:
subMenu(self) - Get the item's submenu (Menu) or None.
Set Method:
subMenu(self, submenu) - Set the item's submenu (Menu).

toolTip

Get the item's toolTip (str) or ''.

Get Method:
toolTip(self) - Get the item's toolTip (str) or ''.
Set Method:
toolTip(self, tip) - Set the item's toolTip (str).