[Scribus] Copying frame properties - with Scripter?
Sun Jan 8 19:31:39 CET 2006
Gregory Pittman wrote:
> I've been thinking about this issue of being able to copy properties
> from one frame to another, and wondering whether one could write a
> script to do this.
> As I look through the Scribus manual, though, it doesn't seem that one
> can get very many properties: if it's a text frame, one can get the
> contents, its size, various things about line spacing, font information
> (though apparently only one type per frame). For image frames, the name
> of the file, its scale. For both kinds, one can get line color/shade
> (and other attributes like join type), fill color/shade, position,
> width/height, how much rotation.
> Someone might tell me if I'm missing some important features, but I want
> to try to start by writing a script to list these, after which the next
> step would be copying selected features to another frame.
There is no good way to access or copy all, or even most, page item
properties in the current stable scripting interface.
The main Python interface is just too slow and time consuming to add
access to all Scribus's features, or even all PageItem properties, to.
Each property needs functions written and maintained. Some of these must
go out and poke other bits of Scribus as well due to the unfortunately
rather interconnected nature of the current core code. It's very bug
prone, and I personally have no plans to add more functionality to this
interface. I'll be concentrating any new scripter work on the
boost::python based scripter2 stuff. No promises, though, on how long
that'll take to be really solid - it depends to a large extent on how
well the core code cleanups go and how quickly.
Iit's now possible to copy many properties using the (very experimental
and unfinished) scripter2 interface I just mentioned. It's in 1.3cvs,
though not compiled in by default. The core code is still not in a
sufficiently sane state for me to complete that interface with the time
constraints I have, so it's a very hairy and experimental affair right
now. I know for a fact that incorrect access to some methods *will*
crash Scribus; for example, assigning an invalid font.
Allowing for that, it should be possible to copy many or most pageitem
properties with it. There might be weird effects though, and it's highly
likely that some of the changes won't show up until the document is
saved and reloaded. The scripter2 interface doesn't try to go and poke
those other bits of Scribus that need to be told when something got
changed; it's not going to be ready to use until the Scribus core can do
that job correctly its self.
There's also an earlier interface in the scripter that'll let you get at
many properties - see the getProperty, getPropertyNames, and setProperty
functions. I wouldn't recommend relying on that interface too heavily,
as once the boost::python one is done I hope to be able to remove it. It
proved too limited to allow a really generic propery access mechanism
like I was hoping. Still, it may do enough for your needs.
I realise none of these answers are at all good. There's not much to be
done about that unless Petr or I somehow find the time and inclination
to spend *much* more time on Scribus than is presently the case. I am,
of course, happy to help others learn their way around and explain
what's involved in extending the system.
It may well be possible to write a C++ function to copy a frame's
properties relatively painlessly, then wrap that for use with Python.
I'd be glad to help someone who wanted to do this in the right direction.
More information about the scribus