[scribus] recalculation of overflow is not correct
Chantal Rosmuller
chantal at antenna.nl
Mon Mar 2 11:06:22 CET 2009
Hi, I am writing a script that loops through textboxes in a document and
resizes them until the frame fits. However after resizing and re evaluating
the overflow the script gives me the exact same number. How is that possible
and what can I do about it?
# ---------------------------------------------------#
# 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)
#Loop through the pages
page = 1
pagenum = scribus.pageCount()
while (page <= pagenum):
scribus.gotoPage(page)
#go to the next page in the next loop
page += 1
#and get all pageitems, this function gets
#name, obejcttype and ordre for eacht item
#
#objecttype 4 is textframe
ItemsOnpage = scribus.getPageItems()
#print pageitmes for debugging puprposes
ItemsOnpage
#count the number of items
NumberItemsOnpageTotal=len(ItemsOnpage)
#loop through items
NumberItemsOnpage = 1
while (NumberItemsOnpage <= NumberItemsOnpageTotal):
#whe have arrays of itemproperties (name, obejcttype and ordre)
#within arrays with items, first get the current itme number in the array
#current item number is NumberItemsOnpage but counting in an array
# starts with zero so subtract one
NumberItemsOnpageArraynumber=NumberItemsOnpage-1
#now move to the right item
CurrentItem=ItemsOnpage[NumberItemsOnpageArraynumber]
#the first value in the itemarray is the itemname
CurrentItemName=CurrentItem[0]
print CurrentItemName
#the secund value is the itemtype
CurrentItemType=CurrentItem[1]
print CurrentItemType
#type 4 is textbox
if CurrentItemType == 4:
print "this is a textbox"
selectObject(CurrentItemName)
OverflowChar = scribus.textOverflows(CurrentItemName)
print "initial overflow"
print OverflowChar
if OverflowChar > 0:
(CurrentItemwidth, CurrentItemheight) = scribus.getSize(CurrentItemName)
InitialAddition=1000
ItemHeight=CurrentItemheight+InitialAddition
scribus.sizeObject(CurrentItemwidth,ItemHeight,CurrentItemName)
##OverflowChar = 0
##print "overflow zero"
##print OverflowChar
scribus.selectObject(CurrentItemName)
OverflowChar = scribus.textOverflows(CurrentItemName)
print "overflow after first adjustment"
print OverflowChar
#go to the next item
NumberItemsOnpage += 1
More information about the scribus
mailing list