char styles in scripts

Previous topic - Next topic

hvfrancesco

hi, I' facing a problem related to Char styles:
I can create styles in scripts, and they appear in available styles inside scribus, with every parameter set as expected, but I'm not able to find a way, if there is one, to apply a Character style to a text frame programmatically in a script, if I try to use something like:
scribus.setStyle(name_of_style, name_of_textframe)
I just get an error reporting that such style does not exist.
I can't find much about it in scripting documentation, can anyone point me in the right direction?
best to all
francesco

Nermander

I think that it is not possible to apply a character style to a whole frame, I think you need to apply a paragraph style.

dave61430

Good, I asked the same question, namely how do you apply a paragraph style in a script, so how does one. Is there any documentation on this, I couldn't find much.

Nermander

Did you not notice "scribus.setStyle(name_of_style, name_of_textframe)" in the original post in this topic?

hvfrancesco

Quote from: Nermander on March 29, 2013, 05:21:59 PM
I think that it is not possible to apply a character style to a whole frame, I think you need to apply a paragraph style.

I feared something like that. that's a pity, it would be quite handy not to have to apply manually character style to a huge amount of text. Hope it can be adressed sometimes in the future, I don't see a reason to limit the setStyle only to paragraph styles, as you can create programmatically character styles, it would be perfectly logic having a way of using them too.

hvfrancesco

I've been looking briefly and superficially at scribus code in svn repo.
setStyle() deals actually only with paragraph style, though it should not be too hard to implement a setCharStyle() function.
The thing that puzzles me is that the style stuff is in the API in 1.4 branch, but I was not able to find it in trunk, so, is it supposed to get removed from the API in coming scribus implementations?

dave61430

Sorry, Nermander, yes I do see setStyle and have tried it, but get an error. Bear in mind I've never used Python. The problem seems to be in the arguments.
This is what I am trying:
scribus.setStyle('House Number','Text Frame')

House Number is the name of the style. There is no name for the text frame except that generic.
Isn't this stuff more fully documented somewhere, sorry if I seem a bit dumb in all this.

dave61430

OK, I've got it to run without error, line is scribus.setStyle('House Number',item[0]) so I'm half way there. Problem is style is not modified!! It sees the style name since when I modified it I got a style not found message.

hvfrancesco

shame on me!
I just now realized that char styles are used in definition of paragraph styles, so it perfectly makes sense to only have paragraph styles applied through te API.
sorry for the useles noise on the forum and for not reading properly the docs.

dave61430

Also as I found out, after applying a paragraph style, the properties box (or whatever you call it, f2 thing), will show no style for the frame. However, it does have the style and will update if you change the setting from the style menu (f3). This caused me some confusion. I assume there is some bug in the properties thing, since you get the same failure to correctly display the style for objects retrieved from the scrapbook.

hvfrancesco

Quote from: dave61430 on April 06, 2013, 06:05:58 PM
Also as I found out, after applying a paragraph style, the properties box (or whatever you call it, f2 thing), will show no style for the frame. However, it does have the style and will update if you change the setting from the style menu (f3).

yes, same here, I confirm