Scribus Forums

Scribus => Scripts and Plugins => Topic started by: Paul on March 01, 2013, 11:17:10 AM

Title: setStyle does not work as expected
Post by: Paul on March 01, 2013, 11:17:10 AM
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.
Title: Re: setStyle does not work as expected
Post by: Paul on March 13, 2013, 08:57:27 PM
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