Troubleshooting Scripts

You are likely to find that a number of the example scripts on the wiki don't work, either generating errors, or perhaps nothing happens at all. This is because the acceptable syntax has changed over the years. On this page are some of the common problems I have encountered, often with my own scripts, which at one time worked, and later do not.

Invoking Scribus Commands
There are two ways to include the Scribus Scripter commands: and The first of these pulls in all of the Scripter commands into the interpreter, and is not the advocated method, since most scripts use a handful of Scribus Python commands. The second one only looks for a Scribus method when it is called, but it's important to tell Python that this is a Scribus command, so for example,

This is going to fail, and may even "hang" Scribus. This is because selectionCount, messageBox are Scribus commands, and ICON_WARNING and BUTTON_OK are Scribus-specific constants. So you need to prepend scribus. before each of these elements, like so:

Changes in Constants
This brings up another problem with some older scripts. In a messageBox command like above, you used to be able to use a number for these constants, like Trying this now will result in your script hanging and locking up Scribus, since there will be no OK button to close the messageBox.

I wrote some scripts in which I thought I was clever, using a messageBox for input like this:

This worked at the time because clicking Yes would return a value of 3, and clicking No returned 4. Now two 5-digit numbers are returned, which wreaked havoc with the subsequent syntax based on the value of nrimages. So better to go with a valueDialog method. Here's a bonus troubleshooting feature in the above example. Basically, what this sequence is doing is trying ensure that the user enters only a 4 or 6 for the input, so if he puts in anything else, the while just keeps cranking the valueDialog over and over. When I first wrote it, I had the logic like this: What this or is doing in there is causing the while command to continue until the value of nrimages is 4 AND 6 at the same time! An example of a never-ending loop, and also illustrates the trickiness of using negative tests (!=) with and and or logic.

Error-checking Errors
Here is something you may see at the beginning of many scripts:

The print command is going to send output to the console, since it would be invoked if you tried to run this script there, outside of Scribus. But look at this sequence, coming right after the above error check: If you get to this point, you have already checked to make sure this is being run inside of Scribus, but when this check for PIL fails, it's printing the error message to the console, so from the user's point-of-view, the script runs but nothing happens. So inside of Scribus you need to use a messageBox instead: