[PyKDE] Re: Kcontrol modules.

Jim Bublitz jbublitz at nwinternet.com
Thu Jul 10 08:35:01 BST 2003


On Wednesday July 9 2003 15:20, David Boddie wrote:
> Following up to this again as things change...
>
> On Tue, 8 Jul 2003 20:21:21, Simon Edwards 
<simon at simonzone.com> wrote:
> > I had a look at the IOSlave code and saw that it works quite
> > differently than kcms. Kcms are basically shared libraries
> > that have a factory method that returns a instances of a
> > subclass of KCModule.
>
> Well, I've managed to get kicker to load a shared library and
> call the C++ "init" factory function as normal. This starts a
> Python interpreter, looks for the relevant Python module,
> imports it then calls the "init" function in the module. The
> "init" function creates an instance of the KPanelApplet
> subclass and returns this to the C++ function.
>
> -> C++ "init"
>    ...
>            -> Python "init"
>               ...
>                       -> AppletClass.__init__
>                          ...
>               applet  <-
>               ...
>    pInstance <-
>
> The instance is then converted to a pointer using
>
>     panel_applet = (KPanelApplet*)sipMapSelfToThis(pInstance);
>
> which is returned to the caller. Kicker (or its applet loading
> proxy) then crashes, rather unhelpfully failing to provide a
> traceback.
>
> Any ideas on what I'm doing wrong would be good at this point.

sipMapSelfToThis returns sipThisType*, which is a ptr to a 
struct. You probably want sipThisType->cppPtr (at least it is in 
3.5 - its in siplib/siplib.c). Alternatively, it's a little 
simpler to use:

KPanelApplet *sipForceConvertTo_KPanelApplet (
   PyObject  *,int *)

eg:

#include <sipkdeuiKPanelApplet.h>

int isErr = 0;
panel_applet = sipForceConvertTo_KPanelApplet (pyObj, &isErr);

if (isErr) {
<handle error>
}

and link to libkdeui (in site-packages).

You might not be this far along, but will your method allow 
someone to choose one of several panel applets written in Python 
using the same .so file for each? In other words, does each 
applet require a .so file, or is there a common .so file and 
users just write applets strictly in Python?

Jim




More information about the PyQt mailing list