command¶
-
class
guerilla.
command
¶ Bases:
object
Base class to create new command in Guerilla
In order to create a command in Guerilla, derive the class
command
and implement at leastaction()
as a static method (isenabled()
is optional)To add the command to the Guerilla main menu, use
install()
.>>> from guerilla import command, Node >>> class AddNode(command): ... @staticmethod ... def action(luaObj, window, x, y, suffix): ... n = Node.create('foo') >>> cmd = AddNode('addNode') >>> cmd.install('PyGuerilla', 'tests') >>> cmd.execute()
-
__init__
(name, icon=None, shortcut=None)¶ Command constructor
Parameters:
-
static
action
(luaObj, window, x, y, suffix)¶ action method for command
Return type: None Note
default method will do nothing
-
static
addseparator
(*args)¶ Add a command separator in Guerilla main menu
Parameters: args (list of str) – list of menu name >>> command.addseparator ('Modify', 'Id')
-
execute
()¶ Execute the command
-
static
executebyshortname
(name, window=None)¶ Execute a command by its name
Parameters: - name – The command shortname to execute
- window – The optional window pointer if the command should act on a specific window
-
static
focusview
(name, viewtype, icon=None, shortcut=None)¶ Create a command to focus a specific view (or create the view in the current active tab)
This function creates a command that looks for a specific in the current window layout, and sets focus on that window. In the event such a window can’t be found, a new window of that type is created in the current active tab.
Available view types are:
- Library
- Linking
- NodeList
- Passes
- RenderView
- Browser
- Viewport
Parameters: Return type: Raise: RuntimeError if in batch mode (nogui)
Return type:
-
static
getcommandbyshortname
(name)¶ Return a command by its shortname, or None if the command doesn’t exist
Parameters: name (str) – command name
-
static
getshortcommands
()¶ Return the list of commands, indexed by their short name
Return type: dict
-
install
(*args)¶ Install command in Guerilla main menu
Parameters: args (list of str) – list of menu name >>> cmd = command('dummycmd'); >>> cmd.install('Modify', 'SubMenu', 'SubSubMenu')
-
static
isenabled
(luaObj, window)¶ isenabled method for command
Return False to disable command execution in Guerilla menu.
Return type: bool Note
default method will always return True
-
name
¶ command name
-
setshortcut
(shortcut)¶ Set a command shortcut
Parameters: shortcut (str) – The command shortcut to associate (or None if no shortcut is to be associated)
-
static
uninstall
(*args)¶ Remove a command from the main menu
Parameters: - name – name of the command to remove
- args (list of str) – list of menu name where to find the command
>>> cmd = command('dummycmd'); >>> cmd.install('Modify', 'SubMenu', 'SubSubMenu'); >>> cmd.uninstall('Modify', 'SubMenu', 'SubSubMenu', 'dummycmd')
-