Experimental PyQt projects

From Scribus Wiki
Revision as of 06:02, 17 February 2005 by Ringerc (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Extension script and PyQt tricks

This page provides a place to discuss and keep track of some of the things various folks are working on with the extension script system for scribus. Currently, that's pretty much me (ringerc).

PyKde and DCOP

Scribus has a fairly good API exposed via Python. Why not try to expose *that* using DCOP, or use dcop's automatic Qt proxy to expose the underlying C++ API? PyKDE looks like it's well worth investigating.

Scribus is not a KDE application ... but dcop works fine with it anyway. One can load the dcop bindings from PyKDE then create, attach, and register a DCOP client, and things appear to work. If one launches Scribus with kdeinit scribus, then loads dcop support:

>>> import dcop
>>> dclient = dcop.DCOPClient()
>>> dclient.attach()
>>> myname = dclient.register('scribus')

it should now be possible to access Scribus's newly created dcop interface from the command line dcop client:

$ dcop
kded
klauncher
scribus-23330
$ dcop scribus-23330
qt
$ dcop scribus-23330 qt
QCStringList functions()
QCStringList interfaces()
QCStringList objects()
QCStringList find(QCString)
$ dcop scribus-23330 qt objects
qt/desktop
qt/unnamed382(QSmSocketReceiver, 0x84bdc80)
qt/unnamed382(QSmSocketReceiver, 0x84bdc80)/unnamed1(QSocketNotifier, 0x84bdd50)qt/scribus
qt/scribus/global font cache
qt/scribus/session manager
qt/scribus/default event loop
qt/scribus/toolTipManager
qt/scribus/toolTipManager/unnamed1(QTimer, 0x84c6b18)
qt/scribus/popup submenu timer
...blah blah blah...
qt/scribus/global font cache
qt/scribus/session manager
qt/scribus/default event loop
qt/scribus/toolTipManager
qt/scribus/toolTipManager/unnamed1(QTimer, 0x84c6b18)
qt/scribus/popup submenu timer
qt/_ptrpriv
$ dcop scribus-23330 qt/unnamed381 hide
$ dcop scribus-23330 qt/unnamed381 show
$ dcop scribus-23330 qt/unnamed381 slotFileQuit
call failed
$ 

You will note that a lot of objects are unnamed. I'm going to be slowly fixing that up, starting with important objects like the main window, menu bars, palettes, etc.

Note that the quit call failed. It actually quit the application fine, but of course it shut down the Python interpreter, so it was unable to reply to the dcop message. No big deal.