[scribus] while loop in python script crashes scribus

Chantal Rosmuller chantal at antenna.nl
Fri Jan 30 13:29:41 CET 2009


<snip>
> i wonder if it has to do with the fact that you delete and create the
> text frame on each iteration...
>
> have you tried to use sizeObject() ?
>
>
<snip>

Hi, thanks. Although your suggestion makes sense (I  didn't know about 
sizeObject() ) it stilll crashes, here 's the new version:


# ---------------------------------------------------#
# 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)

#----------------------------------------------------#
# declareer variabelen                               #
#----------------------------------------------------#


VerticalPosition = 100 #verticale positie eerste textbox tov, voor de volgende 
wordt het uitgerekend aan de hand van de hoogte
Width = 325.99 #text box width
Height = 50 #initial text box height
VerticalMarge = 10 #afstand tussen de tekstboxen
TextFile='' #tekst file dat geimporteerd moet worden

Page = 0 # bladzijde, we beginnen bij 0
Add = ''
OverflowChar = 0 #overflowing characters, we will adjust textbox height until 
this is 0

#----------------------------------------------------#
# actie                                              #
#----------------------------------------------------#



if scribus.newDoc(scribus.PAPER_A5, 
(51.02,42.52,42.52,53.86),scribus.PORTRAIT, 1, scribus.UNIT_POINTS, 
scribus.FACINGPAGES, scribus.FIRSTPAGERIGHT):
    # laad stylen
    TextFile = open('/home/chantal/scribus/wiki.txt', 'r')
    while 1:
        info = TextFile.readline()
        if not info: break
        if info != '\n':
            Add = Add + info
        else:
		#maak textbox
		TextBox = scribus.createText(60, VerticalPosition, Width, Height)
		VerticalPosition=VerticalPosition+VerticalMarge+Height
		#vul de textbox
		scribus.setText(Add, TextBox)
		#check of alles wel past
		OverflowChar = scribus.textOverflows(TextBox)
		while OverflowChar > 0:
			Height=Height+100
			sizeObject(Width,Height,TextBox)
			OverflowChar = scribus.textOverflows(TextBox)




More information about the scribus mailing list