Scribus Forums

Scribus => Scripts and Plugins => Topic started by: polpero on May 10, 2015, 10:54:16 pm

Title: Accessing item attributes
Post by: polpero on May 10, 2015, 10:54:16 pm
Hi

Is there a way (with scripter) to access a frame attributes as defined in rightClick on frame -> attributes...?
I would like to retreive data from the value and parameter fields...

I know how to access the frame:

Code: [Select]
...
    while (page <= pagenum):
        scribus.gotoPage(page)
        d = scribus.getPageItems()
        strpage = str(page)
        for item in d:
            if (item[1] == 4):
                rawname = item[0]
                ...

but not how to get the value inserted into it's attributes
is this possible?

Thanks...
Title: Re: Accessing item attributes
Post by: Derek on January 30, 2021, 05:39:33 pm
I realise this topic is more deceased than Monty Python's dead parrot, but I couldn't find any documentation about accessing attributes and kept finding myself back here, so if this stops someone else joining me in my rabbit hole, here's what I found ....

Attributes are stored as a dictionary, and can be accessed using (example snippet):

Code: [Select]
attributes = getObjectAttributes(item[0]) # Get list of attributes for item
for attribute in attributes: # For each attribute in current item
    if attribute.get('Name') == "TOC": # If the attribute name is "TOC"
        tocList[attribute.get('Value')] = page         # Add/update the value of the attribute to/on the tocList
        ...
        ...

Fields which can be accessed are:

As I only needed to use Name and Value I didn't dive in any further, so can't comment further.
Title: Re: Accessing item attributes
Post by: dragonfly on January 30, 2021, 05:52:58 pm

XMLCopyEditor https://xml-copy-editor.sourceforge.io/ (https://xml-copy-editor.sourceforge.io/) can open any *.sla file (which is XML format).  Attributes can be inspected. But of course you can use other methods like scripting.