wxPython Form Builder

Recently I've been involved in a large scale user interface rewrite for one of our products. The long and short of the story boils down to needing to rewrite code that's essentially unmaintainable in its current state as generated by a developer who's no longer with our company.

We started by investigating existing solutions for UI Design in Python. wxGlade is probably the most notable, but I found its generated code to be overly verbose, its default naming schemes to be cumbersome, and I generally disliked the idea of a new .wxg project file that I'd need to go back to when making layout changes.

I also reviewed and tested XRCed. While closer to what I was after (it parses XML to generate the UI Layout) it still wasn't quite what I had in mind. It did give me some great ideas regarding object structure and layout in general. If you're fond of XML you should definitely check it out.

In the end, I rolled my own solution. Sometimes that's overkill, and sometimes that means you get what you need out of the project. In my case, it's been mostly the later, with a bit of the former mixed in.

I'd like to lead with the disclaimer that the form structure these declarations use grew from some demented corner of my mind. For that reason, there are times where I've conglomerated some of the options for sizers together with some of the options for the actual elements. Initially that may seem confusing, but I found that it allowed me to centralize my declarations in a way that benefitted me long term. I also made the decision to process parts of this structure by type (dictionaries represent a single element, tuples represent rows which can contain one or more elements, and lists represent grids - they typically contain one or more tuples (rows) which in turn contain dictionaries (columns)). Depending on your design background this may seem counter intuitive or overworked. If so, I'm interested in feedback, but you're also under no obligation to use these classes and they work for what we're doing.

Below then, are examples of the Forms generated using this combination of classes.  The four forms demonstrated are all available in the FormsDemo attachment.  The Ordered Dictionary is necessary if you're using Python 2.6.

Examples

Archive to Folder

Filter Action

General Settings

PCL 2 PDF Conversion

AttachmentSize
FormDemo.py.txt27.56 KB
odict.py.txt46.84 KB

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage

NewMessage