[scribus] Python script for scribus
Gregory Pittman
gpittman at iglou.com
Sun Dec 28 17:22:35 CET 2008
Roger wrote:
> I have been trying to get python script to past images and text into a
> page in order to automate some of the set up and page layout
> I am just learning python and wrote the following .py script from my
> gleaning of the documentation but get an error message:
>
> Traceback (most recent call last):
> File "<string>", line 8, in <module>
> File "/home/user/Scribus/scripts/setpage.py", line 61, in <module>
> scribus.loadImage(path+selectfile)
> NoValidObjectError: Cannot use empty string for object name when there
> is no selection.
>
>
> (( I have tried to hard code the imagename but get another error
> message:))
>
> Traceback (most recent call last):
> File "<string>", line 8, in <module>
> File "/home/user/Scribus/scripts/setpage.py", line 63, in <module>
> scribus.loadimage('EK_medium.png')
> AttributeError: 'module' object has no attribute 'loadimage'
>
>
> I would really appreciate help please.
>
>
> Does anyone have a .py script for putting images and text into an a4
> page, I will input box coordinates where necessary.
>
> Thanks in anticipation
> Roger
>
> ------=====------
> page script in part as follows:
>
> import sys, os, string, scribus # need to do directory and string
> manipulation also
>
> path = '/home/user/Pictures/ECK_Symbols/'
>
> os.chdir(path)
>
> selectfile = scribus.fileDialog("Select Your Image File/s", "*.*")
> #file = open(selectfile, 'r') # Same errors if open or not..
>
>
> if
> scribus.newDocument(scribus.PAPER_A4,(15,15,15,12),scribus.LANDSCAPE,1,scribus.UNIT_POINTS,scribus.PAGE_1,0,1):
>
>
> # scribus.createText(in1, in2, in3, in4) #in1 to 4 set the
> box coordinates, 12,15,12,12
>
> # from api documentation = createImage(x, y, width, height,
> ["name"]) -> string
> scribus.createImage(12, 12, 20, 20, 'eKbox') # -> string
> (Dont know what this part means, no explanation in the doc file.)
this means the commands returns a string, so you need a construct like:
imagename = scribus.createImage(12, 12, 20, 20, 'eKbox')
after which you can use imagename in a scribus.loadImage command to tell
python where to put the loaded image:
scribus.loadImage(path+selectfile, imagename)
>
> # scribus.gotoPage(1) # doesnt seem to matter in this case.
>
> scribus.loadImage(path+selectfile) # Tried this and got
> the first error
> scribus.loadimage('EK_medium.png') # This gave the 2nd error
>
second one looks like spelling error: should be scribus.loadImage
instead of scribus.loadimage
Greg
More information about the scribus
mailing list