PDA

View Full Version : Design patterns for dynamic GUI building



gruszczy
17th July 2008, 21:30
I would like to ask, if you know any solid design pattern for dynamic gui creation. Description of user interface is kept in a xml file and a simple model is created basing on this description. Then a GUI (mostly a form, but with a few additional custom-made widgets) should be built from this model.

Right now every part of the model and the model itself (each part represent usually represent some kind of a input field) has getWidget method, which calls a factory that returns properly built widget. Model recursively calls its parts and returns whole, large widget. I don't like it, because model knows something about the GUI, which isn't something I would like to have. On the other hand, I just can't iterate through objects, because I would need to ask for a type of every part of the model - that sucks too. And I even can't cheat a little and use overloading, since it's python. What's more when I use external factory I don't have all the information about the editor which will keep the input widgets. I thought about giving the editor functions, that will add input widgets to itself, but this just doesn't seem right.

Did anyone do such thing and has observations or know any good solutions to this problem?

caduel
17th July 2008, 22:07
QUiLoader?

gruszczy
18th July 2008, 10:59
I'd rather use some more generic design, that depend on entirely on qt solution. I might need to add code for different GUI library. That's why I would like to use some less concrete design, that I can easily implement with other libs.

Anyony tried such thing or knows how to do this?

EDIT: OK, I think I'll just use a Visitor and treat editor itself as visitor walking through the model.