[PyKDE] Re: Help getting started with applets

Jim Bublitz jbublitz at nwinternet.com
Thu Apr 11 18:42:52 BST 2002


On 11-Apr-02 Chris Burn <chris_burn at bigfoot.com> wrote:

> Hi, I've just got PyQt and PyKDE built and it all looks good.
> I want to write a panel applet but I don't know how to get
> started. I know how in C from the tutorial : 
> http://developer.kde.org/documentation/tutorials/dot/panel-applets
> .html 
> but I can't think how to do this with PyKDE and I can't find any 
> docs/tutorials/examples for applets.

> Could anyone give me some pointers? Perhaps port the first hello
> world  example from the link to pyKDE? That would be great.

Basically everything you need is already in PyKDE2, but there are
two nasty problems to overcome: 1. You need to embed the Python
interpreter into your application for this to run (something has to
run the Python code) 2. You need to create a .so library so KDE can
load your applet.

Without going into a lot of detail at the moment, the way I'd
approach this (since I've already done something similar and know
it works) is:

a. Build a .so lib that embeds the Python interpreter (which is a
static lib) - I have this done but the build process is very
specific to my setup at the moment, so I can't distribute it easily.

b. Create a .so library following the tutorial steps for loading
your applet, but expand the 'init' function to load the Python
interpreter .so as a plugin.

I haven't looked at this very closely, but if the QString
(configFile) that's passed in will support it, it should be
possible to create a mechanism which will allow loading any Python
applet via a single general .so lib, which I can put together and
distribute with PyKDE2.

There are pretty much two options: you can pursue this yourself, in
which case contact me directly and I'll try and provide some code
to get you started, or I'll get to this but it will take some time.
I'm just getting ready to start doing my tax return, so the next 4
days are shot, and I've also started on the PyKDE2 release for
KDE3.0 final. I can try and put something together in 2 or 3 weeks,
since I have most of the pieces already. Getting the
automake/autoconfig stuff setup is the hardest part.

Another possible approach is to write the applet .so as in the the
tutorial, and have it exec Python with command line args that load
your app, but I haven't tried this.

Jim






More information about the PyQt mailing list