[PyKDE] KFilePlugins, using Python from C++ code and vice versa

David Boddie david at boddie.org.uk
Thu Aug 31 22:35:33 BST 2006


On Thu Aug 31 12:59:20 MEST 2006, Joachim Werner wrote:

> quite a while ago I asked if anybody had working examples of KFilePlugins
> written in Python, but I got no answer. I guess the reason was that there
> are no such examples.

Probably.

> So let me rephrase the problem:
> 
> What I want to do is prototype a metadata pluging for KDE that can fetch
> file metadata from a server instead of reading the files.

Or you could just write it in Python rather than merely prototyping it. ;-)

[Details of the architecture and what the plugin would do.]

> KFilePlugins are available in PyKDE, but the missing piece for me is how to
> register them. Usually, KFilePlugins are referenced by name in a .desktop
> file, and the matching dynamic library is loaded when needed.

Yes, lots of plugins in KDE need a shared library, a libtool library file
(with a .la suffix), and a desktop file.

> So the question is how I can do that with PyKDE. Do I have to write a
> wrapper dynamic library in C++ that calls my Python code? If yes, how?
> (An example would be fine.)

Unfortunately, the answer is yes. Fortunately, this has been done many times
by people reading this list, just for different types of plugins to the one
you want.

The most established set of tools and libraries for doing similar things is
Simon Edwards' PyKDE Extensions package:

  http://www.simonzone.com/software/pykdeextensions/

As far as I can tell, the plugin will need a factory function more like the
one for Control Centre modules than the one for kioslaves, so you should
probably find the code for that in the above package and start with that.

If you get stuck, I can probably send you something to help you get started,
but it won't use the standard DistUtils infrastructure like the PyKDE
Extensions do.

Good luck!

David




More information about the PyQt mailing list