[PyKDE] RE: Problems with PyKDE2 again (long)

Jim Bublitz jbublitz at nwinternet.com
Mon Feb 11 19:37:31 GMT 2002

On 11-Feb-02 Henrik Motakef <henrik.motakef at web.de> wrote:
> I just tried to write a simple app using KParts with PyKDE2alpha3
> (basically a file viewer that loads appropriate KParts for the
> selected files). I had a few problems, that might be bugs (Note
> however that I never wrote anything using KParts before, so I
> could just be doing things wrong.)
> Back on the KStdAction topic, I wrote a simple wrapper module
> that one can use instead of KStdAction directly, that deals with
> Python slots. Probably there is a more sane way to do it, but
> until someone tells me what it is... I included a script that
> generates this module at the end of this message.

I haven't found time to look into KStdAction yet, but will keep
this on file and add it in the 'examples' section if appropriate.
> As for the problems:
> First, KCmlLineArgs.init1 doesn't seem to work. When I do
> something
> like 
>     aboutData = KAboutData("Foo", "foo", "0.1",
>                            "Useless test program",
>                            KAboutData.License_GPL,
>                            "(c) 2002 Henrik Motakef")
>     KCmdLineArgs.init1(sys.argv, aboutData)
> I get a
>     TypeError: Argument 2 of KCmdLineArgs.init1() has an invalid
> type

So do I - it's handwritten code in KCmdLineArgs that's incorrect
(probably from a recent sip change in syntax for defining parameters
passed that I didn't do correctly). Also, the way KAboutData is
used in the pykless.py example is useless because of the way the
call to KMainWindow.helpMenu is implemented (around line 70). Both
the example and KCmdLineArgs need to be repaired - I'll do those for
the next release. 

In the meantime, you can use KMainWindow.helpmenu as in pykless.py
as a workaround, or KCmdLineArgs.init will work. If you pass a
null string to 'helpMenu', the 'version' and 'description' parameter
data for 'init' will be used.
> Second, I cannot get an instance of KIO.KTrader. (It's a
> singleton with an accessor method self()). A call to
>     KIO.KTrader.self()
> results in a segfault.

KTrader isn't implemented because it depends on KService::Ptr which
in turn depends on KSharedPtr which is also unimplemented (as is
QSharedPtr, I believe). KSharedPtr depends on template classes which
sip doesn't currently handle. I'll look into a way around this, but
it will probably be a while.

KServiceTypeProfile is partially implemented (the KService::Ptr
dependent parts are also not implemented though). Is there enough
there to make your application workable? I've never done anything
with KParts either - if anyone here has, please jump in.

> The output is:
>   Trying to load /usr/home/henrik/devel/pykde/browser/pyviewer.py
> (text/x-java)
>   Getting trader
>   KCrash: crashing.... crashRecursionCounter = 2
>   KCrash: Application Name =  path = <unknown> pid = 60365
> (The first two lines are debugging output generated by me)

I'm not sure why the segfault occurs - KTrader should just throw an
error since it isn't implemented.
> Unfortunatly I don't have debugging support in my KDE
> installation (and to be honest, I don't plan to change this -
> KDE still isn't too fast even without :), so Dr. Konqi doesn't
> give me a usable backtrace. I have also included the script
> where it happens, so that interested people can try to reproduce
> it.

While there may be some KDE bugs, I won't be offended if you assume
initially that the bugs are in PyKDE2. You should be able to debug
most of this in Python.
> (BTW: If this is not an appropriate place to send such stuff, I'd
> be thankful for pointers. Sorry for the traffic)

This is the place and your input is greatly appreciated. Please
keep posting.

I'm far from being an expert on KDE, so the answers may be slow in
coming unless some user contributions are available.


More information about the PyQt mailing list