[scribus] createCharStyle: and apply

José Antonio Rocha joseantoniorocha at gmail.com
Mon Sep 5 18:39:23 UTC 2011


> Nonetheless, Cédric is right, even though you can create a style you cannot apply it with a script.

Yes, we can apply it in selected paragraph. No problem. This snippet
show functions that do the job:

APPEND = -1  # -1 append text to frame

###################

def applyStyle(style,story):

    '''Try apply style to selected text. If style doesn't exist, create it.'''

    try:

        scribus.setStyle(style, story)

    except:

        scribus.createParagraphStyle(style)

        scribus.setStyle(style, story)

    return story


###################

# Insert text and
 format paragraph

def formatParagraph(textBegin,text,style,story):

    '''Insert text and format paragraph.'''

    paraLen = len(text)

    scribus.insertText(text, APPEND, story)

    scribus.selectText(textBegin, paraLen-1, story)

    applyStyle(style, story)

    # Hyphenate if style is in hyphenation list

    if hyphenate.count(style) != 0:

        scribus.hyphenateText()

    return paraLen



------------------------------
nome: "José Antonio Meira da Rocha"
googletalk: email: MSN: joseantoniorocha at gmail.com
veículo: [ http://meiradarocha.jor.br ]
------------------------------



More information about the scribus mailing list