[PyKDE] Re: PyKDE useful for KDE plugins?

Jim Bublitz jbublitz at nwinternet.com
Tue Apr 23 06:02:01 BST 2002


On 22-Apr-02 Richard Jones <rjones at ekit-inc.com wrote:

> Would it be possible to use Python two write plugins for programs
> in KDE? A  specific case is Noatun, which I'd really like to
> write a decent playlist manager for. I don't know C++ well
> enough to write something like that, and I'd really rather
> avoid writing C++ in any case. Would I be able to use 
> python in this case?

I completely share your sentiments about Noatun playlists, and also
about not writing something like that in C++. I haven't looked
specifically at Noatun, but the general situation re:
plugins for the stuff I have looked at is that there are three
basic obstacles to writing KDE plugins in Python:

1. KDE plugins are libtool libraries (an .so and an accompanying
.la library) - hard to do in Python.

2. A plugin has to understand the API for the app it's being
plugged in to. That means a Noatun plugin has to have some idea
about how to interface to Noatun. In C++, that's done with .h
files. In Python that means bindings for at least some part of
Noatun.

3. A Python script has to have a Python interpreter to run.

In reverse order, (3) is easy and I have that working. How easy (2)
is depends on how you want to approach it. To do a complete set of
bindings for Noatun is probably a 100+ hour job, you'll end up
with a lib in the several MB range, and the interface may or may
not be user friendly (you'd probably want to use Python
lists/dicts easily for example) to a Python developer depending on
how Noatun is put together. The alternative is a very
lightweight/high level set of bindings - I have something similar
working for KSpread and it takes very little time once you figure
out the app's API (most KDE stuff is pretty well written too). Once
you have (2), it's maybe a few hours work to write a small C++ lib
to accomplish (1) - basically a lib that gets loaded by Noatun as a
plugin, and in turn knows how to load Python as a plugin and also
load arbitrary Python scripts and pass them to Python.

This is basically the same discussion as the one about a week ago
concerning panel applets, except that panel applets don't have the
API/bindings requirements that app plugins do.

Note that none of this has anything to do with PyKDE (but sip makes
it really easy), other than you can use PyKDE (or any other Python
module) in writing plugin scripts.

What I have at the moment is in pretty rough shape and there are
some logistical concerns (autoconf/automake, what .h files does the
end-user have to have, how to package the whole thing, etc.). In
addition I want to get PyKDE2 for KDE3.0 released first (it's not
very far off) and then get something released related to doing
plugins/panel applets as soon after PyKDE2 as possible. Right now
it looks like the memory footprint for something like this is about
1MB (with the Python interpreter being about 80% of that) - PyKDE
style bindings would be considerably larger.

You could also look at something like 'boost' (www.boost.org).
While generally I don't like the boost approach myself, it might
work well for something like this. There are probably other ways to
attack this as well - I just found doing it this way *really* easy
and hope to get back to working on it soon.

I would really like a good Python playlist plugin for Noatun and
I'd like it even better if I didn't have to write it.

Stay tuned.


Jim




More information about the PyQt mailing list