[scribus-dev] Need help with python script
Gregory Pittman
gpittman at iglou.com
Thu Dec 18 00:09:32 UTC 2014
On 12/17/2014 04:11 PM, JLuc wrote:
> Hello
>
> great project !
>
> In
> http://wiki.scribus.net/canvas/Generate_a_ten_page_layout_with_three_columns_on_each_page
>
> i see
> newDoc((185, 250), (12, 20, 15, 28), PORTRAIT, 1, UNIT_MILLIMETERS,
> FACINGPAGES, FIRSTPAGELEFT)
>
If you look at the online manual, you can see that newDoc is deprecated.
Use instead newDocument().
If you use the preferred statement* early in your script:
import scribus
then remember to tell python where to look for commands and constants
with a prefix of 'scribus.', for example:
scribus.newDocument((width, height), (0.25, 0.25, 0.25, 0.25),
scribus.PORTRAIT, 1, scribus.UNIT_INCHES, scribus.PAGE_1, 0, 1)
where width and height are your values for your cover. I am presuming
that even though the width may be larger than height, you want a
PORTRAIT orientation to most easily work with the cover.
The (0.25, 0.25, 0.25, 0.25) specifies margins and could all be zeros if
you don't want any. These parenthetical groups of values are how you
present tuples to the scribus command.
Note that this command returns a boolean response, so you might have
if (scribus.newDocument(...............)):
followed by some things you might want to do to the document, like
adding the vertical guides.
Make vertical guides with:
scribus.setVGuides([v1, v2, v3, ...])
where these represent the distance in your page units from the left edge
of the page. The brackets denote that these values are part of a python
list.
As you may know, instead of the obligatory ';' that Perl uses at the
ends of lines, Python uses nothing. Instead it is very strict about the
use of indentation to understand the structure of your script.
Greg
*You may also see some scripts on the wiki begin with
from scribus import *
which allows you to use commands without the prefix, but what it does is
load all of Scribus's python commands, which really isn't necessary.
More information about the scribus-dev
mailing list