[PyKDE] Re: Kcontrol modules.
Phil Thompson
phil at riverbankcomputing.co.uk
Thu Jul 10 20:55:01 BST 2003
On Thursday 10 July 2003 7:25 pm, David Boddie wrote:
> On Thursday 10 July 2003 07:29, Jim Bublitz wrote:
> > On Wednesday July 9 2003 15:20, David Boddie wrote:
> > > 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 *)
>
> That's helpful, thanks.
>
> I've since been on a detour, wrapping the KPanelApplet methods manually,
> but then I discovered sipConvertToCpp which I'm using in the following
> manner:
>
> int iserrp;
> PyClassObject *class_obj;
> PyObject *base_objs, *base_class;
>
> class_obj = ((PyInstanceObject*)pInstance)->in_class;
>
> base_objs = ((PyClassObject*)class_obj)->cl_bases;
>
> base_class = PyTuple_GetItem(base_objs, 0);
>
> panel_applet = (KPanelApplet*)sipConvertToCpp(
> pInstance, base_class, &iserrp
> );
>
> The result of this class hacking is a space for an applet on the panel and
> a handle for it (but this happens even when the Pythen part of it has
> crashed). With the manual method, I managed to get an applet to open an
> About dialog but this is taking longer with the above approach.
Instead of base_class you should use sipClass_KPanelApplet. The above won't
work if you are using a (Python) sub-class of KPanelApplet. Or use
sipForceConvertTo_KPanelApplet as Jim suggested which is just a wrapper
around the above.
Phil
More information about the PyQt
mailing list