Scribusoid

Author Topic: setStyle does not work as expected  (Read 2051 times)

Paul

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
  • Scribus User
setStyle does not work as expected
« on: March 01, 2013, 12:17:10 pm »
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.
« Last Edit: March 13, 2013, 09:57:54 pm by Paul »

Paul

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
  • Scribus User
Re: setStyle does not work as expected
« Reply #1 on: March 13, 2013, 09: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
« Last Edit: March 13, 2013, 10:00:37 pm by Paul »

 

palmate