WINID = "mineUI"
def ui():
# Make sure that the UI isn"t already active
if cmds.window(WINID, exists=True):
cmds.deleteUI(WINID)
cmds.window(WINID, title="My window testing", width=365, height=135,
sizeable=False)
# Add a Layout
cmds.columnLayout(adjustableColumn=True)
cmds.rowColumnLayout(numberOfColumns=3, columnAttach=[1, "right", 0],
columnWidth=[2, 250])
# Add text field for character to constraint
cmds.text(label="Constraint From: ")
constraint_from = cmds.textField("constraint_from")
cmds.button(label=" <<< ")
# Add text field for constraint_to
cmds.text(label="Constraint To: ")
constraint_to = cmds.textField("constraint_to")
cmds.button(label=" <<< ")
# Add checkbox for constraint offset
cmds.text(label="")
cmds.checkBox("offset", label="Maintain offset", value=False)
cmds.text(label="")
# Add checkbox for time
cmds.text(label="")
cmds.checkBox("time", label="Specify frame range", value=False,
changeCommand=_frame_range)
cmds.text(label="")
# Add labels for frame range
cmds.text("start", label=" Start Frame ", visible=False, height=1, width=1)
cmds.textField("start_frame", visible=False, height=1, width=1)
cmds.text("space1", label="", visible=False, height=1, width=1)
# Add text field for frame range
cmds.text("end", label=" End Frame ", visible=False, height=1, width=1)
cmds.textField("end_frame", visible=False, height=1, width=1)
cmds.text("space2", label="", visible=False, height=1, width=1)
# Add button for select all the controls
cmds.text(label="")
cmds.button(label=" Select all controls to constraint ")
cmds.text(label="")
# Fill first column
cmds.text(label="")
cmds.button(label=" Constraint and Bake ")
cmds.text(label="")
# Display the window.
cmds.showWindow(WINID)
def _frame_range(*args):
switch = cmds.checkBox("time", value=True, query=True)
if switch:
# Labels
cmds.text("start", edit=True, visible=True, height=20, width=65)
cmds.text("end", edit=True, visible=True, height=20, width=65)
# Text Fields
cmds.textField("start_frame", edit=True, visible=True, height=20,
width=250)
cmds.textField("end_frame", edit=True, visible=True, height=20,
width=250)
# Fix Window size
# This line is not here in my initial code.
cmds.window(WINID, edit=True, resizeToFitChildren=True)
else:
# Labels
cmds.text("start", edit=True, visible=False, height=1, width=1)
cmds.text("end", edit=True, visible=False, height=1, width=1)
# Text Fields
cmds.textField("start_frame", edit=True, visible=False, height=1,
width=1)
cmds.textField("end_frame", edit=True, visible=False, height=1, width=1)
# Fix Window size
cmds.window(WINID, edit=True, width=365)
cmds.window(WINID, edit=True, height=135)
ui()