Tuesday, December 21, 2004

RAD with Python, wxPython and Boa constructor - Part 3

Here's the third essay in a three part series on using Python, wxPython and Boa Constructor to rapidly develop cross-platform desktop applications.

Last time, we discussed wxPython, the GUI toolkit we're using to create rich, cross-platform user interfaces from Python. Now wxPython is great, but like almost all such toolkits, it's a royal pain to code up an interface using it. The code which deals with creating and managing the UI is usually very verbose and it's boring, tedious work. The drudgery of trying to get your buttons set up just so by repeatedly changing the relevant positioning variables and running the script, is positively mind numbing. What we need is a way to graphically setup the interface and have the code to recreate it generated automatically...

Enter Boa Constructor (just Boa from now on).

To quote from it's website, Boa is "...a cross platform Python IDE and wxPython GUI Builder. It offers visual frame creation and manipulation, an object inspector, many views on the source like object browsers, inheritance hierarchies, doc string generated html documentation, an advanced debugger and integrated help..."

Pretty impressive.

So what's to like?

  1. GUI Construction - This is the main reason I use Boa. Create a new frame, click on frame designer and away you go. Drag visual elements like list boxes, buttons and text areas in and throw them around until they look the way you want them to. You can access the attributes of the various visual elements by bringing up the inspector and change just about everything to do with the widget. You can also automatically generate place-holder callback functions and fill them up with the relevant code later. Boa really makes GUI construction a breeze.
  2. Code Exploration - Boa comes with some nice tools that help you explore other people's code; or your own if you're as lazy about commenting as I can sometimes be! :-). Just open up the .py file and tab over to Explore in the editor and you can browse the various classes and their attendant methods. Mosey over to Events and you can check out the various events handled in that file as well.
  3. Skeleton Files - Boa generates a wide variety of skeleton files which help reduce the amount of tedious typing you have to do. You can generate everything from wizards to setup files to help files, all at the click of a button.
  4. Debugging - Boa has extensive support for debugging Python code. However, python is so easy to use that I've never had to use a debugger to solve any problems. Yet :-P.

So much for the cheerleading.

Boa is currently at version 0.3.1-alpha. Now version numbers hold very little meaning across applications. I trust FireFox 1.0 a hell of a lot more than I trust Internet Explorer 6.0. Boa is fairly stable and useful, but it does have it's short comings.

  1. Ugly - Boa is ugly enough to make children cry, horses faint and women snort and rear up, pawing at the air. OK, that may be a little harsh... but it is pretty damned ugly. Now I know that shouldn't make a difference. Book covers and internal beauty and all that PC crap. But personally, I like working on applications which don't remind me of the bleeding, infected sores on a lepers back.
  2. Doesn't support latest version of wxPython - The official stable release of wxPython is still version 2.4.2.4. However, wxPython version 2.5 is stable enough to use regularly and has some nifty new features. Unfortunately, Boa refuses to work with 2.5 so all that's out.
  3. So-so editor - One of the main modules in any IDE is the code editor. It has got to be perfect, or as close to perfection as you can get... and Boa's just can't hack it. Now that's partly my fault. I'm an Emacs addict and it's chords are burnt into by muscle memory. When I want to save a file, I do C-x C-s without even thinking about it. Unfortunately, Boa's editor doesn't let me re-set shortcut keys, so when I do a C-a to move to the head of the line, I end up selecting all the text in the program and losing my place in the code. If it had offered code completion and other goodies, I still might have used it; but it doesn't, so I don't.
  4. Slightly buggy - This is still alpha code. Weird 'stuff' will happen, usually when you haven't saved your code in a while.
  5. Ugly - Did I mention that Boa is really really ugly?

Now as I mentioned in the beginning, I primarily use Boa to rapidly generate GUI code. What would take me days to do manually can usually be done in scant minutes using Boa. However, that also just about all I use Boa for 'cause I can't stand it's editor and looking at it makes my eyes bleed (which is a little surprising cause wxPython GUI's usually look quite reasonable).

If Boa isn't your cup of tea, you might want to check out Spe (Stani's Python Editor) which seems to offer similar functionality.

Well that concludes this particular series of essays. See you next time.

Same Bat Blog.

Same Bat Time.

No comments: