Boilerplate.py does not work in Scribus version 1.6.4

Previous topic - Next topic

hjh

Hi

The boiler plate script given on the wiki at https://wiki.scribus.net/canvas/Boilerplate.py
does not work even if there is no change.


The error message is

````
Traceback (most recent call last):
  File "<string>", line 11, in <module>
  File "<string>", line 11
    except ImportError,err:
                      ^
SyntaxError: invalid syntax
````

The same thing happens with https://wiki.scribus.net/canvas/Scripter/Snippet/Main

How can I fix this?

Regards
Hannes


P.S. The wiki page https://wiki.scribus.net/canvas/Boilerplate.py was last edited 10 years ago an applies to version 1.4.0
(retrieved from 1.4.0 rc6 script directory)

hjh

I found a correct version of boilerplate.py  in
C:\ScribusPortable\App\Scribus\share\samples
and copied it to
C:\ScribusPortable\Data\Scripts

hjh

However if I insert

````
createText(40, 40, 100, 30, "myFirstTextFrame")
````

After "Your code goes here" and run it on a new document I get an error message that 'createText' is not defined.


So I am looking for a boilerplate.py which operates on a new blank document and inserts a single text frame.

hjh

The solution is to write

scribus.createText(40, 40, 100, 30, "myFirstTextFrame")


So the problem is solved.
boilerplate.py  in
C:\ScribusPortable\App\Scribus\share\samples

works fine with

scribus.createText(40, 40, 100, 30, "myFirstTextFrame")

added after "Insert code here"

a.l.e

I would say that the boilerplate from the wiki is a bit too complex for a default starter.

I would suggest something like this:

# encoding: utf-8
#
# (c) MIT your name
#
# Boilerplate for Scribus scripts
#
# For details see the README file.

try:
    import scribus
except ImportError as ex:
    print('This script must be run from inside Scribus')
    raise ex

def main():
    # Replace the following line by your code
    pass

if __name__ == "__main__":
    main()

I've added to my collection of scripts:

https://github.com/aoloe/scribus-script-repository/tree/master/boilerplate