I have this UI using maya commands in which I am having problem with one of 
the checkbox.
Here is the code:
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()


If the "Specify frame range" is checked, it will displays the text field 
boxes etc correctly. However if you uncheck and checked it again, you will 
notice that the 2 buttons, namely "Select all controls to constraint" and 
"Constraint and Bake" are somewhat hidden.

But if you re-click on the Window Title, it seems to "expand" the window 
and displays it correctly.

My question here would be - Are there any other ways in which I can make 
the window to display correctly (checked, unchecked and checked the frame 
range checkbox)?

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/3f86b2f2-6f6c-4fbe-aec8-d4ad87c767ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to