[scribus] Tables in 1.5.6svn - another script revision!

Gregory Pittman gpittman at iglou.com
Fri Jan 10 00:59:05 UTC 2020


It occurred to me that one might want to get this same effect of top and bottom rules even with a single frame.
One approach might be to revert to leaving out the grouping and ungrouping commands in the script and do this manually,
but this version will detect if more than one object is selected, and if so, skip grouping/ungrouping. It's an interesting 
effect perhaps fairly useful to some users, especially if you center the text vertically and use some Text Distances.
It's certainly a lot quicker than doing this manually. If you only want a line at the top or bottom, it's easy enough
to delete the unneeded line.

Even with a single object, you still need to select the top rule and move it to the bottom level after the script runs.
Note that this version uses the unGroupObjects() command as fixed by Jean in the latest 1.5.xsvn revision. Edit this to 
unGroupObject() if you're using something older.

Greg

<<begin script>>
#!/usr/bin/env python
"""
topbottomrules_2.py

Select one or more objects.
Run this script. Top and bottom horizontal rules are
created.
Afterward, select the top rule. Using Properties send this to bottom level.
Now you should be able to select individual objects.

"""
import scribus

if (scribus.haveDoc()):
    scribus.setRedraw(False)
    objects = scribus.selectionCount()
    if objects > 1:
        framegroup = scribus.groupObjects()
    else:
        framegroup = scribus.getSelectedObject()
    xpos,ypos = scribus.getPosition()
    width,height = scribus.getSize()
    topline = scribus.createLine(xpos,ypos,xpos+width, ypos)    
    bottomline = scribus.createLine(xpos, ypos+height, xpos+width, ypos+height)
    if objects > 1:
        scribus.unGroupObjects(framegroup)
    scribus.setRedraw(True)
    scribus.redrawAll()

else:
    scribus.messageBox('OOPS!','You need to have a document open',scribus.ICON_NONE,button1=scribus.BUTTON_OK)
    sys.exit(1)

<end script>>



More information about the scribus mailing list