[PyKDE] KTrader woes?

Jim Bublitz jbublitz at nwinternet.com
Thu Sep 11 04:30:01 BST 2003


On Wednesday September 10 2003 17:45, Sundance wrote:
> I heard Jim Bublitz said:

> I assume that it is not expected to work outside a
> KApplication, then? Maybe there should be a way to raise an
> exception rather than crash when this is called outside a
> KApplication...? 

You'd have to talk to KDE and TrollTech about that - that's 
built-in behaviour in the KDE/Qt C++ libs. Some things do throw 
an exception/error msgs, like trying to use widgets without a 
QApplication/KApplication instance exisiting (although the msg 
usually complains about a missing QPainter instance). I would 
imagine KTrader is looking for some other connection the 
KApplication establishes with KDE.

> That was the behavior I expected anyway, so
> when I tried the KTrader trick on its own I assumed that it
> would either 1) work on its own, or 2) require some
> QApplication-like class to have been instanciated, in which
> case it would warn me.

> Guess I was wrong about the 'warn me' part.

Nah - you got a segfault. Just not a very delicate warning. :)

> > There are a couple of programs in examples/ that use KTrader
> > (pyParts.py, pyParts_1.py don't work too well at the moment
> > though). If you run examples/mimetype.py, the OfferList tab
> > results are from a KTrader call -- does that work?

> It does.
> I rewrote my little example above adding a KApplication
> instanciation just before the call to KTrader.self().query,
> and it works, whee!

> Well, more precisely, it works if I copy the KCmdLineArgs.init
> line from mimetype.py. If I call KApplication([], "SomeName")
> it dies. Apparently KApplication REQUIRES a non-empty list as
> its first argument, unlike QApplication (with which the []
> trick works).

PyKDE-3.8 (rc releases are at 
http://www.sourceforge.net/projects/pykde) has a bunch of 
application templates you can use to get started.

> Alright, so. Erm. :) I may be wrong about this as well, but I
> still sort of think there are more elegant ways to let the
> user know he's done something wrong than crash the full
> interpreter. =)

> Is there any way we can help make it so?

Seems pretty difficult - my guess would be the most appropriate 
route would be a tutorial/better docs/more example programs - 
that's in the works, but takes a while to accomplish. The KDE 
libs classref docs are pretty good, even if C++ oriented. You 
find them at http://www.kde.org in the documentation section, 
along with a lot of tutorial stuff.

Jim





More information about the PyQt mailing list