-
Notifications
You must be signed in to change notification settings - Fork 58
How a Component Works
All components must inherit from the Component base class, which is a type of QObject. The class must have the following attributes (as class variables):
-
name
-
version
(a string such as '1.0.0')
The major version is used to determine preset compatibility, i.e., presets created for version 1.0.0 will work with 1.1.2 but not 2.0.0.
By default, the module filename is used to find the component's .ui file (module.py
uses module.ui
). An optional ui
attribute may be defined for a custom .ui filename if necessary.
-
The component's
widget()
method is called to create the component's QtWidget (saved asself.page
). -
Any simple widgets within the page (e.g., lineedits, checkboxes, spinboxes) are automatically connected to the component's
update()
method. -
To save the values of these widgets as attributes, this magical method must be used within the
widget()
definition:trackWidgets({'attribute_name': self.page.widget})
-
Immediately after creation,
update()
is called. -
If the program is in commandline mode,
command()
will be called next to process an argument. If the argument isn't valid, the subclass should callsuper().command(*args)
to let the base class triggercommandHelp()
.
-
The
update()
method could be called any number of times, possibly as the user changes configuration rapidly. Any tracked widgets (defined bytrackWidgets({})
) will have their values assigned to the corresponding attribute. -
savePreset()
andloadPreset()
could be called at any time. The first may be called far more often for creating autosaves. Both methods will automatically make use of tracked widgets. -
previewRender()
must return a Pillow image of the exact correct frame size (usetoolkit.frame
functions).
-
preFrameRender()
is called to give the components attributes such ascompleteAudioArray
which contains raw PCM data the component could use for a visualization. -
properties()
is checked next to see what properties the component has. It must return a list of strings from this pool:static
,audio
,error
. Each property's method is called if it exists in this list. -
static
has no further options, the presence of the property simply indicates that the component is not animated and only needs itsframeRender()
method to be called once. -
audio()
must return a tuple of(filename, {ffmpeg_parameters})
. The filename is used as an input file for ffmpeg, and the ffmpeg parameters are used to define a series of audio filters to be applied to this input file. -
error()
may be undefined or return a string for a simple error message, or a tuple with two strings for more detail. -
frameRender(int frameNumber)
is called as many times as needed to construct the video. This method must return a Pillow image of the exact correct size (usetoolkit.frame
functions). -
postFrameRender()
is called at the end of the export, whether it completes successfully or not, in case the component needs to do any cleanup.