Scripting Scribus with Python

Scripting Scribus with Python

Abstract

This is the description how to use the Scripting Plugin for Scribus. This Plugin allows you to use the powerful Python Language as a Scripting Language in Scribus.

This manual is the first version, by no means complete or fully accurate. There are just a couple of commands written in red letters aren't yet implemented yet in this version.

There are some simple example scripts in the samples subdirectory where Scribus is installed. If you have created scripts which would be useful for other users, please feel free to contribute a copy to the program author, Franz Schmid. Hopefully, in the near future, a Scribus plug-in gallery will be added.

Using the Plugin

Running a script

To execute a Python Script select "Script->Execute Script..." Scribus will display a File select Box which allows you to select a Python Script. Below there is an extra Menu item "Recent Scripts" where all your recent Scripts are remembered. How many Scripts are remembered depends on your Setting for Recent Documents in the Scribus Preferences.

You can use many Python Programs with this Plugin. The only exception are Scripts who expect Parameters from the Command Line. They won't work because the Plugin gives the Python Interpreter an empty Command Line.

The Menu Item "Show Console" gives you an interactive Python Console, where you can execute Commands directly. There is no need to do a "from scribus import *", this has already been done. You can use all the following Commands in the Scripter API section directly without any Prefix. Scribus Python console is quite different from Python console itself. It takes some useful things from well known development tools.

The console window id divided into two parts. First part, the code editor, is simple programming text editor. You can here load and save your scripts or files with some unrelated commands. You can run all commands at once by "Script/Run" menu item (or just press "F9" key) but you can select only a piece of the text so then will be only selected commands processed. The second way can be used for simple debugging of the large scripts. You can have e.g. file with small pieces of the frequently used commands (e.g. a loop with eleven text boxes creation) then you can quickly "select and run" without any writting.

Second part of the console is the output window. It is a container of the output of your commands or scripts. Text in this window is erased everytime you run new command but you can save actual content by "Script/Save Output...".

You can get some useful informations about any script calling "Script->About Script...".

You can display this Reference Manual when you select "Help->Scripter Manual...".