[scribus] centering text vertically in a frame

ale rimoldi ale.comp_06 at xox.ch
Thu Jul 5 20:00:02 UTC 2012


hi greg,

i've used your script to do a test round of the new scripter!

the result is a dozen of bug reports, a couple of patches and one new
script that almost works!

--- 8< ---

import sys

if not Scripter.activeDocument:
    # scribus.messageBox('Scribus - Script Error', "No document open", 
    Scripter.dialogs.alert("A document must be open.")
    sys.exit(1)

document = Scripter.activeDocument

#Scripter.activeWindow.setRedraw(False) # TODO
if document.selectionCount == 1:
    item = document.activeItem
    # TODO check if it's a text frame or exit
    if item.textOverflows == False:
        line_n = item.textLines
        distance_lrtb = item.distances
        # print distance_lrtb
        distance_lrtb[2] = (item.height - (item.textLines *
item.lineSpacing)) / 2
        item.distances = distance_lrtb
    else:
        Scripter.dialogs.alert("The text frame should not overflow.")
else:
    Scripter.dialogs.alert("Please only select one text frame.")

#Scripter.activeWindow.setRedraw(True)

--- >8 ---


... probably, we will be showing it next week at the Rencontres
mondiales du logiciel libre (http://rmll.info) in geneva :-)

however, as you can see the new syntax is much more compact and
clean... but there will be a lot of work to do to port all the old
scripts to the new scripter.


have a nice evening
a.l.e



More information about the scribus mailing list