Is there possibility how to use scribus module in python outside Scribus?

2.3k views Asked by At

I would like to generate pdf files using Scribus and python scripting. I have been looking around and have found just examples of python scripts using scribus module within Scirbus. And commentary in these scripts, that

"This Python script is written for the Scribus scripting interface. 
It can only be run from within Scribus."

When I am using command

import scribus

In python, an error occurs ImportError: No module named 'scribus'. But when I am using this command within python console in Scribus, everything is ok and I can use this module. So, Where can I found this module?

Or can I run Scribus with input parametr as python script? Something like

scribus python_script.py

I am using both linux and windows, so solution in one of these os will be great.

Python 3.3.2 & Scribus 1.4.3

3

There are 3 answers

0
Paul Sweatte On

Use the command line interface as such:

python foo.py
scribus -ns -f myfile

The Python script simply runs Save as PDF programmatically(Ctrl+Shift+P) every few seconds.

References

0
Martin Zaske On

Please have a look at the Scribus Documentation under

For Developers > Scripter API > Scripter Extensions

If you manage to write your functionality as "extension script", you can make Scribus execute it, on startup:

Scribus > File... > Preferences > Scripter > Enable Extension Scripts and select your Script.

Now, if you run Scribus from the command line (not from the Python console), it should firstly run your script and do its magic.


Sorry, I did a longer search and could not find a way to send stuff from your Python console to your OS as if it were on the command line (I believe that would give you what you asked for). That would allow you to run your script (using Scribus) from your console.

0
Alexander Baltasar On

In fact you can pass a python script as argument to scribus. But this works as far as I know only since version 1.5

Example from the scribus wiki

# only one short flag  + scribus doesnt open a document (the script itself does it)
scribus -py somescript.py --python-arg v