This may not be interesting to everyone but for some people it might be helpful. It came up in conversation yesterday how annoying Maya UI building can be. PyQt makes this a bit easier I hear, but i would like to avoid recompiling for different versions of Maya if possible. I just need something quick that gets me my buttons with as little fuss as possible. So i made a custom UI class.

The class is fairly straightforward. It manages UI tasks through functions and splits the button placement into a separate overridable function addUIElements(). From here you simply call functions to create a few UI elements. For now the class supports lists, textfields, and buttons, but i’ll be adding more in the future. Each element can be created with a single function call, allowing you to create complex setups with very little code. 

The demo class and demo extension class create these 2 windows respectively: 

Note that the extension class only requires 25 lines to make all the needed changes for the additional buttons as well as declaring a  new function to list the objects in the fields. This should hopefully allow me to iterate on my tool faster rather than being forced to address the minutia of the UI.

Update 7-23 : Updated to support radioButtons, Int fields, and Float fields. Also added optional flags to tweak elements in a non default manner, such as a text field without buttons.

Update 7-24 : Minor update to support spaces in UI elements better

Source Code:

baseuiwindow.py
File Size: 9 kb
File Type: py

Download File


Leave a Reply

Your email address will not be published. Required fields are marked *