[scribus] recalculation of overflow is not correct

Chantal Rosmuller chantal at tmcr.nl
Tue Mar 3 15:51:09 CET 2009


On Tuesday 03 March 2009 09:16:29 Patrick Wallace wrote:
> 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
> try:
>    import scribus
>
> except ImportError:
>    print "This script only works from within Scribus"
>    sys.exit(1)
>
> 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 CurrentItemType=CurrentItem[1]
>           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,Curre
>ntItemName) # increase height page += 1	     # increment to the next page
> (good programmers do this at the END of while loops)
>
>
>
>
> _______________________________________________
> scribus mailing list
> scribus at lists.scribus.net
> http://lists.scribus.net/mailman/listinfo/scribus

Sorry but this is not working, I used your script but added the print commands 
like this and the overflow does not change. You can see the output of print 
if you use the script console. If you use while instead of if scribus 
crashes, but that is ofcourse because the overflow value never becomes 0






import sys
try:
   import scribus

except ImportError:
   print "This script only works from within Scribus"
   sys.exit(1)

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
          CurrentItemType=CurrentItem[1]
          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)
	     print "before"
             print OverflowChar 
             if OverflowChar > 0:
                   (CurrentItemwidth, CurrentItemheight) = 
scribus.getSize(CurrentItemName)      # get width, height
                   scribus.sizeObject(CurrentItemwidth,CurrentItemheight+InitialAddition,CurrentItemName) 
# increase height
		   OverflowChar = scribus.textOverflows(CurrentItemName)
		   print "after"
		   print OverflowChar 
     page += 1       # increment to the next page (good programmers do this at 
the END of while loops)






More information about the scribus mailing list