(MEL) how to build UI that list groups and children ?

(MEL) how to build UI that list groups and children ?

absoluteKelvin
Collaborator Collaborator
1,761 Views
8 Replies
Message 1 of 9

(MEL) how to build UI that list groups and children ?

absoluteKelvin
Collaborator
Collaborator

Im trying to build a UI for my script that list Groups and children  similar to Outliner. The issue Im having is that I  just needs a list where users can add items to the list. Not a global list that list all the objects in scene.  I search the MEL documentation already but unsure as to which command i should be using.

https://www.artstation.com/kelvintam
0 Likes
1,762 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable

Unfortunately the UI options offered in MEL are very basic. For something more complicated like this you would need to use QT specifically the QTreeWidget. 

0 Likes
Message 3 of 9

absoluteKelvin
Collaborator
Collaborator

you are probably right. however I have found a UI layout that does kind of what I need, which is the treeView.

 

http://help.autodesk.com/cloudhelp/2018/ENU/Maya-Tech-Docs/Commands/treeView.html 

 

now im just trying to figure out how to query the selection.

 

 

https://www.artstation.com/kelvintam
0 Likes
Message 4 of 9

absoluteKelvin
Collaborator
Collaborator

after some more digging I figure out how to query the selection.

treeView -query -selectItem

Now Im stuck on the UI part.

Need to replicate this UI in formLayout format. because I want to make the UI adjustable when user resizes the window.

ktMassUVTransfer.JPG

https://www.artstation.com/kelvintam
0 Likes
Message 5 of 9

jmreinhart
Advisor
Advisor

Formlayout is not great for making the UI "stretchable". You can nest layouts within each other.  

layouts.png

However there is a widget in that UI called the splitter which can be made with Qt or Pyside but not MEL.

Message 6 of 9

absoluteKelvin
Collaborator
Collaborator

Thanks for paintover, I will try the nesting. Qt and Pyside is beyond me at this point, so im gona stick with mel for the time being.

https://www.artstation.com/kelvintam
0 Likes
Message 7 of 9

absoluteKelvin
Collaborator
Collaborator

I tried several times to wrap my head around this. I understand the theory of nesting layouts, but executing is different.

The following is my Attempt. getting errors. Too many children in layout: mainRowLayout

    window -title "testLayout" testLayout10;
    rowLayout -adjustableColumn 2 -numberOfColumns 2 mainRowLayout;
        text -align "center" " Source Objects" ;
        text -align "center" "Target Objects" ;
        columnLayout -adjustableColumn true;
                rowLayout -adjustableColumn 2 -numberOfColumns 2 horizontalLayout1;
                    treeView -allowMultiSelection true TreeView1;       
                    columnLayout -columnAttach "both" 5;
                    button -label "Add"  addSourceBtn;
                    button -label "Remove" RemoveSelSourceBtn;
                    button -label "Remove All"  removeSourceBtn;
   showWindow;

really stuck right now.

 

https://www.artstation.com/kelvintam
0 Likes
Message 8 of 9

jmreinhart
Advisor
Advisor

"This command creates a layout capable of positioning children into a single horizontal row."

 

The rowLayout only creates a single row, so those first two text widgets you create fill up the layout.

 

 

0 Likes
Message 9 of 9

absoluteKelvin
Collaborator
Collaborator

I took some time away from this UI, now im back at tackling this.

Heres my result.

 

ktUI.JPG

Still not really able to create the effect i want. Currently the UI can scale Horizontally. But Wont scale vertically.

 

 

global proc ktMassTransferUV(){
        if (`window -ex MassTransferUVsWIN`) {
        deleteUI MassTransferUVsWIN;
    }
    window -title "KT_MassTransferUVs"  MassTransferUVsWIN;
    columnLayout -adjustableColumn true -columnWidth 200 mainLayout;
    rowLayout -numberOfColumns 2 -adjustableColumn 2 -width 100;
    text "Source Objects";
    text "Target Objects" ;
    setParent..;
    separator -height 10 -style "in";
    paneLayout -configuration "vertical4" -paneSize 1 40 80 vertTopLayout;
    paneLayout -edit -paneSize 3 40 80 vertTopLayout;
    treeView -allowMultiSelection true -allowDragAndDrop true sourceTreeView;
        columnLayout -columnAttach "both" 5;
        button -label "Add" -command ("updateSourceList(\"sourceTreeView\")") addSourceBtn;
        button -label "Remove Selected" -command ("removeSel(\"sourceTreeView\")") RemoveSelSourceBtn;
        button -label "Remove All" -command ("removeList(\"sourceTreeView\")") removeSourceBtn;
    setParent..;
    treeView -allowMultiSelection true -allowDragAndDrop true targetTreeView;
        columnLayout -columnAttach "both" 5;
        button -label "Add" -command ("updateSourceList(\"targetTreeView\")") addTargetBtn;
        button -label "Remove Selected" -command ("removeSel(\"targetTreeView\")") RemoveSelTargetBtn;
        button -label "Remove All" -command ("removeList(\"targetTreeView\")") removeAllTargetBtn;
    setParent mainLayout;
    separator -height 10 -style "in";
    radioButtonGrp -numberOfRadioButtons 4 -label "Method   " -labelArray4 "World" "Local" "Component" "Topology" -select 4 transferMethodBtnGrp;
    setParent..;
    columnLayout -adj 1;
    button -label "Transfer" -command "massUVTransferProc";
    showWindow;
}

 

When I try to replace this

    paneLayout -configuration "vertical4" -paneSize 1 40 80 vertTopLayout;
    paneLayout -edit -paneSize 3 40 80 vertTopLayout;

with a rowLayout. The treeView disappears, leaving only the buttons.

 

 

However I found the layout that i want to replicate, at least part of it. which is the Connection Editor. But I cant seem to find the mel script for it, so i can study it. I like the fact that the whole UI is adjustable when you resize the window. In the Connection Editor case, they used nodeOutliner to populate the list. In my case Im using the treeView. Which works similar to Outliner list, without all the extra stuff.

 

ConnectionEditor.JPG

https://www.artstation.com/kelvintam
0 Likes