Author Topic: char styles in scripts  (Read 3828 times)

hvfrancesco

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
  • Scribus User
char styles in scripts
« on: March 29, 2013, 11:44:17 am »
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

  • Hero Member
  • *****
  • Posts: 1218
  • Karma: 15
Re: char styles in scripts
« Reply #1 on: March 29, 2013, 06: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.

dave61430

  • Jr. Member
  • **
  • Posts: 53
  • Karma: 0
  • Scribus User
Re: char styles in scripts
« Reply #2 on: March 29, 2013, 08:05:31 pm »
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

  • Hero Member
  • *****
  • Posts: 1218
  • Karma: 15
Re: char styles in scripts
« Reply #3 on: March 29, 2013, 08:25:41 pm »
Did you not notice "scribus.setStyle(name_of_style, name_of_textframe)" in the original post in this topic?

hvfrancesco

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
  • Scribus User
Re: char styles in scripts
« Reply #4 on: March 29, 2013, 08:40:01 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

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
  • Scribus User
Re: char styles in scripts
« Reply #5 on: March 29, 2013, 09:18:52 pm »
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

  • Jr. Member
  • **
  • Posts: 53
  • Karma: 0
  • Scribus User
Re: char styles in scripts
« Reply #6 on: March 29, 2013, 10:47:24 pm »
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

  • Jr. Member
  • **
  • Posts: 53
  • Karma: 0
  • Scribus User
Re: char styles in scripts
« Reply #7 on: March 30, 2013, 12:53:50 am »
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

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
  • Scribus User
Re: char styles in scripts
« Reply #8 on: April 06, 2013, 01:43:40 pm »
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

  • Jr. Member
  • **
  • Posts: 53
  • Karma: 0
  • Scribus User
Re: char styles in scripts
« Reply #9 on: April 06, 2013, 07: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). 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

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
  • Scribus User
Re: char styles in scripts
« Reply #10 on: April 06, 2013, 09:14:40 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