Last week I came across a few websites that were dealing about dynamic generation of Winforms in IronPython.
I’m not much into code-generated UIs, because it’s easy to get two or three controls on a form, but as soon as you have a dozen, it can be a nightmare to lay them out properly only with code. For example, it might need several tries to get a decent width for your text boxes, or a pleasing height for your lists. When using a WYSIWYG UI editor, at least you’re playing with the real thing, and save a lot of time on the design process.
On the other side, I’m not much into the Visual Studio way of doing UIs (aka “mouse click hell”), where it’s so tempting to put your logic behind the form, because that’s the way it expects you to do it.
The best way of designing forms I know is how Qt does it:
- design your interface in a WYSIWYG, drag-n-drop designer
- save it in a programming language agnostic format (Qt uses XML)
- translate it into a module in your favorite programming language, through a specialized compiler
- import it in your application
- now you can plug it to your application logic
I wanted to use the same flow in .NET, but that was not possible … until introduction of WPF and Xaml format.