Package pallavi :: Module EventActionManager :: Class Action
[hide private]
[frames] | no frames]

Class Action

source code


Any action that can occur in the editor. This can be used as communication between two plugins (this allows decoupling, so either plugin could be replaced by a different version), or actions can be bound to keystrokes, menu items, toolbars, etc. They can be created dynamically by macros and plugins and bound at any time.

Instance Methods [hide private]
 
__init__(self, name, callback, label=None, description=None, icon=None)
Initialize the action.
source code
 
IsUserAction(self)
return true if this is an action that should be visible to end users, false otherwise.
source code
 
Invoke(self, *args, **kwargs)
Invokes the action.
source code

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, name, callback, label=None, description=None, icon=None)
(Constructor)

source code 

Initialize the action. The name must be provided and must be unique from all other actions in the editor. This includes plugins, so plugin-developers are encouraged to watch their namespace. For example, prepend the name of your plugin to all actions the plugin might define. A callback function that takes one argument (may be None) must also be supplied unless the Action class has been subclassed and the invoke method has been overridden.

A label, description, and icon can also be provided. The label serves two purposes: First, it behaves as a flag that this is an end-user action as opposed to an action for communication betwen plugins. If it is set to None, then it is an internal action. Second it provides a label that will be displayed to end users in identifying the action in action lists or in adding the action to menus or other visible items. The description is optional, but highly recommended for user-visible actions. It is used to describe the action in action lists or as a mouse tooltip for menuitems, toolbars, and the like. Finally, an optional icon can be specified to be associated with the action in gui menus or toolbars.
Overrides: object.__init__

Invoke(self, *args, **kwargs)

source code 

Invokes the action. The default implementation calls the callback associated with the Action, but it could be subclassed and this method overridden to provide this behaviour directly.

The optional data parameter can contain action-specific information that the callback must interpret. There is an implicit agreement between event callers and handlers that this data will make sense to each other, but event callbacks should not rely on this. The source of the data may not be known, though non-primitive data is encouraged to have a "GetEventObject()" method.