[Scribus] Scribus features and python scripting
Craig Ringer
craig
Fri May 20 07:33:10 CEST 2005
On Fri, 2005-05-20 at 01:07 -0400, Marvin Dickens wrote:
> I've read all of the info on the WIKI regarding python scripting. It's good
> info, but rather sparse. Question: Are all of the features of python
> available for use when scripting in Scribus?
Yes, with a few limitations:
- Threading probably doesn't work (it does with PyQt's threading,
but not built-in Python threading, and Qt limitations make it not
very useful in Scribus anyway).
- Modules and libraries that want to have exclusive control
of the event loop will cause problems for scripts that you want
to continue to run while the user works (you can work around the
problems but it's kinda gross). Examples include PyQt, Tkinter,
and Twisted.
- GUI scripts are "interesting". Tkinter works best for plain
scripts, PyQt (used carefully) for scripts that continue to run
while the user works.
There's a little more info on this topic in the Scripter FAQ.
Please report any other issues you encounter, Python features you can't
use inside Scribus, etc.
> If not, what features of the
> python language are excluded? Are there features within Scribus that cannot
> be accessed using python?
A fairly significant proportion of Scribus's features cannot be accessed
from Python. This is being improved, but as the current method involves
considerable hand-coding and delving into the (currently rapidly-
changing) guts of Scribus, it's slow going. Both Petr and I have largely
stopped writing individual new individual API functions in 1.3 and are
seeking a way to do things that's practical to build and maintain as the
app grows (Currently, I'm eyeing Qt4's improved meta-object magic).
> Are there any "Gotcha's" or other surprises?
If you find any not mentioned here or in the docs, please drop in on
IRC, post about it, or file a bug.
> Is there information/documentation regarding this subject that I have missed?
> It's obvious that python and Scribus play well together, but I don't know what
> the limits are (Although, I'm sure they exist).
The main limitation you will hit is with Scribus features not yet
exposed via Python. Some include:
- GetText and access to most other plug-ins is not yet possible
(this will be fixed in 1.3.something).
- Some PageItem properties/parameters can not be accessed or
manipulated. Sometimes it's easy to add support for missing ones
when encountered, sometimes it's ... er ... really not. This will
probably be the most significant limitation you encounter.
- There are no text metrics to let you find out "how wide will this
string be in this font", "will this line fit in this frame", etc.
- You can't (yet) trigger GUI events that haven't been specifically
implemented for the scripter (eg file open, file save have been) in
scripts without doing some scary-but-fun PyQt hacks
Also:
- Scripts "take control" of Scribus while they run; the app will
appear to have "locked up". It is crucially important to use
the progress meter and status bar to indicate to the user that
all is well and work is progressing.
- Scripts that continue to run while the user works, eg to provide
new palettes or tools, are somewhat tricky to write and I
*STILL* need to finish the documentation.
I'm interested in hearing how you go, what improvements you think would
be good, what problems you find, etc.
--
Craig Ringer
More information about the scribus
mailing list