[scribus] scribus file format / python

wibr lists at wibr.de
Tue Jul 5 18:41:12 UTC 2011


Am 04.07.2011 23:14, schrieb Gregory Pittman:
> On 07/04/2011 02:45 PM, wibr wrote:
>> Am 04.07.2011 20:22, schrieb Gregory Pittman:
>>> On 07/04/2011 01:41 PM, wibr wrote:
>>>> Hi,
>>>>
>>>> so I would like to use Scribus to create some flashcards. It should
>>>> work
>>>> like this:
>>>> 1. I have a .txt file with my flashcards
>>>> 2. I create two pages in Scribus how they will look like, one for each
>>>> side of the flashcards
>>>> 3. I will do some python magic, load the .txt and create many pages
>>>> with
>>>> flashcards.
>>>> 4. I can edit the cards if I want or just export them to pdf.
>>>>
>>>> So here is my question: Should I manipulate the xml or let the script
>>>> run in Scribus?
>>>>
>>>> I think editing the xml shouldn't be too hard, but I don't completely
>>>> understand the file format, is there any recent documentation
>>>> available?
>>>> Especially I would like to know how I could duplicate pages.
>>>> I had a look at it: <PAGE> is a page and it gets a number NUM, and
>>>> <PAGEOBJECT> is something on a page and it has an attribute "OwnPage".
>>>> So I tried to move pageobjects between pages by editing the "OwnPage"
>>>> number, but that didn't work...so how does Scribus know, which object
>>>> belongs to which page?
>>>>
>>>> Or maybe using python in Scribus would be easier? I am more familiar
>>>> with xml editing, though...
>>>>
>>>
>>> Hi Wilhelm,
>>>
>>> I would start by manually making a few cards, so that you can work out
>>> document page size, what sort of font, font size and style, spacing,
>>> etc., you want to use.
>>>
>>> After that, I would be inclined to use a script inside Scribus to make a
>>> document from a text file, so that you can create pages as needed, with
>>> frames, paragraph styles and so on.
>>> You might make it less demanding on the scripting end by just putting
>>> text into new frames on as many pages as needed, then applying the
>>> styles in Scribus later.
>>> Here is a simple script showing some of the methods:
>>> http://wiki.scribus.net/canvas/Importing_addresses_from_a_text_file
>>>
>>> Having said that, it's worth making a 2-page document, then looking at
>>> the SLA file to see how much work it would be to generate a file using
>>> python outside of Scribus. I sense that you have a long way to go to
>>> understand what parts of the file are used for various aspects of the
>>> document. Even if you know xml, I think you'll find an SLA file
>>> challenging.
>>>
>>> Another approach /might/ come from using text filters, but then I think
>>> you would need to deal with the problem of making new pages and
>>> frames...
>>>
>>> Greg
>>>
>>> ___
>>> Scribus Mailing List: scribus at lists.scribus.net
>>> Edit your options or unsubscribe:
>>> http://lists.scribus.net/mailman/listinfo/scribus
>>> See also:
>>> http://wiki.scribus.net
>>> http://forums.scribus.net
>>>
>>
>> Hi Greg,
>>
>> thanks for the quick reply.
>>
>> To be a bit more specific:
>> I don't want to create the whole document in python. Let's say I want 8
>> flashcards on each DinA4 page. So I create two pages in Scribus, instead
>> of the flashcard text I use dummy text like $def1 and $def2, everything
>> formatted nicely like I want.
>> The only thing I want to do with python is opening the xml, knowing
>> exactly where the two pages are. Then I will just copy those pages as
>> many times as needed, always replacing the dummy text with the real
>> flashcards.
>> I did something like that with svg and Inkscape once and it worked out
>> very well. So I don't need or want to understand the whole Scribus xml,
>> I would just need to know how the pages work.
>> However, I will also look at the scripter API.
>
> I think this is going to be problematic, now that I look at the SLA
> files. The page parameters happen one after another as <PAGE ..../>
> tags, and contain some elements that relate to their position in the
> document, PAGEYPOS for one.
> After this comes a series of <PAGEOBJECT .../> tags, assigned to a
> particular ordered page, but also having some elements that are absolute
> distances from the top of the first page. You also may get conflicts
> with naming the frames the same as you copy.
>
> How about this instead:
> Make your 2 pages. Select all the objects on each page and save in the
> Scrapbook as 2 separate objects, named so you remember which is which
> for even-odd pages.
> Now insert as many blank pages as you want. For each odd page,
> right-click the odd-object in the Scrapbook, and one option will be
> Paste to Page, and it will be pasted at the same coordinates as the
> original. Do the same for the even pages/even-object.
>
> This shouldn't be so much work.
>
> Greg
>
> ___
> Scribus Mailing List: scribus at lists.scribus.net
> Edit your options or unsubscribe:
> http://lists.scribus.net/mailman/listinfo/scribus
> See also:
> http://wiki.scribus.net
> http://forums.scribus.net
>

Hi Greg,

thanks for your suggestions. I had a look at the Scripter API and found 
that I could duplicate my pages using the importPage() command. Not the 
fastest way probably, but I don't see any "duplicatePages()" command. So 
I played around with it and I think it should do the job, together with 
some getPageItems(), set/getText(), ...

Wilhelm



More information about the scribus mailing list