[PyKDE] KTrader woes?
Jim Bublitz
jbublitz at nwinternet.com
Sat Nov 1 09:09:00 GMT 2003
On Friday October 31 2003 09:55, Paul Evans wrote:
> Sundance sundance_at_ierne.eu.org:
> >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).
> sorry if this has been fixed in newer versions than the 3.7-3
> version - I haven't been able to follow some of the discussion
> on the topic (c++).
I looked into this a little and:
> I recently had to change one program from QApplication to
> KApplication to support a kde widget and found that not only
> does it require a non-empty list as Sundance noted,
Yes - the list has to be non-empty.
> but there
> can only be One element in that list or it will fail on
> 'Unexpected argument '.
That's correct behavior.
It simply means you haven't specified any command line options,
which is done via KCmdLineArgs.addCmdLineOptions (the PyKDE
version is different than the KDE version - uses a dict to pass
the options as tuples).
> Of course, the program still works
> fine when its main class is instantiated from another script
> with args.
That's another possibility if you'd rather use Python to process
cmd line args. Or just use Python to process the options in the
same script, but before instantiating KApplication or calling
KCmdLineArgs.init.
> I got around it by passing [sys.argv[0]] to KApplication when
> run stand-alone. This way it starts fine and the main class
> can pick off the args it needs. However, the kde crash handler
> kicks in when the program exits now.
I don't get a segfault using sys.argv or [sys.argv [0]] or [""]
(has to be a list of strings). SuSE and RH - no Mdk running at
the moment; KDE 3.0.3, 3.1.0, 3.1.1. The test program doesn't do
much though.
> Sorry if this is fixed, I can certainly handle it for the time
> being until I upgrade. If not, can you suggest a proper cure
> over my work around?
See previous post - there's a note in the KDE classref docs to
the effect that the ctor you're trying to use (with cmd line
args passed) should be removed because it "causes crashes" due
to not calling KCmdLineArgs::init. I don't know if that's
correct or not, but it works with as noted above.
I'd recommend using the second method in my previous post -
calling KCmdLineArgs.init. The next release will have a number
of simple program templates, and all but one are written that
way. It seems to be the way KDE wants to go in the future. It's
5 or so extra lines of code.
Jim
More information about the PyQt
mailing list