[scribus] centering text vertically in a frame

Gregory Pittman gpittman at iglou.com
Thu Jul 5 21:32:50 UTC 2012


On 07/05/2012 04:00 PM, ale rimoldi wrote:
> 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.
>
I'm glad to see someone other than me who likes short scripts!

Greg



More information about the scribus mailing list