[scribus] while loop in python script crashes scribus

Chantal Rosmuller chantal at antenna.nl
Mon Feb 9 14:51:53 CET 2009


On Saturday 31 January 2009 15:31:41 alessandro rimoldi wrote:
> ciao
>
> while enjoying this gray saturday i came up with a "cleaner" script for
> reading a text file and adjusting the frame to its content:
>
> ====== 8< ========
>
> #!/usr/bin/env python
> import sys
> try:
>    import scribus
> except ImportError:
>    print "This script only works from within Scribus"
>    sys.exit(1)
>
>
> # read the content of the file line by line into the text frame
> file_name = 'mytext.txt'
> file = open(file_name, 'r')
>
> text = "";
>
> for line in open(file_name, 'r') :
>     if line != '\n':
>         text += unicode(line, 'iso-8859-2')
>
> # create a text frame and put the text into it
> x = 60
> y = 100
> w = 300
> h = 10
>
> frame = scribus.createText(x, y, w, h)
> scribus.setText(text, frame)
>
> # resize the frame in 10pt steps
> while (scribus.textOverflows(frame) > 0) :
>     h += 10
>     scribus.sizeObject(w, h, frame)
>
> # undo the latest 10pt step and fine adjust in 1pt steps
> h -= 10
> scribus.sizeObject(w, h, frame)
>
> while (scribus.textOverflows(frame) > 0) :
>     h += 1
>     scribus.sizeObject(w, h, frame)
>
> ====== 8< ========
>
> since i am at home now, i could check it in scribus... and it does work*!
>
> i've also posted the script to the wiki: feel free to make a working script
> out of it!
> http://wiki.scribus.net/index.php/Adjust_a_text_frame_to_fit_its_content
>
> ciao
> a.l.e
>
>
>
> * well, it does not work in today's 1.3.5svn, but i've posted a fix for
> PageItem::frameOverflows() in the bug tracker: the second try could be the
> good one :-)
>
> _______________________________________________
> scribus mailing list
> scribus at lists.scribus.net
> http://lists.scribus.net/mailman/listinfo/scribus

Hi allesandro, this script crashes my scribus as well, could that be a version 
issue? I use 1.3.3.11




More information about the scribus mailing list