Python command reference: Difference between revisions

From MXWendler Wiki
Jump to navigation Jump to search
remove cross-language see-also links (covered by sidebar)
Add to Category:Reference (bot)
Line 214: Line 214:
* [[3. Python imgui reference|Python ImGui Reference]] &ndash; drawing plugin panels with <code>mxw_imgui</code>
* [[3. Python imgui reference|Python ImGui Reference]] &ndash; drawing plugin panels with <code>mxw_imgui</code>
* [[3. Python plugin reference|Python Plugin Howto]] &ndash; writing media and playlist plugins
* [[3. Python plugin reference|Python Plugin Howto]] &ndash; writing media and playlist plugins
[[Category:Reference]]

Revision as of 16:45, 8 August 2026


This page lists the commands of the Python module mxw, MXWendler's general Python command interface. It is available from the script console and from Python plugins (see the Python Plugin Howto). For drawing plugin panels see the Python ImGui Reference.

The embedded interpreter is Python 3.12. Import is implicit in the script console; in a plugin module use import mxw.

The presented Python commands supported in version 7.2. and up

Legend

FLOATS are written with one decimal: 0.0 .. 1.0 → every float between 0 and 1 inclusive.

INTEGERS are written as plain numbers or ranges: 1 .. 5 → the integers 1,2,3,4,5.

STRINGS are written between double quotes.

When OR appears, two alternative call formats produce a similar result; use one at a time.

Addressing: widgets are targeted by their OSC-style address string, e.g. /mxw/track/active/layer/active/clip. The same addresses used over OSC work here.

Access model (7.2): widget values are read/written through mxw.widget(address); global functions live in the submodules/factories mxw.playlist, mxw.io, mxw.preload(n), mxw.media(name), mxw.grabber(name).

Reference

PYTHON COMMAND/SYMBOL DESCRIPTION EXAMPLE
Software Info
mxw.millis milliseconds passed since the software was opened mxw.print_console("passed time is " + str(mxw.millis))
mxw.width current frame width in px mxw.print_console("frame width is " + str(mxw.width))
mxw.height current frame height in px mxw.print_console("frame height is " + str(mxw.height))
mxw.outwidth current output width in px mxw.print_console("output width is " + str(mxw.outwidth))
mxw.outheight current output height in px mxw.print_console("output height is " + str(mxw.outheight))
mxw.framecounter number of frames rendered since the software was opened mxw.print_console("frames rendered: " + str(mxw.framecounter))
mxw.print_console("text") print a line to the script console mxw.print_console("hello")
mxw.print_statusline("text") print text on the application status line mxw.print_statusline("running")
mxw.makescreenshot("path") save a full-frame screenshot as PNG (empty path → Desktop) mxw.makescreenshot("c:/Users/me/Desktop/shot.png")
mxw.makesectionscreenshot("path", x, y, w, h) save a cropped screenshot of the region (x, y, w, h) mxw.makesectionscreenshot("c:/Users/me/Desktop/crop.png", 0, 0, 400, 200)
mxw.describe() return a text listing of every operation known to the unified interface registry (auto-docs / discovery) mxw.print_console(mxw.describe())
I/O ( mxw.io )
mxw.io.dmx(channel) return the DMX value received on the given channel v = mxw.io.dmx(4)
mxw.io.midi(device, channel) return the MIDI value received from device/channel v = mxw.io.midi(1, 6)
mxw.io.keyboard(state, key) return whether the given key (ASCII) is in the given state if mxw.io.keyboard(0, 65): pass
mxw.io.send_dmx(channel, value) send a DMX value on a channel mxw.io.send_dmx(4, 255)
mxw.io.send_midi(device, channel, value) send a MIDI value to device/channel mxw.io.send_midi(1, 6, 100)
mxw.io.pjlink("command", "ip", "pw") PJLink projector control. Commands: on, off, avmute_on, avmute_off, vmute_on, vmute_off mxw.io.pjlink("on", "192.168.1.2", "panasonic")
mxw.io.send_osc("host", port, "address", "tags", *args) send an OSC message. tags is one char per argument: d float, i int, c string, b blob (list of 0..255) mxw.io.send_osc("127.0.0.1", 7000, "/cue", "ci", "go", 5)
Playlist ( mxw.playlist )
mxw.playlist.preload_media() preload the media used by the playlist mxw.playlist.preload_media()
mxw.playlist.play() play the playlist mxw.playlist.play()
mxw.playlist.pause() pause, or restart if already paused mxw.playlist.pause()
mxw.playlist.go_pause(True/False) halt (True) or resume (False) playback mxw.playlist.go_pause(True)
mxw.playlist.skiptonext() skip to the next cue mxw.playlist.skiptonext()
mxw.playlist.go_next() go to the next cue without playing mxw.playlist.go_next()
mxw.playlist.go_prev() go to the previous cue mxw.playlist.go_prev()
mxw.playlist.go_first() go to the first cue mxw.playlist.go_first()
mxw.playlist.navigate_index(index) go to the cue with the given index mxw.playlist.navigate_index(2)
mxw.playlist.navigate_string("name") go to the cue matching the given name mxw.playlist.navigate_string("BG_video2")
mxw.playlist.get_active_cue() return the active cue index (int) i = mxw.playlist.get_active_cue()
mxw.playlist.get_cue_count() return the number of cues (int) n = mxw.playlist.get_cue_count()
mxw.playlist.get_cue_names() return the list of cue names (index matches navigate_index) for name in mxw.playlist.get_cue_names(): pass
mxw.playlist.is_rehearsal() return True if the playlist is in rehearsal mode if mxw.playlist.is_rehearsal(): pass
Preload ( mxw.preload(n) )
mxw.preload(n).isvalid() True if preload n exists if mxw.preload(2).isvalid(): pass
mxw.preload(n).clear() clear the selected preload mxw.preload(2).clear()
mxw.preload(n).set_media("filename") set the preload media by filename mxw.preload(2).set_media("try.mp4")
mxw.preload(n).set_name("name") rename the preload mxw.preload(2).set_name("new_background")
mxw.preload(n).add_preload() load the preload into the layers mxw.preload(2).add_preload()
mxw.preload(n).trigger_preload() trigger a layer from the preload mxw.preload(2).trigger_preload()
mxw.preload(n).get_activated() True if the preload is open for edit mxw.preload(2).get_activated()
mxw.preload(n).set_activated(True/False) open/close the preload for edit mxw.preload(2).set_activated(False)
mxw.preload(n).get_layer_position() return the preload's layer index mxw.preload(2).get_layer_position()
mxw.preload(n).get_track_position() return the preload's track index mxw.preload(2).get_track_position()
mxw.preload(n).set_layer_position(pos) set the preload's layer index mxw.preload(2).set_layer_position(2)
mxw.preload(n).set_track_position(pos) set the preload's track index mxw.preload(2).set_track_position(2)
mxw.preload(n).get_preload_names() return the list of preload comment/name strings names = mxw.preload(2).get_preload_names()
mxw.preload(n).get_image_sample_cvmat(w, h) return a w×h RGBA image sample of the preload as a buffer (OpenCV Mat) img = mxw.preload(2).get_image_sample_cvmat(64, 64)
Widgets ( mxw.widget(address) )
mxw.widget("/mxw/path").getValue() return the widget's normalized value (float) o = mxw.widget("/mxw/track/active/layer/active/opacity").getValue()
mxw.widget("/mxw/path").setValue(v) set the widget's normalized value mxw.widget("/mxw/track/active/layer/active/opacity").setValue(0.5)
mxw.widget("/mxw/path").getStringValue() return the widget's string value (e.g. a cue/clip name) mxw.print_console(mxw.widget("/mxw/playlist/container/1/column/0/row/1").getStringValue())
mxw.widget("/mxw/path").setStringValue("text") set the widget's string value (e.g. name a cue) mxw.widget("/mxw/playlist/container/1/column/0/row/1").setStringValue("background videoclip")
mxw.widget("/mxw/path").setWidgetRealValue(d) set the widget's real (un-normalized) value mxw.widget("/mxw/path").setWidgetRealValue(120.0)
mxw.widget("/mxw/path").animate(initvalue, incomingvalue, duration, delta, type) animate the widget value over duration ms mxw.widget("/mxw/path").animate(0.0, 1.0, 1000, 0.0, 0)
mxw.widget("/mxw/path").info() return a list describing the widget. For a clip: [length, width, height, millis_per_frame, cache_state, media_path]. Returns [] if the address does not resolve length, w, h, mspf, cache, path = mxw.widget("/mxw/track/active/layer/active/clip").info()
Media ( mxw.media(name) )
mxw.media("name").isvalid() True if the named media exists if mxw.media("USB Cam").isvalid(): pass
mxw.media("name").reference(True/False) add (True) or remove (False) a reference that keeps the media loaded mxw.media("clip.mov").reference(True)
mxw.media("name").unload_media_full_if_not_used_by_clips() unload the media if no clip uses it (returns bool) mxw.media("clip.mov").unload_media_full_if_not_used_by_clips()
mxw.media("name").get_image_sample_cvmat(w, h) return a w×h RGBA image sample of the media (OpenCV Mat) img = mxw.media("clip.mov").get_image_sample_cvmat(64, 64)
mxw.media("name").get_image_sample_cvmat_async(w, h) non-blocking variant of the image sample img = mxw.media("clip.mov").get_image_sample_cvmat_async(64, 64)
mxw.media("name").get_capture_device_names() return the list of available capture-device names devs = mxw.media("").get_capture_device_names()
mxw.media("name").ptz("ptz_is_supported") return whether the (NDI) camera supports PTZ mxw.media("USB Cam").ptz("ptz_is_supported")
mxw.media("name").ptz("ptz_zoom", value) zoom, 0 (in) .. 1 (out) mxw.media("USB Cam").ptz("ptz_zoom", 0.5)
mxw.media("name").ptz("ptz_zoom_speed", value) zoom speed, -1 (out) .. 1 (in) mxw.media("USB Cam").ptz("ptz_zoom_speed", 0.5)
mxw.media("name").ptz("ptz_pan_tilt", pan, tilt) absolute pan/tilt, -1 .. 1 mxw.media("USB Cam").ptz("ptz_pan_tilt", -0.5, 0.2)
mxw.media("name").ptz("ptz_pan_tilt_speed", pan_speed, tilt_speed) pan/tilt speed, -1 (right/down) .. 1 (left/up) mxw.media("USB Cam").ptz("ptz_pan_tilt_speed", -0.3, 0.8)
mxw.media("name").ptz("ptz_store_preset", n) store position/focus/zoom into preset 0 .. 99 mxw.media("USB Cam").ptz("ptz_store_preset", 75)
mxw.media("name").ptz("ptz_recall_preset", n, speed) recall preset 0 .. 99 at speed 0 .. 1 mxw.media("USB Cam").ptz("ptz_recall_preset", 4, 0.5)
mxw.media("name").ptz("ptz_auto_focus") toggle auto-focus mxw.media("USB Cam").ptz("ptz_auto_focus")
mxw.media("name").ptz("ptz_focus", value) absolute focus, 0 (infinity) .. 1 (closest) mxw.media("USB Cam").ptz("ptz_focus", 0.5)
mxw.media("name").ptz("ptz_focus_speed", value) focus speed, -1 (out) .. 1 (in) mxw.media("USB Cam").ptz("ptz_focus_speed", -0.2)
mxw.media("name").ptz("ptz_white_balance_auto") auto white balance mxw.media("USB Cam").ptz("ptz_white_balance_auto")
mxw.media("name").ptz("ptz_white_balance_indoor") indoor white balance mxw.media("USB Cam").ptz("ptz_white_balance_indoor")
mxw.media("name").ptz("ptz_white_balance_outdoor") outdoor white balance mxw.media("USB Cam").ptz("ptz_white_balance_outdoor")
mxw.media("name").ptz("ptz_white_balance_oneshot") set white balance once from current brightness mxw.media("USB Cam").ptz("ptz_white_balance_oneshot")
mxw.media("name").ptz("ptz_white_balance_manual", red, blue) manual white balance, 0.0 .. 1.0 each mxw.media("USB Cam").ptz("ptz_white_balance_manual", 0.1, 0.7)
mxw.media("name").ptz("ptz_exposure_auto") auto exposure mxw.media("USB Cam").ptz("ptz_exposure_auto")
mxw.media("name").ptz("ptz_exposure_manual", level) manual exposure iris, 0.0 (dark) .. 1.0 (light) mxw.media("USB Cam").ptz("ptz_exposure_manual", 0.4)
mxw.media("name").ptz("ptz_exposure_manual_v2", iris, gain, shutter) manual exposure iris/gain/shutter, 0.0 .. 1.0 each mxw.media("USB Cam").ptz("ptz_exposure_manual_v2", 0.4, 0.2, 0.5)
Grabber ( mxw.grabber(name) )
mxw.grabber("name").isvalid() True if the named keystone grabber exists if mxw.grabber("cam").isvalid(): pass
mxw.grabber("name").getGrabSizeX() grabber width in px mxw.grabber("cam").getGrabSizeX()
mxw.grabber("name").getGrabSizeY() grabber height in px mxw.grabber("cam").getGrabSizeY()
mxw.grabber("name").getData() return the grabber's pixels as a byte list (RGBA, width×height×4) px = mxw.grabber("cam").getData()

See also