[scribus] Setting character style in a Python Script

Julius Cordes julius at julius-cordes.de
Mon Mar 21 16:28:52 UTC 2016


Hi Greg,

Thank you for your answer.

 > > Is it possible to add a function `setCharStyle` to the next stable
 > > release of Scribus?
 > I don't know the answer to that question (we keep talking about
improving Scripter).

You're talking about Scripter2? As far as I know it may be included in 
1.6 but since 1.6 seems far away I try to do this with the current 
stable branch.

 > What you might consider in Python is to create a function with a
 > collection of text properties that you call within your script and apply
 > to some selected text. This is more or less what a character style is 
doing.

This works but that is exactly what I try to avoid – from my point of 
view it's no optimal solution (changes on the character style are not 
applied on the text) – the build in html import handles character styles 
(e.g. the `strong` element) this way.

I took a look at the 1.4.6 source code and found out which files contain 
the scripter code responsible for applying the styles and fonts to the text:
  * scribus/plugins/scriptplugin/cmobj.cpp
  * scribus/plugins/scriptplugin/cmdobj.h
  * scribus/plugins/scriptplugin/scriptplugin.cpp

Inspired by `setStyle` and `setFont` I tried to build a function named 
`setCharStyle` but didn't succeed (character style is applied to the 
entire text frame instead to the selection or code didn't compile...). 
I'll put my changes on the code and error messages together and post it, 
maybe someone is able to locate my mistake.
Where should I post it? At <forums.scribus.net> or the developer 
mailinglist?

Thanks.
   Julius



More information about the scribus mailing list