[Scribus] different paragraph-Styles from scripter (1.3)

Craig Ringer craig
Fri Oct 21 09:34:05 CEST 2005


Ralf-Diether Ebel wrote:

> setText("ABC"+chr(13),ob)  #chr(13) should be paragraph -or?

That's exactly equivalent to:

   setText("ABC\r")

though it's more common to use:

   setText("ABC\n")

Scribus doesn't appear to care about the difference.

> setStyle("Style1,ob)
> insertText("DEF",-1,ob)
> selectText(4,3,ob)
> setStyle("Style2,ob)
> 
> Regardless what I do, the whole frame has always the same style, 
> normaly the last applied.

Yep. setStyle(...) will only apply its effects to a selection if no 
object target is given. I realise that's surprising, but it's consistent 
with the rest of the API, and until/unless we can perhaps provide a more 
OO API it's likely to stay like that.

Unfortunately, that doesn't seem to be working right now. I'm unsure of 
why that is. It seems to be a problem with selecting the text range 
rather than with applying the style, as if I hand-select the range it 
all works fine. I'm using current "great breakage" CVS not anoncvs, so 
it's entirely possible this is a problem you won't have. Please let me know.

On a side note, would you find something like this more friendly 
(extended example):

doc = scribus.documents.currentDocument()
ob = doc.newTextFrame(100,100,100,100,doc.currentPage)
ob.text = "ABC\nfred\n"
par0 = ob.selectText(0,3)   # select first paragraph
par0.style = doc.styles["fred"]
par1and2.style = doc.styles.defaultStyle()
ob.text += "More text\n"
ob.paragraph[2].paragraphStyle = doc.styles["wilma"]

?

Frames could also be acccessed by name, eg:

doc.frames["barney"]

and manipulated by properties, eg:

doc.frames["barney"].text = scribus.documents["MyDoc"].frames["barney"]

plus it should be possible to do things like use slices to make 
selections on frames and work with the selection, though that's require 
a much more flexible concept of "selection" than the Scribus core 
presently has:

ob.pars[1:3].style = "dinosaur"

There are lots of fun possibilities for making scripting more intuitive 
and "python-like". With Boost::Python it might not even be insanely 
painful to implement ;-)

If I ever find myself landing on about a billion years of free time and 
sort out the other things I really need to do in the Scribus core code 
(encoding fixes, FileLoader plugin work, etc) that's what I'm really 
hoping to put in place with the approval of Petr and all you folks who 
use the scripting API. Look reasonable?

--
Craig Ringer




More information about the scribus mailing list