Package peppy :: Package actions :: Class SelectAction
[frames] | no frames]

Class SelectAction

      object --+    
               |    
debug.debugmixin --+
                   |
                  SelectAction
Known Subclasses:

Display a normal menu item, toolbar button, or simple keystroke command.

SelectAction is also the base class of any action (menu item, toolbar item, or keyboard command).

An important characteristic of the peppy menu system is that persistent data should be stored extrinsically to the action. Action instances are created and destroyed continually as the dynamic menu bar is updated when the user changes tabs. Any instance level variables will be lost when the user switches major modes. Instead of storing information in the action itself, reference the information in some other place that is persistent: in the major mode instance that is associated with the action, in the frame, or in class attributes of the action.

The subclass should override the action method to provide the implementation and isEnabled to return the enable/disabled (i.e. the grayed-out) state of the menu item or toolbar item.

Menu items can also be updated dynamically by mixing in the OnDemandActionMixin class, or using the OnDemandGlobalListAction class.

Instance Methods
 
__call__(self, evt, number=1)
 
__init__(self, frame, menu=None, toolbar=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
 
action(self, index=-1, multiplier=1)
Override this to provide the functionality of the action.
 
getMenuItemName(self)
 
getSubIds(self)
 
getTooltip(self, id=None, name=None)
 
initPostHook(self)
 
initPreHook(self)
 
insertIntoMenu(self, menu)
 
insertIntoToolbar(self, toolbar)
 
isEnabled(self)
Override this to provide the enable/disable state of the item.
 
showEnable(self)

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Methods
 
getHelp(cls)
 
setAcceleratorText(cls, force_emacs=False)
 
worksWithMajorMode(cls, mode)
Hook to restrict the action to only be displayed with a specific major mode

Inherited from debug.debugmixin: dprint

Class Variables
  alias = ''
This alias holds an emacs style name that is used during M-X processing.
  default_menu = ()
The default menu location is specified here as a tuple containing the menu path (separated by / characters) and a number between 1 and 1000 representing the position within the menu.
  default_toolbar = True
Toolbar item will automatically be created unless this is False
  global_id = None
If the action doesn't use a stock id, it will automatically get assigned a global id here.
  icon = None
If there is an icon associated with this action, name it here.
  key_bindings = None
Map of platform to default keybinding.
  keyboard = None
Current keybinding of the action.
  name = None
This is the name of the menu entry as it appears in the menu bar.
  stock_id = None
If this menu action has a stock wx id, such as wx.ID_ABOUT or wx.ID_PREFERENCES, add it here and the wx menu system can do some special things to it, like automatically give it the correct location on WXMAC.
  tooltip = None
Tooltip that is displayed when the mouse is hovering over the menu entry.

Inherited from debug.debugmixin: debuglevel

Properties

Inherited from object: __class__

Method Details

__init__(self, frame, menu=None, toolbar=None)
(Constructor)

 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

action(self, index=-1, multiplier=1)

 

Override this to provide the functionality of the action.

This method gets called when the user initiates the action, whether it be from the menu bar, toolbar, or keyboard.

Parameters:
  • index - The index of the item in the list. This is only useful for list or radio items.
  • multiplier - the multiplier supplied by the keyboard handler. The keyboard handler allows for emacs-style repeat commands. For some actions, it makes sense to allow repetition of the command. For instance, in a command that uppercases words, the multiplier could be 4, would mean that the next 4 words get uppercased. The default is 1.

isEnabled(self)

 

Override this to provide the enable/disable state of the item.

The menu system will call this method before the menu is drawn (or periodically during idle time for toolbar items) to determine whether or not the item should be disabled (grayed out).

Default is to always enable the item.

worksWithMajorMode(cls, mode)
Class Method

 

Hook to restrict the action to only be displayed with a specific major mode

This hook is called by the menu creation code to determine if the action should be displayed when showing the major mode's user interface.

Parameters:
  • mode - the major mode instance
Returns:
True if the action is allowed to be associated with the major mode

Class Variable Details

alias

This alias holds an emacs style name that is used during M-X processing. If you don't want this action to have an emacs style name, don't include this or set it equal to None

Value:
''

default_menu

The default menu location is specified here as a tuple containing the menu path (separated by / characters) and a number between 1 and 1000 representing the position within the menu. A negative number means that a separator should appear before the item

Value:
()

global_id

If the action doesn't use a stock id, it will automatically get assigned a global id here. Note that if you are subclassing an action, you should explicitly assign a global id (or None) to your subclass's global_id attribute, otherwise the menu system will get confused and attempt to use the superclass's global_id

Value:
None

icon

If there is an icon associated with this action, name it here. Icons are referred to by path name relative to the peppy directory. A toolbar entry will be automatically created if the icon is specified here, unless you specify default_toolbar = False

Value:
None

key_bindings

Map of platform to default keybinding. This is used to assign the class attribute keyboard, which is the current keybinding. Currently, the defined platforms are named "win", "mac", and "emacs". A platform named 'default' may also be included that will be the default key unless overridden by a specific platform

Value:
None

keyboard

Current keybinding of the action. This is set by the keyboard configuration loader and shouldn't be modified directly. Subclasses should leave this set to None.

Value:
None

name

This is the name of the menu entry as it appears in the menu bar. i18n processing happens within the menu system, so no need to wrap this string in a call to the _ function

Value:
None

tooltip

Tooltip that is displayed when the mouse is hovering over the menu entry. If the tooltip is None, the tooltip is taken from the first line of the docstring, if it exists.

Value:
None