maya里怎么用mel和python写动态 button,简单来说就是用一个按钮控制另一个按钮的显示与隐藏,谢谢
发布网友
发布时间:2022-04-29 23:44
我来回答
共1个回答
热心网友
时间:2023-10-10 14:46
python的脚本如下
import maya.cmds as mc
win=mc.window()
mc.columnLayout( adjustableColumn = True )
btn1=mc.button(l="按钮开",c='')
btn2=mc.button(l="按钮2",c='mc.button(btn1,e = 1,l = "按钮关")')
mc.showWindow(win)
mel的脚本如下
window;
columnLayout -adj 1;
button -l "按钮开" -c "" btn1;
button -l "按钮2" -c "button -e -l \"按钮关\" btn1";
showWindow;
其实还可以写成函数来调用
python函数如下
import maya.cmds as mc
win=mc.window()
mc.columnLayout( adjustableColumn = True )
btn1=mc.button(l="按钮开",c='')
btn2=mc.button(l="按钮2",c = 'change()')
mc.showWindow(win)
def change():
btn = mc.button(btn1,q = 1,l = 1)
if btn == '按钮开':
mc.button(btn1,e = 1,l = '按钮关')
if btn == '按钮关':
mc.button(btn1,e = 1,l = '按钮开')
mel函数如下
window;
columnLayout -adj 1;
button -l "按钮开" -c "" btn1;
button -l "按钮2" -c "btn1";
showWindow;
proc btn1(){
string $btn1 = `button -q -l btn1`;
if($btn1 == "按钮开"){
button -e -l "按钮关" btn1;
}
if($btn1 == "按钮关"){
button -e -l "按钮开" btn1;
}
}追问谢谢你的答案,我还有个问题maya里的button能不能支持鼠标热区,就是当鼠标移动到按钮上时可改变按钮状态。要用那个函数实现,谢谢,给分