[scribus] Insert image as header into Scribus page

Gregory Pittman gpittman at iglou.com
Fri Dec 26 15:05:40 CET 2008


Roger wrote:
>
>
>
>
> Subject:
> Insert images with .py
> From:
> Roger <hovergo at net-tech.com.au>
> Date:
> Fri, 26 Dec 2008 17:54:00 +1100
> To:
> scribus-request at lists.scribus.net
>
> Attempting to create a .py script to set up new newsletter page/s each 
> issue.
> I have the same images for header and sub headers saved as .tiff and .jpg
>
>
> From <help><scripter API><Setting Object Properties>
>
> loadImage(...)
> loadImage("filename" [, "name"])
>
> I have /setpage.py starting with Craig's address .py script as an 
> example to learn from:
>
> selectfile = scribus.fileDialog("Select Your Image File/s", "*.*")
> file = open(selectfile, 'r')
>
> # newDocument(size, margins(lrtb), orientation, firstPageNumber, unit, 
> pagesType, firstPageOrder, numPages) -> bool
> # newDocument(PAPER_A4, (10, 10, 20, 20), LANDSCAPE, 7, UNIT_POINTS, 
> PAGE_4, 0, 1)
>
> if 
> scribus.newDocument(scribus.PAPER_A4,(15,12,15,15),scribus.LANDSCAPE,1,scribus.UNIT_POINTS,scribus.PAGE_1,0,1): 
>
>
>     scribus.gotoPage(1)
>     scribus.loadImage(file,["header"])
> # where "header" is the name of the image box at the top of the page.
>
> I get error message:
> Traceback (most recent call last):
>   File "<string>", line 8, in <module>
>   File "/home/roger/Scribus/scripts/setpage.py", line 59, in <module>
>     scribus.loadImage(file,["header"])
> TypeError: coercing to Unicode: need string or buffer, file found
>
> --What am I doing wrong and how to fix please
Not quite sure how you're going about this.
If you are creating a new frame for your header, you will need a 
construct something like:

                        f = scribus.createImage(xframe, yframe, pwidth, 
pheight)
                        scribus.loadImage(imagename, f)

where you create the frame and assign it to this variable name, f in 
this case.

If you are using  an already existing frame, you would do something like 
this:

                        scribus.selectObject(nameofobject)
                        scribus.loadImage(imagename) #obviously, your 
selected object better be an image frame!

In the API, the brackets [] are there for optional parameters, so if 
you're selecting a frame, you shouldn't need to add the second parameter 
in the loadImage command.
(I don't have the time right now to check out this selectObject method, 
but that is my understanding of the syntax looking at the info in Scribus)

Greg




More information about the scribus mailing list