Last active
February 5, 2022 10:12
-
-
Save JFlynnXYZ/9913813 to your computer and use it in GitHub Desktop.
Maya GUI Gists
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
'''This piece of code creates three buttons along the bottom of a window | |
equally seperated and adjustable by the changing of the window size. | |
To change where they are positioned in the form layout, swap out the | |
values in the attachForm with the attachNone values. For example, if | |
I wanted to place the buttons along the top I would swap out the | |
attachForm values for each "bottom" value with the attachNone values | |
for "top". | |
''' | |
window = cmds.window() | |
form = cmds.formLayout(numberOfDivisions=100) | |
button1 = cmds.button(label='button1') | |
button2 = cmds.button(label='button2') | |
button3 = cmds.button(label='button3') | |
cmds.formLayout(form, edit=True, | |
attachForm=[(button1, "bottom", 5), | |
(button1, "left", 5), | |
(button2, "bottom", 5), | |
(button3, "bottom", 5), | |
(button3, "right", 5)], | |
attachControl=[(button2, 'left', 5, button1), | |
(button2, 'right', 5, button3)], | |
attachPosition=[(button1, "right", 5, 33), | |
(button3, "left", 5, 66)], | |
attachNone=[(button1, "top"), | |
(button2, "top"), | |
(button3, "top")]) | |
cmds.showWindow() |
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
import maya.cmds as cmds | |
def reveal_more(state): | |
cmds.control(moreOptionsFrame, e=True, vis=state) | |
window = cmds.window(menuBar=True, title='dimWhen Example') | |
cmds.frameLayout(label='Example Frame', borderStyle='in', cll=True) | |
cmds.columnLayout(adj=True) | |
cmds.button(label='Button 1') | |
cmds.button(label='Button 2') | |
cmds.rowLayout(nc=2) | |
cmds.text(label='More Options') | |
cmds.checkBox(cc=reveal_more, label='') | |
cmds.setParent('..') | |
moreOptionsFrame = cmds.frameLayout(label='More Options', borderStyle='in', cll=True, vis=False) | |
cmds.columnLayout(adj=True) | |
cmds.button(label='Button 3') | |
cmds.button(label='Button 4') | |
cmds.showWindow( window ) |
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
Here is just a selection of GUI gists I've written which I have found useful when creating my own GUI's. | |
Hope you find them useful! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks a lot Jon!