Difference between revisions of "Action"
Jump to navigation
Jump to search
(Created page with "== Action == All Actions must be derived from the '''Action''' base class, and should implement the <tt>available</tt> and <tt>execute</tt> methods. === Attributes === ''Th...") |
|||
(9 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | + | All Actions must be derived from the '''Action''' base class, and should implement the <tt>available</tt> and <tt>execute</tt> methods. | |
− | + | Refer to the built-in Actions in the resources/scripts/actions directory for examples. | |
=== Attributes === | === Attributes === | ||
Line 9: | Line 9: | ||
! scope="col" | Name | ! scope="col" | Name | ||
! scope="col" class="unsortable" | Description | ! scope="col" class="unsortable" | Description | ||
+ | ! scope="col" | Added | ||
|- | |- | ||
|actionType | |actionType | ||
Line 21: | Line 22: | ||
|label | |label | ||
|The Action label that appears in the Actions menu | |The Action label that appears in the Actions menu | ||
+ | |- | ||
+ | |root | ||
+ | |The root menu name the Action is in | ||
+ | |- | ||
+ | |menu | ||
+ | |The menu the action is in, if a menu extension | ||
+ | |6.0 | ||
|} | |} | ||
Line 29: | Line 37: | ||
! scope="col" class="unsortable" | Description | ! scope="col" class="unsortable" | Description | ||
|- | |- | ||
− | | | + | |__init__(label, menu=None, root=None, type=Action, extension=None, order=-1, after=None) |
− | | | + | |Constructor - Initializes the base class. The menu can be listed separately or prefixed to the label with the '<nowiki>|</nowiki>' character. "Actions" is the default top-level menu for normal Actions, but can be overridden with the <tt>root</tt> argument, to put the Action into an alternate menu (such as <tt>File</tt> or <tt>Edit</tt>). <tt>order</tt> can be used to control the order of the action in the list, and use <tt>after</tt> to specify the name of an action that this one should appear after. |
− | |- | ||
− | |||
|- | |- | ||
− | | | + | |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. | ||
|} | |} | ||
Line 46: | Line 54: | ||
! scope="col" | Name | ! scope="col" | Name | ||
! scope="col" class="unsortable" | Description | ! scope="col" class="unsortable" | Description | ||
+ | ! scope="col" | Added | ||
|- | |- | ||
|Action | |Action | ||
− | |A normal action | + | |A normal action that appears in the Actions menu (the default) |
|- | |- | ||
|ShapeImporter | |ShapeImporter | ||
Line 57: | Line 66: | ||
|- | |- | ||
|TrackerImporter | |TrackerImporter | ||
− | |An Action that should appear in the Tracker Import | + | |An Action that should appear in the Tracker Import dialog |
+ | |6.0 | ||
|- | |- | ||
|TrackerExporter | |TrackerExporter | ||
− | |An Action that should appear in the Tracker Export | + | |An Action that should appear in the Tracker Export dialog |
− | | | + | |6.0 |
− | |||
− | |||
|- | |- | ||
|Extension | |Extension | ||
|An Action that implements core functionality is bound using some other means | |An Action that implements core functionality is bound using some other means | ||
|} | |} |
Latest revision as of 17:36, 25 July 2018
All Actions must be derived from the Action base class, and should implement the available and execute methods.
Refer to the built-in Actions in the resources/scripts/actions directory for examples.
Contents
Attributes
These attributes are read-only.
Name | Description | Added |
---|---|---|
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 | |
root | The root menu name the Action is in | |
menu | The menu the action is in, if a menu extension | 6.0 |
Methods
Name | Description |
---|---|
__init__(label, menu=None, root=None, type=Action, extension=None, order=-1, after=None) | Constructor - Initializes the base class. The menu can be listed separately or prefixed to the label with the '|' character. "Actions" is the default top-level menu for normal Actions, but can be overridden with the root argument, to put the Action into an alternate menu (such as File or Edit). order can be used to control the order of the action in the list, and use after to specify the name of an action that this one should appear after. |
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 | Added |
---|---|---|
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 | |
TrackerImporter | An Action that should appear in the Tracker Import dialog | 6.0 |
TrackerExporter | An Action that should appear in the Tracker Export dialog | 6.0 |
Extension | An Action that implements core functionality is bound using some other means |