Maya UI (ELF) wrapper

This UI wrapper was originally created to avoid PyQt installation (and instability) and I recently had the chance to do some bug-fixes and port it to Maya 2010.

What it does is use simple maya UI elements (from the cmds module) but wraps them in a more user friendly and editable way. This is not much to see but it’s to use! Using form layouts in an automated way saves the headache of making things work and align neatly and comes with a nice perk: you can have row-layouts with a dynamic number of columns (because they are actually form layouts).

Alltogether this makes interface code less long and more logical wrapping the static native Maya UI system (to be fair: this system is old and pretty decent, but the amount of exposed API is extremely limited. So for a third party, like me and probably you, it is very hard to use.

Click to get a zip:

PythonUI

Run the install to add the extracted folder to the pythonpath, go into ElfUI/icons/ to find another useful BAT example: drag a PNG on it to get an XPM out of it – > you do need to open it and edit it to point to the right path though (this assumes x64 maya 2010, default location, as you will notice once you open it).

Last but not least, have a little example script that inherits a window and adds some elements into it:

import ElfUI


class UI( ElfUI.Window ):
    def __init__(self):
        super(UI, self).__init__('Easy interface.')
        self.size = [200,300]
        
        self.collapsable = ElfUI.FrameLayout(self, self.layout, 'File list')
        ElfUI.Label(self, self.collapsable, 'Label 1')
        ElfUI.Label(self, self.collapsable, 'Label 2')
        
        self.header = ElfUI.RowLayout(self, self.layout)

        btnA = ElfUI.Button(self, self.header, 'A', None, [16, 32], 'Prints the letter a!')
        btnA.AppendClicked(self._PrintA)
        self.header.AddChild(btnA)
        
        btnB = ElfUI.Button(self, self.header, 'B', None, [32, 16], 'Prints the letter b!')
        btnB.AppendClicked(self._PrintB)
        self.header.AddChild(btnB)
        
    def _PrintA(self):
        print('a')
        
    def _PrintB(self):
        print('b')


UI().show()

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>