2010年9月19日

发几个常用窗口代码,需要的可以取用

最近有朋友很头疼写窗口的问题,其实写MEL做一些工具命令并不难,但是要写成窗口其实非常的繁琐费力,所以在解答那位朋友问题的同时,把一些常用的代码给大家,希望对写窗口非常头疼的朋友有帮助。1.单窗口主要语法及flag可以参见help中window的MEL

global proc nrCreateYaoTestWindow(){ string $nrWindowName =
"YaoTestWindow";
if(`window -exists $nrWindowName`) deleteUI
$nrWindowName;
if(`windowPref -exists $nrWindowName`) windowPref -remove
$nrWindowName; $nrWindowName = `window -t "YaoTestWindow" -s 1 -tb 1
-mnb
1 -mxb 1 -mb 0 -mbv 0 -tlb 0 -rtf 1 -mnc "" -rc ""
$nrWindowName`; string $newObject1 = `formLayout -en 1 -w 247 -h 354
-nd
100 formLayout79`; setParent ..; showWindow $nrWindowName;}
nrCreateYaoTestWindow;

2.标准按钮主要语法及flag可以参见help中button的MEL;

global proc nrCreateYaoTestWindow(){ string $nrWindowName
= "YaoTestWindow"; if(`window -exists
$nrWindowName`) deleteUI
$nrWindowName; if(`windowPref -exists
$nrWindowName`) windowPref -remove
$nrWindowName; $nrWindowName = `window -t "YaoTestWindow"
-s 1 -tb 1 -mnb 1 -mxb 1 -mb 0 -mbv 0
-tlb 0 -rtf 1 -mnc
"" -rc ""
$nrWindowName`;
string $newObject1 = `formLayout -en
1 -w 247 -h 354 -nd 100
formLayout91`;
string $newObject2 = `button -en 1 -w 100 -h 22 -l "按钮1" -al "center" -c "" -aop
0 -rs 1
button19`;
formLayout -e -attachPosition $newObject2 "top" 6 0 -attachPosition $newObject2
"left" 9 0 $newObject1; setParent
..; showWindow $nrWindowName;}nrCreateYaoTestWindow;







3.列按钮会用button语法以后依次写就会逐渐向下排列下去;

global proc nrCreateYaoTestWindow(){ string $nrWindowName =
"YaoTestWindow"; if(`window -exists
$nrWindowName`) deleteUI
$nrWindowName; if(`windowPref -exists
$nrWindowName`) windowPref -remove
$nrWindowName; $nrWindowName = `window -t "YaoTestWindow"
-s 1 -tb 1 -mnb 1 -mxb 1 -mb 0 -mbv 0
-tlb 0 -rtf 1 -mnc
"" -rc ""
$nrWindowName`;
string $newObject1 = `formLayout -en
1 -w 247 -h 354 -nd 100
formLayout91`;
string $newObject2 = `button -en 1 -w 100 -h 22 -l "按钮1" -al "center" -c "" -aop
0 -rs 1
button19`;
formLayout -e -attachPosition $newObject2 "top" 6 0 -attachPosition $newObject2
"left" 9 0
$newObject1;
string $newObject3 = `button -en 1 -w 100 -h 22 -l "按钮2" -al "center" -c "" -aop
0 -rs 1
button20`;
formLayout -e -attachPosition $newObject3 "top" 32 0 -attachPosition $newObject3
"left" 9 0
$newObject1;
string $newObject4 = `button -en 1 -w 100 -h 22 -l "按钮3" -al "center" -c "" -aop
0 -rs 1
button21`;
formLayout -e -attachPosition $newObject4 "top" 58 0 -attachPosition $newObject4
"left" 9 0 $newObject1; setParent
..; showWindow $nrWindowName;}nrCreateYaoTestWindow;




4.三排两列MEL没有新的,多主义左侧对齐数值就可以;


global proc nrCreateYaoTestWindow(){ string $nrWindowName = "YaoTestWindow";
if(`window -exists $nrWindowName`) deleteUI $nrWindowName; if(`windowPref
-exists $nrWindowName`) windowPref -remove $nrWindowName; $nrWindowName =
`window -t "YaoTestWindow" -s 1 -tb 1 -mnb 1 -mxb 1 -mb 0 -mbv 0 -tlb 0 -rtf 1
-mnc "" -rc "" $nrWindowName`; string $newObject1 = `formLayout -en 1 -w 262 -h
354 -nd 100 formLayout91`; string $newObject2 = `button -en 1 -w 100 -h 22 -l
"按钮1" -al "center" -c "" -aop 0 -rs 1 button19`; formLayout -e -attachPosition
$newObject2 "top" 6 0 -attachPosition $newObject2 "left" 9 0 $newObject1; string
$newObject3 = `button -en 1 -w 100 -h 22 -l "按钮2" -al "center" -c "" -aop 0 -rs
1 button20`; formLayout -e -attachPosition $newObject3 "top" 32 0
-attachPosition $newObject3 "left" 9 0 $newObject1; string $newObject4 = `button
-en 1 -w 100 -h 22 -l "按钮3" -al "center" -c "" -aop 0 -rs 1 button21`;
formLayout -e -attachPosition $newObject4 "top" 58 0 -attachPosition $newObject4
"left" 9 0 $newObject1; string $newObject5 = `button -en 1 -w 100 -h 22 -l "按钮4"
-al "center" -c "" -aop 0 -rs 1 button22`; formLayout -e -attachPosition
$newObject5 "top" 6 0 -attachPosition $newObject5 "left" 144 0 $newObject1;
string $newObject6 = `button -en 1 -w 100 -h 22 -l "按钮5" -al "center" -c "" -aop
0 -rs 1 button23`; formLayout -e -attachPosition $newObject6 "top" 32 0
-attachPosition $newObject6 "left" 144 0 $newObject1; string $newObject7 =
`button -en 1 -w 100 -h 22 -l "按钮6" -al "center" -c "" -aop 0 -rs 1 button24`;
formLayout -e -attachPosition $newObject7 "top" 58 0 -attachPosition $newObject7
"left" 144 0 $newObject1; setParent ..; showWindow
$nrWindowName;}nrCreateYaoTestWindow;


沒有留言:

張貼留言