Package peppy :: Module menu :: Class UserActionMap
[frames] | no frames]

Class UserActionMap

      object --+    
               |    
debug.debugmixin --+
                   |
                  UserActionMap

Creates a mapping of actions for a frame.

This class creates the ordering of the menubar, and maps actions to menu items. Note that the order of the menu titles is required here and can't be added to later.

Instance Methods
 
__init__(self, frame, mode)
Initialize the mapping with the new set of actions.
 
createActions(self, mode)
Create the list of actions corresponding to this major mode.
 
updateMinMax(self, min, max)
Update the min and max menu ids
 
getAction(self, actioncls)
Return an existing action if already instantiated, or create it
 
updateMenuActions(self, menubar)
Populates the frame's menubar with the current actions.
 
updateToolbarActions(self, auimgr)
 
getKeyboardActions(self)
 
updateActions(self, toolbar=True)
 
popupActions(self, parent, action_classes=[])
Create a popup menu from the list of action classes.
 
cleanupPrevious(self, auimgr)
 
cleanupAndDelete(self)
 
reconnectEvents(self)
Update event handlers if the menu has been dynamically updated
 
disconnectEvents(self)
Remove the event handlers for the range of menu ids
 
connectEvents(self)
Add event handlers for the range of menu ids
 
OnMenuSelected(self, evt)
Process a menu selection event
 
OnUpdateUI(self, evt)
Update the state of the toolbar items.
 
OnMenuOpen(self, evt)
Callback when a menubar menu is about to be opened.

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

Class Methods

Inherited from debug.debugmixin: dprint

Class Variables
  mode_actions = {}
mapping of major mode class to list of actions

Inherited from debug.debugmixin: debuglevel

Properties

Inherited from object: __class__

Method Details

__init__(self, frame, mode)
(Constructor)

 

Initialize the mapping with the new set of actions.

The ordering of the menu items is set here, but nothing is actually mapped to a menubar or a toolbar until either updateMenuActions or updateToolbarActions is called.

frame: parent Frame object action_classes: list of possible action classes (i.e. not instantiated classes, but the classes themselves. They will be instantiated when they are mapped to a menubar or toolbar.

Overrides: object.__init__

createActions(self, mode)

 

Create the list of actions corresponding to this major mode.

The action list includes all commands regardless of how they are initiated: menubar, toolbar, or keyboard commands. If a new minor mode or sidebar is activated, this list will have to be regenerated.

updateMinMax(self, min, max)

 

Update the min and max menu ids

The range of menu Ids are used in the menu event handlers so that you don't have to bind events individually.

updateMenuActions(self, menubar)

 

Populates the frame's menubar with the current actions.

This replaces the current menubar in the frame with the menus defined by the current list of actions.

reconnectEvents(self)

 

Update event handlers if the menu has been dynamically updated

Sub-ids may have changed after a dynamic menu change, so update the min-max list, and update the event handlers.

OnUpdateUI(self, evt)

 

Update the state of the toolbar items.

This event only gets fired for toolbars? I had thought it was fired just before wx shows the menu, giving us a chance to update the status before the user sees it.

OnMenuOpen(self, evt)

 

Callback when a menubar menu is about to be opened.

Note that on Windows, this also happens when submenus are opened, but gtk only happens when the top level menu gets opened.

By trial and error, it seems to be safe to update dynamic menus here.