setStyle does not work as expected

Previous topic - Next topic

Paul

Hi,
I have made a script in Scribus 1.4.0 that reads a text file and inserts the text with several different paragraph styles.
However, the setStyle( ) function changes not only the selected text, but the whole text.

Fragments of de script are:
     story = scribus.getSelectedObject(0)
     ...
     scribus.selectText(line3end+1, line4end, story)
     scribus.setStyle("EB-titel")

How can I change the paragraph style of only a part of a text, e.g. selected text?
Any ideas? Thanks.

Paul

#1
I found the solution myself:
the setStyle function also needs a reference to the frame and after setting the style, the selection must be deselected, so that the next selection will be independent from the first selection. The size of the selection can be set simply to 1 character to set the whole paragraph.

The working script is: 
     story = scribus.getSelectedObject(0)
     ...
     scribus.selectText(line3end+1, 1, story)
     scribus.setStyle("EB-titel", story)
     scribus.deselectAll()

Cheers, Paul