Here is one in MEL.  The UI is just copy/pasted from the frameLayout
example in the doc's, except that it tracks one of the int sliders
with an optionVar so it will remember the value it was set to last.


global proc MyOptionsUISetup(string $parent)
{
        setParent $parent;

        columnLayout -adjustableColumn true;
                frameLayout -label "Buttons"
                        -borderStyle "in";
                        columnLayout;
                                button;
                                button;
                                button;
                                setParent ..;
                        setParent ..;
                frameLayout -label "Scroll Bars"
                        -borderStyle "out";
                        columnLayout;
                                intSlider -min -100 -max 100 -value 0 -step 1 
MyIntSlider;
                                intSlider;
                                intSlider;
                                setParent ..;
                        setParent ..;
                frameLayout -label "Fields"
                        -borderStyle "etchedIn";
                        columnLayout;
                                intField;
                                intField;
                                intField;
                                setParent ..;
                        setParent ..;
                frameLayout -label "Check Boxes"
                        -borderStyle "etchedOut";
                        columnLayout;
                                checkBox;
                                checkBox;
                                checkBox;
                                setParent ..;
                        setParent ..;
}

global proc MyOptionsUIInitValues(string $parent, string $filterType)
{
        setParent $parent;

        print ("Current file filter: " + $filterType + "\n");

        // Probably make sure optionVar's or whatever are initialized here...
        if (!`optionVar -exists defaultFileOpenType`)
        {
                optionVar -intValue MyIntSliderOption 0;
        }

        int $intValue = `optionVar -query MyIntSliderOption`;

        // Set all the values of the controls...
        intSlider -edit -value $intValue MyIntSlider;
}

global proc MyOptionsUICallback(string $parent)
{
        setParent $parent;

        // When the UI is going away we usually save the state in optionVar's

        int $intValue = `intSlider -query -value MyIntSlider`;
        optionVar -intValue MyIntSliderOption $intValue;
}

global proc MyCurrentFileTypeOption(string $parent, string
$filterType)
{
        print ("File filter switched to: " + $filterType + "\n");
}

global proc MySelectionChangedCallback(string $parent, string
$selection)
{
        print ("User selected: " + $selection + "\n");
}

global proc customOptions()
{
        string $file[] = `fileDialog2
                        -returnFilter 1
                        -caption "Open"
                        -fileMode 1
                        -okCaption "Open"
                        -optionsUICreate "MyOptionsUISetup"
                        -optionsUIInit "MyOptionsUIInitValues"
                        -selectionChanged "MySelectionChangedCallback"
                        -optionsUICommit "MyOptionsUICallback"
                        -fileTypeChanged "MyCurrentFileTypeOption"
                        -fileFilter "Maya Scenes (*.ma *.mb);;Maya ASCII 
(*.ma);;Maya
Binary (*.mb);;All Files (*)"
                        -selectFileFilter "Maya Scenes"`
                        ;

        int $len = size($file);
    if( $len > 0 && $file[0] != "" )
    {
                string $path = fromNativePath($file[0]);
                print ("File: " + $path + "\n");
        }
}

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to