Difference between revisions of "Action"

From Silhouette Wiki
Jump to navigation Jump to search
Line 29: Line 29:
 
! scope="col" class="unsortable" | Description
 
! scope="col" class="unsortable" | Description
 
|-
 
|-
|action(name)
+
|__init__(label, menu=None, type=Action, extension=None)
|Returns the [[Action]] with the given name
+
|Constructor - Initializes the base class. The menu can be listed separately or prefixed to the label with the '|' character.
 
|-
 
|-
|activeLayer()||Return the active [[Layer]], or None
+
|available()
 +
|Should return True (the default) if the Action is available. The Action should examine the current state in this method and assert (with an optional error message) that conditions are good for execution.
 
|-
 
|-
|activeNode()||Return the active [[Node]], or None
+
|execute(path=None)
|-
+
|Called to execute the Action. UI Actions should be undoable. Importer/Exporter actions are passed the path to the file to operate on.
|activeProject()||Return the active [[Project]], or None
 
 
|}
 
|}
  

Revision as of 19:18, 18 November 2012

Action

All Actions must be derived from the Action base class, and should implement the available and execute methods.

Attributes

These attributes are read-only.

Name Description
actionType The Action Type
extension If the Action implements an importer or exporter, the file extension the action works with
id The Action class name
label The Action label that appears in the Actions menu

Methods

Name Description
__init__(label, menu=None, type=Action, extension=None) ' character.
available() Should return True (the default) if the Action is available. The Action should examine the current state in this method and assert (with an optional error message) that conditions are good for execution.
execute(path=None) Called to execute the Action. UI Actions should be undoable. Importer/Exporter actions are passed the path to the file to operate on.

Constants

Action Type

Name Description
Action A normal action that appears in the Actions menu (the default)
ShapeImporter An Action that should appear in the Shape Import menu
ShapeExporter An Action that should appear in the Shape Export menu
Extension An Action that implements core functionality is bound using some other means