On Fri, 2005-01-14 at 08:54, Gregory Pittman wrote: > I've looked at the sample python scripts, and I have to say that they do > not seem very instructive. > It would be nice to seem some constructs that show, for example, 'here > is how you set up a page with a text frame with this content and an > image frame with that content'.
It's really mostly a matter of getting the samples together. I think it'd be fantastic if more folks would submit useful scripts they've written to be included as samples, so we get a more comprehensive base of examples for people to look over. I think Kobus Wolvaardt posted something similar to what you've described a while ago. I've also written a script like that (though it pulls the content from a database), but it's currently unfinished - I can't make it actually work how I want until there's a way of getting basic string/text metrics in the scripter. > Is it possible to use qt commands in python with scribus? There are commands in the scripter for accessing some pre-wrapped Qt functions, such as the standard Qt file dialog, input dialog, and message box. If you have an idea for another dialog that you think would be useful for scripts, or need a base Qt dialog that's not available from Python, please mention it because it may well be simple to add. It's not possible to use the Qt toolkit, with PyQt or any other interface I know of, to build your own interface in python scripts running under Scribus. It may never be for normal scripts because of interactions between the way Scribus runs Python scripts and the way PyQt loads. It's also not necessarily a good idea for normal scripts, because you can crash Scribus with PyQt. The safest and most portable option for custom GUIs in scripts remains Tkinter. That said, I have PyQt working here, and support for it is part of the macro patch. That's all been delayed because of my "real-work" workload, but is really almost finished now - I'm just writing the documentation. If anybody is interested in trying the patch out, there's a preliminary version at http://www.postnewspapers.com.au/~craig/scribus/scripter_macros_08.tar.bz2 (applies to a clean 1.2.1 tree). Testing, comments and screams of horror would be appreciated. I don't know if the patch will be accepted for 1.2.x (or at all) but I do hope so. The PyQt support added by the patch relies on running scripts in a different mode (called "Extension scripts" in the patch) where they're not protected from each other and don't clean up automatically after each other. Technically, "extension scripts" are run in the main interpreter, not in a temporary sub interpreter for each script - it's a bit like a shell script that "source's" other scripts instead of executing them as separate programs. Most importantly, they share the same global namespace. Because of this, and because PyQt gives you the dubious ability to crash Scribus if you do something silly, more caution is required when coding than for basic scripts. Also make sure to use modal windows for your UI (you don't have to, but it's more complex if you don't - an explanation will be in TFM when its finished). I'd like to provide a simpler Qt GUI interface for scripts that just loads .ui files and lets you manipulate them, and have one partly written - but the remaining issues are proving very hard for me to solve (grr stupid C++ grr :-P ) and it's extremely limited in its current form. So, again, Tkinter remains the safest and most portable option. -- Craig Ringer
