Python on the Side

12/13/2001

While browsing KDE Dot News the
other day, I saw some Python software listed in the Recent Software
section. It led me to four
small applications by Doug Bell: ConvertAll, a unit conversion
program; FlyWay, a route planner for pilots; rpCalc, a reverse polish
calculator; and TreeLine, a simple tree structured information storage
program. Written with Python and PyQt, they all looked sharp. The
code was clean and easy to understand if not heavily commented. They
were my favorite kind of small application to learn from. I called
Doug to ask him about the programs. Turns out he isn't even a
programmer by trade.

"I'm a mechanical engineer," Doug tells me. "I work for a company
that designs handheld radios." He doesn't use Python in his work at
all, it's just something he learned in his spare time. "I use it more
as a departure from my work." He learned C in college and
later taught himself C++. "For a little while I was playing around
with MFC. From there I started using linux and discovered Qt, using
it with C++. At that point I started wondering why I ever used MFC!"

The FlyWay program was originally written in C++ using Qt. When he
began learning Python about a year ago, he changed it around. He said
it was easy to pick up PyQt, since he already knew Qt with C++. And
moving from C++ to Python was easy as well. Doug said, "When you have
already written something in C++, translating it to Python is fairly
quick." Though his four programs have been around in one form or
another for a while, they were only made publicly available under the
GPL in the last couple of months.

I thought his layouts looked clean. I asked if he used any special
layout tool to put them together. He said, "No, I used to use a
layout tool back in my MFC days, that's about the only way to do it
with MFC. Using PyQt, I like the way you can resize all the dialogs
automatically and have them come out the right way. That's why I
primarily hand code them rather than using a layout tool."

I haven't tried to write cross platform programs myself, but all of
Doug's applications are available on both Windows and Linux. Curious
how Qt lived up to its cross platform claims, I asked him how it went.
"I have been very impressed with Qt. At first I just had them running
on Linux, but when QT came out with its non-commercial edition for
Windows, everything that ran on Linux pretty much ran on Windows." He
said, "Some printing code was different, but Qt 3.0 is supposed to
improve that."

"Porting from Linux to Windows is what turned me on to Qt." Doug
said. "I looked at wxWindows and Tk as well, but they didn't perform
as well." He used rpCalc as a test, writing it in each interface. He
decided he liked Qt the best. I asked about wxWindows, which many
people seem to like. "The wxWindows version was kind of the opposite
of Qt in terms of how it ported, the behavior under each platform was
different. I think this is because wiWindows doesn't do the rendering
itself but relies on the underlying system for rendering. It wasn't
just cosmetic differences, some of the widgets operated differently,
and I didn't want to have to write separate code for both systems."
Using py2exe to
package the windows zip files, Doug said putting together Windows
versions of his applications was easy. "It's nice to give a Windows
user an .exe and support files, rather than requiring them to install
Python."

My favorite of the four programs is TreeLine. It stores data
hierarchically. I suppose that isn't much different from the way a
filesystem stores files, but it's a bit less messy with little
tidbits of information, and it can spit out your data in HTML or
tabbed title text, making it a handy outliner. Doug explained "I had
seen other outliner's, similar programs, for example TreePad on Windows. My goal with
TreeLine was to come up with a Linux version of TreePad. When I had a
command line version that handled text, I used it as a mini-database
that I could export to HTML. Playing with it, I got the idea that
combining database functions with treeline would be a good idea."

Not just good code examples, Doug's applications are fully
functional and useful. They show off PyQt very nicely as well as the
power of Python in general. Doug tells me he has some enhancements in
mind for TreeLine, so keep your eye on his site.