Discovering an Item's Properties

From Scribus Wiki
Revision as of 07:22, 17 September 2007 by TrnsltLife (talk | contribs)
Jump to navigation Jump to search
This article is part of the Scripts series.

By selecting a Scribus object (image, line, textbox, etc.) and running this script, you can see the item's properties that are available to your script. This saves you having to dig through the C++ code, if you're not into that kind of thing.

Once you know what properties are available, you can try accessing them in your script by using the getProperty(objectName, propertyName) and setProperty(objectName, propertyName, propertyValue) functions. This lets you change quite a few more object properties than are exposed through the other Scripter API functions.

Please note that using the setProperty() function may not always have the effect your are looking for. Changing a value using setProperty() doesn't trigger any other effects that might happen when change the value in Scribus using the GUI. However, some things do work, as you can see by running these scripts:

This script has been tested in Scribus 1.3.3.9 and 1.3.4.

Save this script as ItemProperties.py, for example.

from scribus import *

if haveDoc():
    nbrSelected = selectionCount()

objList = []

for i in range(nbrSelected):
    objList.append(getSelectedObject(i))
	
for i in range(nbrSelected):
    try:
        obj = objList[i]
        props = ""
        propList = getPropertyNames(obj)
        for p in propList:
            props = props + p + " (" + str(getPropertyCType(obj, p) + "): " + str(getProperty(obj, p))) + "\n"
        messageBox("Property Info for " + obj, "Below is a property list for the selected object named " + obj + "\n" + props, ICON_INFORMATION)
    except WrongFrameTypeError:
	    nothing = "nothing"