Controlling MXW through Python: Difference between revisions

From MXWendler Wiki
Jump to navigation Jump to search
Hwendler (talk | contribs)
No edit summary
m Admin moved page 1. Controlling MXW through Python to Controlling MXW through Python: Remove leading index prefix from title
 
(26 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Python is used in MXW trough a plugin interface. Specified program paths are searched for plugins which are registered, and then loaded through the user interface.
<!-- MXWendler wiki page: Controlling MXW through Python (overview / hub) -->
<!-- Intended location: https://wiki.mxwendler.net/index.php?title=1._Controlling_MXW_through_Python -->
<!-- See also: https://wiki.mxwendler.net/index.php?title=Python_command_reference -->
<!-- See also: https://wiki.mxwendler.net/index.php?title=Python_imgui_reference -->
<!-- See also: https://wiki.mxwendler.net/index.php?title=Python_plugin_reference -->


As of version 7.2., plugins are available in the playlist. There are two paths searched during program startup, the program folder and the user folder:
MXWendler StageDesigner embeds '''Python 3.12'''. Python is used in two ways:


* '''(Program folder)/plugins/playlist/python/'''
* '''Command interface / scripting''' &ndash; the module <code>mxw</code> controls the running software (playlist, layers, clips, media, I/O, widgets by their address, ...) from the script console or from within a plugin.
* '''~.StageDesigner/plugins/playlist/python/ (Unix)'''
* '''Plugins''' &ndash; self-contained folders that add a media source or a playlist item and are called back by the host through a defined set of functions (''hooks'').
* '''~.StageDesigner/plugins/playlist/python/ (Windows)'''


Each plugin resides in a folder. Inside this folder, two files have to be present,
'''The presented Python interface is supported in version 7.2. and up'''


* '''mxw_plugin.ini'''
== Where to go ==
* '''mxw_main.py'''


The file '''mxw_plugin.ini''' defines the registration of the plugin. The following fields are valid:
The detailed documentation lives on three dedicated pages; this page only points to them so nothing is documented twice.
{| class="wikitable" style="margin:auto"
 
|+ Caption text
{| class="wikitable"
|-
|-
! Tag !! Use !! Values/Example
! Topic !! Page
|-
|-
| plugin_version || Plugin Version || 1
| The <code>mxw</code> command interface &ndash; software info, <code>playlist</code>, <code>io</code>, <code>widget(address)</code>, <code>media(name)</code>, <code>preload(n)</code>, <code>grabber(name)</code> || [[Python command reference|Python command reference]]
|-
|-
| plugin_script_language || Plugin Script Language || Python
| Drawing plugin settings panels with <code>mxw_imgui</code> (MXWendler's Dear ImGui binding) || [[Python imgui reference|Python ImGui reference]]
|-
|-
| Example || Example || Example
| Writing '''plugins''' &ndash; media and playlist &ndash; the manifest (<code>mxw_plugin.ini</code>), the hooks, per-instance state, examples || [[Python plugin reference|Python plugin reference]]
|}
|}


<syntaxhighlight lang="ini" line>
== Quick start ==
[mxw_plugin]                            ; must be here
 
plugin_version = 1                      ; must be V1 (as of 2023)
A minimal look at each entry point; follow the links above for the full reference.
plugin_script_language = Python        ; must be Python (as of 2023)
 
plugin_menu_parent = AI
'''Scripting.''' From the script console (or any hook), the <code>mxw</code> module reaches the software:
plugin_menu_name = NeuronalNet(Dlib) Face Detect Plugin
 
plugin_grid_name = Face Detect Plugin
<syntaxhighlight lang="Python" line>
plugin_grid_bg_color = 0.950000 0.050000 0.450000 1.000000 ; set plugin color.
import mxw
plugin_tooltip = This plugin triggers the playlist when it finds a Face using a neuronal net (Dlib)
mxw.print_console("frame " + str(mxw.framecounter))
</syntaxhighlight>
mxw.playlist.play()
mxw.widget("/mxw/track/active/layer/active/opacity").setValue(0.5)
</syntaxhighlight>
 
'''Plugins.''' A plugin is a folder holding a manifest and a Python module:
 
<pre>
plugins/playlist/python/plugin_my_item/
    mxw_plugin.ini      the manifest: identity, menu entries
    mxw_main.py        the Python module with the hook functions
</pre>
 
The host discovers it at startup, shows it in the user interface and calls its hooks at the right moments. See the [[Python plugin reference|Python plugin reference]] for the manifest fields, the full hook list for media and playlist plugins, plugin locations, installing extra packages with <code>mxw-pip</code>, and complete examples.
 
== See also ==
 
* [[Python command reference|Python command reference]] &ndash; the <code>mxw</code> module
* [[Python imgui reference|Python ImGui reference]] &ndash; drawing plugin panels with <code>mxw_imgui</code>
* [[Python plugin reference|Python plugin reference]] &ndash; writing media and playlist plugins

Latest revision as of 20:58, 8 August 2026


MXWendler StageDesigner embeds Python 3.12. Python is used in two ways:

  • Command interface / scripting – the module mxw controls the running software (playlist, layers, clips, media, I/O, widgets by their address, ...) from the script console or from within a plugin.
  • Plugins – self-contained folders that add a media source or a playlist item and are called back by the host through a defined set of functions (hooks).

The presented Python interface is supported in version 7.2. and up

Where to go

The detailed documentation lives on three dedicated pages; this page only points to them so nothing is documented twice.

Topic Page
The mxw command interface – software info, playlist, io, widget(address), media(name), preload(n), grabber(name) Python command reference
Drawing plugin settings panels with mxw_imgui (MXWendler's Dear ImGui binding) Python ImGui reference
Writing plugins – media and playlist – the manifest (mxw_plugin.ini), the hooks, per-instance state, examples Python plugin reference

Quick start

A minimal look at each entry point; follow the links above for the full reference.

Scripting. From the script console (or any hook), the mxw module reaches the software:

import mxw
mxw.print_console("frame " + str(mxw.framecounter))
mxw.playlist.play()
mxw.widget("/mxw/track/active/layer/active/opacity").setValue(0.5)

Plugins. A plugin is a folder holding a manifest and a Python module:

plugins/playlist/python/plugin_my_item/
    mxw_plugin.ini      the manifest: identity, menu entries
    mxw_main.py         the Python module with the hook functions

The host discovers it at startup, shows it in the user interface and calls its hooks at the right moments. See the Python plugin reference for the manifest fields, the full hook list for media and playlist plugins, plugin locations, installing extra packages with mxw-pip, and complete examples.

See also