This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ControlMeta(type): | |
''' | |
Metaclass which creates CtlProperty objects for maya gui proxies | |
''' | |
CONTROL_ATTRIBS = ['annotation', 'backgroundColor', 'defineTemplate', | |
'docTag', 'dragCallback', 'dropCallback', 'enable', | |
'enableBackground', 'exists', 'fullPathName', 'height', | |
'manage', 'noBackground', 'numberOfPopupMenus', 'parent', | |
'popupMenuArray', 'preventOverride', 'useTemplate', 'visible', | |
'visibleChangeCommand', 'width'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
xform.py | |
Exposes the xform class: a simple way to set maya position, rotation and similar properties with point notation. | |
from xform import Xform | |
example = Xform('pCube1') | |
print example.translation | |
# [0,0,0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FloatSlider(Control): | |
'''sample output from mGui.helpers.tools.generate_commands()''' | |
CMD = cmds.floatSlider | |
_ATTRIBS = ['horizontal','step','maxValue','value','minValue'] | |
_CALLBACKS = ['changeCommand','dragCommand'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mGui.core.controls import FloatSlider | |
slider = FloatSlider('testslider') | |
# pythonic properties, thanks to the metaclass... | |
slider.width = 100 | |
slider.minValue = 50 | |
slider.maxValue = 250 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ControlMeta(type): | |
''' | |
Metaclass which creates CtlProperty and CallbackProperty objects for Control classes | |
''' | |
def __new__(cls, name, parents, kwargs): | |
CMD = kwargs.get('CMD', None) | |
_READ_ONLY = kwargs.get('_READ_ONLY',[]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Control(Styled, BindableObject): | |
''' | |
Base class for all mGui controls. Provides the necessary frameworks for | |
CtlProperty and CallbackProperty access to the underlying widget. | |
NOTE this is not exactly identical to the code on github - more advanced stuff is removed to make the progression clearer | |
''' | |
CMD = cmds.control | |
_ATTRIBS = ['annotation', 'backgroundColor', 'defineTemplate', 'docTag', 'enable', 'enableBackground', 'exists', 'fullPathName', 'height', 'manage', 'noBackground', 'numberOfPopupMenus', 'parent', 'popupMenuArray', 'preventOverride', 'useTemplate', 'visible', 'visibleChangeCommand', 'width'] | |
_CALLBACKS = ['dragCallback', 'dropCallback', 'visibleChangeCommand'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Nested(Control): | |
''' | |
Base class for all the nested context-manager classes which automatically parent themselves | |
''' | |
ACTIVE_LAYOUT = None | |
def __init__(self, key, *args, **kwargs): | |
self.Controls = [] | |
super(Nested, self).__init__(key, *args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mGui.gui import * | |
# note the caps: all of these are wrapper objects, not maya.cmds! | |
window = Window('main window', title="How's this") | |
with ColumnLayout('gui', width = 256) as gui: | |
with FrameLayout("t_buttons", label = "buttons column"): | |
with ColumnLayout("col"): | |
Button('mkSphere', label = "Make Sphere") | |
Button('mkCone', label ="Make Cone") | |
Button('mkCube', label ="Make Cube") |