Scribusoid

Author Topic: Accessing item attributes  (Read 3482 times)

polpero

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
  • Scribus User
Accessing item attributes
« 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...

Derek

  • Newbie
  • *
  • Posts: 15
  • Karma: 0
  • Scribus User
Re: Accessing item attributes
« Reply #1 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:
  • Name
  • Type
  • Value
  • Parameter
  • Relationship
  • RelationshipTo
  • AutoAddTo

As I only needed to use Name and Value I didn't dive in any further, so can't comment further.
« Last Edit: January 30, 2021, 05:44:14 pm by Derek »

dragonfly

  • Full Member
  • ***
  • Posts: 204
  • Karma: 0
  • Scribus User
Re: Accessing item attributes
« Reply #2 on: January 30, 2021, 05:52:58 pm »

XMLCopyEditor 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.