要mel和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.showWindow(win)
我想用按钮2点击一下改变按钮1的文本,使按钮1的按钮开变成按钮关。
maya里怎么用mel和python写动态 button,简单来说就是用一个按钮控制另一个按钮的显示与隐藏,谢谢
答案:1 悬赏:0 手机版
解决时间 2021-01-28 22:54
- 提问者网友:寂寞梧桐
- 2021-01-28 18:16
最佳答案
- 五星知识达人网友:刀戟声无边
- 2021-01-28 18:41
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;
}
}
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;
}
}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯