[Scribus] help need taking first steps in scripting

Craig Ringer craig
Tue Mar 21 10:53:06 CET 2006

On Sun, Mar 19, 2006 at 06:31:35PM +0000, Ananga ---- Antony Brand wrote:
> I am working at the console on Scribus 1.3.2 on Win XP and I'm starting to
> get the hang of things. Just a few questions that I'm hoping someone here
> will be able to answer.
> What is the difference between createPolygon and createPolyLine ?
> I have been using the following command and it seems to work okay.
> createPolygon(     [  0,0,    4,0,     4*(1.412/2) , -4*1.412     ]     ,
> "quad")
> How do I modify the command to:
> 1    change the colour fill shade to 0%
> 2    change the opacity to 0%
> 3    change the line width to 4pt
> 4    change the line edges and endings to round join and round cap
> respectively

Use subsequent calls to the appropriate API functions (as shown in the
documentation) to alter the attributes. For example,
setLineWidth(newwidth, "objectname") . See:
http://docs.scribus.net/index.php?lang=en&page=scripterapi-setobjprop , 
help(setLineWidth) in the Python interpreter, or Scribus's on-line help.

> Is it possible to use a script to define these as a style as I have a lot of
> polygons/lines to create?

Not currently - there's no exposure of line styles for scripting. You
can just define a function to apply the desired attributes though. The
function can take the object name as a parameter, and pass that to the
calls, or can just work on the current selection, depending on how you
prefer to do it.

> The script always creates the polygon using the top left corner of the page
> as the origing even if I manually reset the origin to the middle of the
> page. Is there a way of creating the object with respect to the actual
> origin on the page chosen by the user?

I don't think so. That'd make the effect of a script dependent on GUI
settings, something I think is undesirable. If that was supported, it'd
need to be accompanied by a call letting a script save and restore the
origin point so it could guarantee reproducable runs.

> When I make the jump to making script files, what does the first line need
> to be?
> #!/usr/bin/env python seems to apply for Linux users but not for PC, what
> would be the equivalent PC command or is that line not strictly necessary.

You can not run a Scribus script directly from the shell by
double-clicking etc. It must be run in-process by Scribus via the Script
menu. An initial line like:
	#!/usr/bin/env python 
will be recognised by text editors for syntax highlighting purposes and
is a hint to readers that the code is Python, but for Scribus scripts is
otherwise unnecessary. You should however be sure to include a
-*-coding-*- line (as should be described in the documentation).

Craig Ringer
GPG Key Fingerprint: AF1C ABFE 7E64 E9C8 FC27  C16E D3CE CDC0 0E93 380D

More information about the scribus mailing list