[scribus] recalculation of overflow is not correct

Patrick Wallace mental at mentalware.com
Tue Mar 3 09:16:29 CET 2009

Chantal on scribus-request at lists.scribus.net wrote:
> Hi, I am writing a script that loops through textboxes in a document and 
> resizes them until the frame fits.
Your script was not finished as it just attempted to add a single value 
to the height of the text frames.
I cleaned up and simplified the logic and here is a working version of 
your first draft for you to study and
continue to develop toward your goal. (You will probably want to use a 
while-loop testing OverFlowChar.)

For debugging, you cannot use print statements (you won't see them in 
Scribus), so it might be more useful to
insert scribus.messageBox() commands to see intermediate variables, etc.

Below, the script just adds 10 to the height (1,000 was way too big) and 
I have verified that
the script runs and performs as expected in Scribus 1.3.5svn.

# ---------------------------------------------------#
# check of het script vanuit scribus wordt gestart   #

import sys
   import scribus

except ImportError:
   print "This script only works from within Scribus"

pagenum = scribus.pageCount()	                        # find out how many pages we have
page = 1						# initialize at first page
InitialAddition=10                                      # define how much to add to text frames

while (page <= pagenum):
     scribus.gotoPage(page)                             # move to the current page
     ItemsOnpage = scribus.getPageItems()               # how many items are on this page
     for CurrentItem in ItemsOnpage:                    # loop all items
          if CurrentItemType == 4:                      # type 4 is text frame. We only bother with them.
             CurrentItemName = CurrentItem[0]           # get this frame's name so we can manipulate it
             OverflowChar = scribus.textOverflows(CurrentItemName)
             if OverflowChar > 0:
                   (CurrentItemwidth, CurrentItemheight) = scribus.getSize(CurrentItemName)      # get width, height
                   scribus.sizeObject(CurrentItemwidth,CurrentItemheight+InitialAddition,CurrentItemName) # increase height
     page += 1	     # increment to the next page (good programmers do this at the END of while loops)

More information about the scribus mailing list