Experimental PyQt projects: Difference between revisions
(add link to dcop startup script) |
(pointers to docs, PyKDE discussion) |
||
Line 3: | Line 3: | ||
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). | 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 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. | ||
Line 59: | Line 59: | ||
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. | 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. | ||
Here's a [http://www.postnewspapers.com.au/~craig/scribus/dcop_startup.py python script] you can use as a startup script in Scribus to dcop-enable it when it loads. Make sure to either run Scribus with <code>kdeinit</code> or start the <code>dcopserver</code> before Scribus loads, because it needs to be able to register with the dcop server when it first starts up. If you use this script, you'll have a new name | Here's a [http://www.postnewspapers.com.au/~craig/scribus/dcop_startup.py python script] you can use as a startup script in Scribus to dcop-enable it when it loads. Make sure to either run Scribus with <code>kdeinit</code> or start the <code>dcopserver</code> before Scribus loads, because it needs to be able to register with the dcop server when it first starts up. If you use this script, you'll have a new name <code>dcop_client</code> in the global namespace - this can be accessed from the script console and from extension scripts. | ||
Be aware that most of the KDE stuff will require a KApplication instance, which doesn't exist with Scribus. So while DCOP works (at least the qt bridge), large chunks of PyKDE probably won't. Still, it should be fun to find out what can and can not be done. The <code>kdecore</code> module is probably a good place to start. | |||
The [http://developer.kde.org/documentation/library/3.3-api/dcop/html/index.html dcop documentation] is probably going to be of interest to folks reading this. It's all C++ based, but not too hard to translate to Python. The [http://developer.kde.org/documentation/library/3.3-api/ KDE Developer Library] might be useful too. |
Revision as of 07:05, 17 February 2005
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.
Here's a python script you can use as a startup script in Scribus to dcop-enable it when it loads. Make sure to either run Scribus with kdeinit
or start the dcopserver
before Scribus loads, because it needs to be able to register with the dcop server when it first starts up. If you use this script, you'll have a new name dcop_client
in the global namespace - this can be accessed from the script console and from extension scripts.
Be aware that most of the KDE stuff will require a KApplication instance, which doesn't exist with Scribus. So while DCOP works (at least the qt bridge), large chunks of PyKDE probably won't. Still, it should be fun to find out what can and can not be done. The kdecore
module is probably a good place to start.
The dcop documentation is probably going to be of interest to folks reading this. It's all C++ based, but not too hard to translate to Python. The KDE Developer Library might be useful too.