Hey everyone. I've been tinkering with mel lately, paritluatly making windows with buttons to perform various functions. Im wanting to color code my buttons, but not getting the resluts I'd like. Ive been using bgc values, but its been difficult getting the exact value I need. Is there a way to apply the rgb and hsv values to a button, and if so, how? Thanks!
Just make a conversion on the fly by dividing you rgb values by 255 to get a normalized value between 0 and 1 (note that I use 255.0 instead of 255 to obtain a float value instead of an int:
test:
print (171/255);
//result 0
print (171/255.0);
//result 0.670588
// ex. code for rgb color (171, 208, 188)
{
window -tlb 1 -t "Use RGB values";
rowLayout -adj 1;
button -l "rgb(171,208,188)" -bgc (171/255.0) (208/255.0) (188/255.0);
showWindow;
}

colorBuddy
global proc colorMe(){
string $window = "colorBuddy|panel|"; string $rh[] ={"r","h"};
for ($abc in {"A","B","C","D","E"}){
float $rgb[2] = `colorSliderGrp -q -rgb ($window+$abc)`;
float $hsv[2] = `colorSliderGrp -q -hsv ($window+$abc)`;
$rgbhsv[0] = ($rgb[0]+" "+$rgb[1]+" "+$rgb[2]);
$rgbhsv[1] = ($hsv[0]+" "+$hsv[1]+" "+$hsv[2]);
for ($n=0;$n<=1;$n++){textField -e -tx $rgbhsv[$n] ($window+$rh[$n]+$abc);}
}
}
global proc makeColorWindow(){
if (`window -ex colorBuddy`) deleteUI colorBuddy;
$i = 0.0;
window -w 700 -t "colorBuddy" colorBuddy;
rowColumnLayout -nc 3 panel;
for ($abc in {"A","B","C","D","E"}){
textField -w 250 ("r"+$abc); colorSliderGrp -cc colorMe -rgb $i $i $i $abc;textField -w 250 ("h"+$abc); $i+=0.25;}
setParent..;
setParent..;
colorMe;
showWindow;
}
makeColorWindow;
