[scribus] Problems with setStyle() and some more...

yakup çetinkaya yakup.cetinkaya at gmail.com
Fri Oct 22 22:07:31 CEST 2010

Hi list,

I am trying to build an automated layout engine to be used in newspaper
design. This is actually a school project for me, but thinking of the
repetitive and low-intellectual processes in the laying out of newspapers, I
thought of sharing such a script could be useful for a lot of people.
Note that the images and titles are excluded here, only the body text with
subtitles is counted for focusing on the issue at hand : )
Below is a simplified version of my script, the problem emerges in the
Estimator class where i try to set the size value of each NewsElement
instance. The dictionary called "switch" is distinguishing text items and
image url's with a convention i used in the sourceText.

class Estimator:
    def __init__(self):
        names = []
        for n in newsList:

            this = names[-1]
            for s in n.body.styleIndex:
                print s[0],s[1],s[2],this
                scribus.setStyle(s[2], this)
            l = scribus.getTextLines(this)
             print 'lineCount:', l
            n.size = l

class NewsElement:
    def __init__(self):
        self.body = BodyElement("")
        self.size = 0

    def appendToBody(self,body,style):

class BodyElement:
    def __init__(self,data):
        self.data = data
        self.styleIndex = []

    def append(self,data,style):
        l = len(self.data)
        self.data += data
        s = [l,len(data),style]

def news(data):
    n = NewsElement()

def header(data):

def first(data):

def para(data):

def slant(data):

def question(data):
    newsList[-1].appendToBody('\n+ '+data,'ps_body')

def answer(data):
    newsList[-1].appendToBody('\n- '+data,'ps_body')

def bullet(data):
    newsList[-1].appendToBody('\n* '+data,'ps_body')

def pas(data):

class docBasics:
    def __init__(self):
        self.unit = scribus.UNIT_PICAS
        self.pageSize = (1080,1584)
        self.pageMargins = (36,36,60,48)
        self.contentSize =
        self.columnGap = 12
        self.baseLine = 15
        self.numPages = 20
        self.defCols = 5
        self.colWidth =
        self.basePath = "/home/yakup/scribus/AGOS/"

switch = {
"?" : news,
"*" : subtitle,
"^" : first,
"&" : para,
"/" : slant,
"+" : question,
"-" : answer,
"!" : bullet,
"" : pas

newsList = []
doc = docBasics()

def getTextFromSource():
    source = sourceText.splitlines(1)
    for line in source:

est = Estimator()

With the outcome, the most evident problem is that the setStyle() command in
the Estimator class only seems to be working for the first and the last
paragraphs, even though the start and count indexes and style names are
printed correctly for each item.
The second issue is the getTextLines() method is returning 0, no matter if I
put it before or after the styling loop or the hyphenate() command. So I
fail to get any estimations for my NewsElements to start the pagination
I am using Scribus v1.3.8 on Ubuntu 10.10.

Any help is appreciated.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scribus.net/pipermail/scribus/attachments/20101022/32b4cb8d/attachment.htm>

More information about the scribus mailing list