PyKDE2: KDE Bindings for Python03/21/2002
Jim Bublitz recently announced a beta version of PyKDE2, providing Python programmers access to high level widgets of the 2.x and 3.0beta versions of the K Desktop Environment. Phil Thompson, the maintainer of Sip, a tool for generating Python bindings from C++ code, and PyQt, the Qt bindings for Python, had made a set of KDE 1.x bindings way back a couple of years ago when he first created PyQt. He continued to maintain Sip and PyQt, but never got round to updating PyKDE.
Jim Bublitz used PyKDE for KDE 1.x to create a custom email client for for his electronics brokering business. He liked KDE's high level widgets, like the editor and html widgets, both useful in a mail client. When it was clear a new version of PyKDE wasn't coming, Bublitz pitched in to make it happen. "I kinda got suckered into it," Bublitz jests. "Phil said just do the bits you need and I or someone else will pick up the rest. Well, it turns out you can't do it that way, you have to do the whole thing at once pretty much."
I asked Bublitz what the work was like. "You start out with the header files for KDE," he told me, "and make changes to them so Sip can understand them, like stripping out variable names, writing some small bit of handwritten C++ code to handle variables passed by reference or template classes, which are unsupported by Sip. Once you have modified the header files 80-90% of the work is done automatically. The rest is just touching things up, getting things to work."
He got the first few libraries working by June of last year. "To get some of the other stuff working Phil had to do some modifications of Sip, like name space support and a couple of other things. It wasn't until the end of summer we got all that nailed down. About November I got the first release of PyKDE out."
"Phil is really the brains behind the operations," said Bublitz. I've done almost all the work on KDE, but when I get stuck I fire off an email to him and he either modifies Sip or gives me a pointer on where to go. I have never met him or talked to him, but it's been a good collaboration."
There's still some work to be done in this version. Recent modifications to Sip will enable to Bublitz to tie up a few things, but Bublitz says the only class he hasn't yet covered is kcrash. In the future he wants to figure out how to write plug-ins, or kparts with Python. Bublitz says, "to do that, you currently have to have C++ or a libtool compatible library, you can't generate those from Python."
For now, Bublitz has created four tarball packages of PyKDE, one contains generic source code and a build program to build specific packages for KDE 2.1.x, 2.2.x and 3.0 beta. The other three are prebuilt versions for 2.1.x, 2.2.2, and 3.0beta2. For 2.2.0 or 2.2.1, you are supposed to be able to generate a build from the generic tarball. I gave this a try on a system that is still 2.2.1, but I ran into some problems. I should probably upgrade KDE on that system, but I have been holding out for 3.0.
For machines that match one of the prebuilt source distributions, however, installation is as simple as configure;make;make install. Then you can start adding all those fine high level KDE widgets to your python applications. If your a Linux developer and haven't yet done any programs with PyQt, PyKDE2 should sweeten the deal for you.
To top off the Qt/KDE news, OpenDocs just announced Boudewijn Rempt's Gui Programming with Python: QT Edition is shipping. You won't find it in bookstores right a way, but you can order it from Linux Ports, and then read it online, while you're waiting for it to arrive.
Stephen Figgins administrates Linux servers for Sunflower Broadband, a cable company.
Read more Python News columns.
Return to the Python DevCenter.