[scribus-dev] Need help with python script

Gregory Pittman gpittman at iglou.com
Thu Dec 18 15:38:35 UTC 2014


On 12/18/2014 08:49 AM, John Culleton wrote:
> On Wed, 17 Dec 2014 19:09:32 -0500
> Gregory Pittman <gpittman at iglou.com> wrote:
> 
>> 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.
>>
>> _______________________________________________
>> scribus-dev mailing list
>> scribus-dev at lists.scribus.net
>> http://lists.scribus.net/mailman/listinfo/scribus-dev
>>
>>
>> _______________________________________________________
>> Unlimited Disk, Data Transfer, PHP/MySQL Domain
>> Hosting http://www.doteasy.com 
> Thanks for your comments. Yesterday I had a
> program that ran, based largely on spine.py. It
> delivers a doc with the right dimensions. I am
> surprised at my success with a language I have
> never used before, even with wholesale copying
> from other people's programs.
> 
>  Three things need fixing. I need to figure out how to
> put the blue lines in the right place to mark
> off the spine area. You offered a solution above.
> I need to get the commentary lines at the bottom
> of the script to work correctly with my data. And
> it would be nice if the data entry fields were on
> one window instead of a series of windows. 
> 
> Today I have a column to write (It's my
> deadline), a dog to take to the vets (maybe) and
> finish preparation for the annual family party on
> Sunday.
> 
> Maybe tomorrow?
> 
> Where in the manuals(online or printed) would I
> find some extra guidance on these matters?
> I looked but did not find. 
> 
In the online manual (F1), look under For Developers > Scripter API.
The detail and presence of examples is limited. Beyond that, going to
the wiki and looking at various example scripts that show more
specifically how to use the various commands is sometimes essential.
Make sure you go back to the online manual, though, to make sure some
command hasn't changed (like the deprecation of newDoc()).

Greg



More information about the scribus-dev mailing list