How to output string from Python script in a workflow on the editor
I'm new to Editorial and I'm new to Python.
I created a new workflow with only one action, a custom Python script.
I want the script to output text on the editor, so I called
workflow.set_output(output_string), but nothing shows up in the editor. Although, calling
print(output_string)will output the string I want in the console.
Is there something I'm missing?
Adding a Replace Selected Text action after the custom Python script solved my problem. If no text is selected, the output I wish to add in my editor is inserted at the position of the cursor.
A Replace Selected Text action is the easiest way to do this. If you need more fine-grained control, you can use the
replace_textfunction in the
editormodule to insert text directly from Python.
workflow.set_output() sends whatever is inside of the parenthesis to the next action. That is why you have to use "Replace selected text" as the following action. You have to make the output of "Replace Selected text" the Input of the action above it (Using variables)
Here is an example:
Edit: oops, I see you figured it out. One thing I did was change the name of the Replace Selected Text action to "Output to Editor" and saved that as a preset. It is easier to remember what the action does.