All templates
ScriptingIntermediate
Display Python Output
Robomotion•Updated 6 months ago

Overview
Runs an inline Python script and shows its output in a dialog. Demonstrates the Python Run node.
Display Python Output
Python is a high-level programming language known for its scripting capabilities. Robomotion enables users to run Python scripts and automate complex scenarios that require a custom approach.
What Display Python Output can do
- Run Python script (
Core.Process.StartProcess) — runspythonwith-c 'variableName = "Hello World!"\nprint(variableName)', captures stdout intomsg.python_output. - Trim output (
Core.Programming.Function) — strips trailing CR/LF frommsg.python_output. - Message Dialog (
Core.Dialog.MessageBox,optType: info) titledOutput from Python script:showsmsg.python_output, thenCore.Flow.Stop.
Behind the scenes
- The inline script uses the Python 3
print(variableName)call syntax, matching thepythoninterpreter most systems ship today. If you need Python 2 fidelity, pointinFilePathat a Python 2 binary and change the call back to theprintstatement form. - Trimming trailing newlines before the dialog keeps the message box compact —
printalways appends a\non stdout.