pycocoa.menus.Item

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__`

Properties
| action Get the item's `action` (`str` or Python `callable`).
| allowsKeyWhenHidden Get the item's `allowsKeysWhenHidden` 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 a `submenu` (`bool`).
| indentationLevel Get the item's `indentation` (`int`).
| isAlternate Get the item's `Alternate` property (`bool`).
| isEnabled Get the item's `Enabled` property (`bool`).
| isHidden Get the item's `Hidden` property (`bool`).
| isHighlighted Get the item's `isHighlighted` property (`bool`).
| key Get the item's shortcut `key` (`str`).
| keyEquivalent Get the ObjC item's shortcut `keyEquivalent` (`str`).
| keyEquivalentModifiers Get the item's shortcut key `modifiers` (`dict`), see `Item.__init__`.
| keyModifiers Get the item's shortcut key `modifiers` (`dict`), see `Item.__init__`.
| nsTarget Get the item's target (`NS...`) or `None` for the default target, `_NSApplicationDelegate`.
| shift Get the `shift` key modifier (`bool`).
| state Get the item's `state` (`int`).
| subMenu Get the item's `submenu` (`Menu`) or `None`.
| tag Get the Item tag (`int`) or `None`.
| toolTip Get the item's `toolTip` (`str`) or `''`.
Inherited from `_Item_Type2`: `isSeparator`, `parent` Inherited from `bases._Type2`: `title` Inherited from `bases._Type1`: `NSdelegate`, `app` Inherited from `bases._Type0`: `NS`, `NSDelegate`, `typename` 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` - The item's title (`str`). `action` - Callback name (`str` ending with ':' or '_'), a Python `callable`, an ObjC `selector` (`SEL_t`) or `None`, see Notes. `key` - The shortcut key, if any (`str`, `bytes` or a Keys). `alt` - Hold `alt` or `option` key down with key (bool). `cmd` - Hold `command` key down with key (bool). `cntl` - Hold `control` key down with key (bool). `shift` - Hold `shift` key down with key (bool). `props` - Additional, settable Item property=value pairs. Raises: `TypeError` - Invalid action or invalid Python `callable` action or `callable` signature, see Notes. `ValueError` - Invalid action or invalid title for `None` action. Overrides: object.__init__ Notes: A `None` action is set to the method name `menu<title>_`, see function title2action. A Python `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 item's `action` (`str` or Python `callable`). Get Method: action(self) - Get the item's `action` (`str` or Python `callable`). Set Method: action(self, action) - Set the item's `action` (`str` or Python `callable`), see `Item.__init__` Notes.

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

### alt Get the `alt` or `option` key modifier (`bool`). Get Method: alt(self) - Get the `alt` or `option` key modifier (`bool`). Set Method: Read_Only(inst, value) - Throws an `AttributeError`, always.

### cmd Get the `command` key modifier (`bool`). Get Method: cmd(self) - Get the `command` key modifier (`bool`). Set Method: Read_Only(inst, value) - Throws an `AttributeError`, always.

### ctrl Get the `control` key modifier (`bool`). Get Method: ctrl(self) - Get the `control` key modifier (`bool`). Set Method: Read_Only(inst, value) - Throws an `AttributeError`, always.

### 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 a `submenu` (`bool`). Get Method: hasSubmenu(self) - Has this item a `submenu` (`bool`). Set Method: Read_Only(inst, value) - Throws an `AttributeError`, always.

### 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 `Alternate` property (`bool`). Get Method: isAlternate(self) - Get the item's `Alternate` property (`bool`). Set Method: isAlternate(self, alternate) - Set the item's `Alternate` 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 `isHighlighted` property (`bool`). Get Method: isHighlighted(self) - Get the item's `isHighlighted` property (`bool`). Set Method: Read_Only(inst, value) - Throws an `AttributeError`, always.

### 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` and {keyEquivalent} (`str`).

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

### keyEquivalentModifiers Get the item's shortcut key `modifiers` (`dict`), see `Item.__init__`. Get Method: keyModifiers(self) - Get the item's shortcut key `modifiers` (`dict`), see `Item.__init__`.

### keyModifiers Get the item's shortcut key `modifiers` (`dict`), see `Item.__init__`. Get Method: keyModifiers(self) - Get the item's shortcut key `modifiers` (`dict`), see `Item.__init__`. Set Method: keyModifiers(self, modifiers) - Set the item's shortcut key `modifiers` (`dict`), see `Item.__init__`.

### 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: Read_Only(inst, value) - Throws an `AttributeError`, always.

### shift Get the `shift` key modifier (`bool`). Get Method: shift(self) - Get the `shift` key modifier (`bool`). Set Method: Read_Only(inst, value) - Throws an `AttributeError`, always.

### 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).

### tag Get the Item tag (`int`) or `None`. Get Method: tag(self) - Get the Item tag (`int`) or `None`. Set Method: tag(self, tag) - Set the Item tag (`int`).

### 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`).