Hi,
I've created a simple Window GUI with one Button.
When the button is pressed, I'd like it to display the name of the object I've selected in maya, in a textfield within the GUI window.
The text would be used as a confirmation that the user has selected that particular Object in the scene.
The Button function is called "returnIKcontroller".
The returnIKcontroller() function returns the variable $name.
--------------------------------------------------------------------------------
string $name = "Nothing selected yet";
global proc string returnIKcontroller() {
string $selected[] = `ls -sl`;
string $name = $selected[0];
print ($name +" Selected\n");
return $name;
}
---------------------------------------------------------------------------------
Inside the window GUI creation, I've setup the code like this....
---------------------------------------------------------------------------------------
button -label "Select IK Controller" -command "returnIKcontroller";
textField -text $name;
----------------------------------------------------------------------------------------
Unfortunately, I can't seem to get the 'textfield $name' variable to update if the button is pressed with a different selection.
Is there a way to update the Window GUI to use the new variable?
Replies
EDIT: yeah, I don't think you can update the button label directly. Maybe someone else knows.
Maybe, Instead of the textField -text $name;
using...
text -label $name;
would be fine.. as long as I can find a way to update the $name variable
window;
columnLayout;
string $selObj[] = `ls -sl` ; textFieldButtonGrp -text $selObj[0] -buttonLabel "Button" -buttonCommand "objectName" selectedObject;
proc objectName(){
string $selObj[] = `ls -sl` ;
textFieldButtonGrp -e -text $selObj[0] -buttonLabel "Button" -buttonCommand "objectName" selectedObject;
}
showWindow;
If you want perhaps for the text field to auto update with whatever you have selected wihout need to always press the button to update field look at scriptJob command. Hope it helps.
This place is never short of amazing people.
Think i've been trying to teach myself Maya GUI since 7am this morning and getting nowhere with this.
Your code is definitely the blue print for what I'm after. Thanks again!!