eg.ActionBase

class eg.ActionBase

Base class of every action of a EventGhost plugin written in Python

name

Set this to descriptive name in your class definition. It might get translated by eg.PluginBase.AddAction() to the user’s language if a translation is found.

description

Set this to descriptive description in your class definition. It might get translated by eg.PluginBase.AddAction() to the user’s language if a translation is found.

iconFile

Name of an icon file if any. Use a 16x16-PNG and drop it inside your plugin’s folder. Only specify the name of the file without extension.

text

Assign a class with text strings to this field to get them localised. For more information read the section about Internationalisation Support for Plugins.

plugin

This will be set from eg.PluginBase.AddAction() for convenience, so every action can access its own plugin instance through this member variable.

info

Internally used house keeping data. Don’t try to manipulate this yourself.

__call__(*args)

Do the actual work. Will in most cases be overwritten in subclasses.

Configure(*args)

This should be overridden in a subclass, if the plugin wants to have a configuration dialog.

When the plugin is freshly added by the user to the configuration tree there are no *args and you must therefore supply sufficient default arguments. If the plugin is reconfigured by the user, this method will be called with the same arguments as the __start__() method would receive.

GetLabel(*args)

Returns the label that should be displayed in the configuration tree with the current arguments.

The default method simply shows the action name and the first parameter if there is any. If you want to have a different behaviour, you can override it.

This method gets called with the same parameters as the __call__() method.

Compile(*args)

Implementation of pre-compiled parameters.

An action class will only override this method, if it uses a special way to implement its action. An action receives a call to Compile() every time their parameters change (the user has reconfigured the action) or in the moment the configuration file is loaded and an action of this type is created because it was saved in the tree. The Compile() method should return a “callable” object, that can be called without any arguments. This “callable” will then be called instead of the the actions __call__() method.

This way actions can be build that need considerable time to compute something out of the parameters but need less time for the actual execution of the action. One example of such action is the PythonScript action, that compiles the Python source every time it changes and then this compiled code object gets called instead of doing compile&run in the __call__() method.

PrintError(msg)

Print an error message to the logger.

Prefer to use self.PrintError() instead of eg.PrintError(), since this method gives the user better information about the source of the error.

Previous topic

Coding Style Guidelines

Next topic

eg.Bunch

This Page