I have a feeling UI programming in maya will actually not suck anywhere near as much with 2011 coming along soon. I’m not 100% sure, but it sounds as though you’ll be able to use the scripted bindings for QT directly in maya for UI work in 2011. If this is true – and I’m not sure it is – then things will certainly get a lot more exciting. I’ve been restricted many times by maya’s lack of decent UI in the past, and integrating something like wxpython, while possible, is also a drag.
So anyway, this last week I was writing some UI to a tool that isn’t really finalized yet. I want to keep the UI code flexible and modular so that its easy to change it up without creating a bunch of work. Anyway if you’ve ever programmed UI using WX or QT there is this concept of events. Basically pieces of UI can listen to events of a certain kind and define a function that gets called when that widget “hears” such an event. Event driven UI’s are pretty common and make for a really powerful way of expressing action and reaction without having to make widgets aware of one another. Because you’re not defining the relationship between widgets, doing things like radically changing up UI layouts is easier to achieve.
Anyway, so I wanted something like this in maya for my mel UIs. So I made the simplest solution on the planet – which actually works out really well. Basically I have a bunch of classes I wrote that wrap the maya mel UI widgets. The base class has a sendEvent method and a process event method. The sendEvent method basically just walks up the UI hierarchy and runs processEvent with the given event args. And thats it. Super simple, but it means I can write modular UI classes, and glue them together easily, or break off a piece of UI into a separate window etc.
Previously I’ve had to have child UI hold a handle to parent UI to call update functions or vice versa which makes this sort of modularization annoying at best, impossible at worst. So anyway, super low tech simple solution – works a charm. Anyone got a better idea?
This post is public domain
This entry was posted on Wednesday, March 10th, 2010 at 22:19 and is filed under main. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.