
作者:七月冰儿
共有的标志(一):
如果你读过mel命令的帮助文档,你会发现所有的界面命令都具有一些共同的标志。比如,"-q"、"-e"就是所有界面命令都具有的标志。我把这些标志介绍一下,这样无论任何界面(布局或控件)命令,只要用到这些标志时,你们就都知道怎么去用了。
"-q/-query"(查询)
表示查询的意思,你可以通过它获得某一标志的数值。(前面讲过了)
"-e/-edit"(编辑)
表示编辑的意思,你可以通过它修改某一标志的数值。(前面讲过了)
"-ex/exists"(是否存在)
通过"-ex"可以得知一个界面元素是否存在。 例如前面讲过的"if(`window -ex myTestWin`)"。
"-dt/defineTemplate" (定义模板)
"-ut/useTemplate" (使用模板)
一般我们没必要定义模板,不过有几个Maya已经定义好的模板有时会用到,我以后再讲。
"-p/parent" (指定父级界面元素)
指定父级界面元素(布局或菜单),平常我们用"setParent"命令来解决这个问题,所以"-p"很少用到。
"-en/enable" (是否激活)
我们经常看到一些菜单或按钮上的字是灰色的,表示它们现在不能用。
使用"-en"就可以让你的界面元素上的字变灰,使它们不能用。
例如"button -e -en off myButton1"就是让按钮myButton1变得不能用。
而"button -e -en on myButton1"就是让按钮myButton1恢复活力。
"-w/width" (宽度)
界面元素的宽度为多少像素。
你会发现使用这个标志时经常不起作用。
比如如果在布局命令中指定了里面控件的宽度,再给布局中这些控件指定宽度就不起作用了。
窗口的宽度只在第一次创建时有用,以后创建会使用预置中的尺寸。预置中的尺寸就是窗口关闭时的大小,这个尺寸记录在预置文件(windowPrefs.mel)中,可以通过"windowPref"命令去除窗口的预置尺寸,方法是"windowPref -remove 窗口名;"
"-h/height" (高度)
界面元素的高度为多少像素。
用法同"-w/width",例如"button -w 32 -h 32;"。
"-vis/visible" (是否可见)
指定界面元素是否可见。
前面讲过"window -visible off"的问题。其它界面元素也可以通过"-visible off"暂时隐藏,想要显示出来,就用"-visible on"。
"-io/isObscured" (是否看不到)
查询界面元素是否不可见。你肯定会问"-io"和"-vis"的区别。"-io"只能用于查询(-q)模式,般查询结果正好与"-vis"的查询结果相反。不过"-io"的不可见包括窗口最小化、父级界面元素隐藏等造成的不可见因素。
"-m/manage" (可控制)
指定界面元素是否可见。跟"-vis"没什么区别。
"-ann/annotation" (注释)
给界面元素注释。注释可以在帮助栏显示,也可以让鼠标在界面元素上停一会,在弹出式的淡黄底色注释条看到。
"-bgc/backgroundColor" (底色)
要想编写彩色窗口就要用到这个标志。
还有一些共有标志留到以后讲。
布局到此已经全讲完了,接下来讲控件。
前面提到过一些控件:
"text"命令 (静态文本)
"textField"命令 (文本框)
"button"命令 (按钮)
"separator"命令 (分隔线)
这些控件虽然已经讲过了,但由于十分重要,现在在强调一下,一定要熟练掌握。
另外,先随便讲几个: "picture"命令 (图片) 静态图片。
picture -w 80 -h 60 -image "sphere.xpm" -tile on;
"-i/image"指定图片。
"-tl/tile"指定图片是否重复排叠显示。
"iconTextButton"命令 (图标文本按钮) "symbolButton"命令 (符号按钮) "intSlider"命令 (整数型滑动条) 
既有字又有图标的按钮,你可以只显示字或图标。
string $window = `window`;
columnLayout -adj 1;
iconTextButton -style "textOnly"
-image1 "sphere.xpm" -label "sphere";
iconTextButton -style "iconOnly"
-image1 "spotlight.xpm" -label "spotlight";
iconTextButton -style "iconAndTextHorizontal"
-image1 "cone.xpm" -label "cone";
iconTextButton -style "iconAndTextVertical"
-image1 "cube.xpm" -label "cube";
showWindow $window; 
有图片的按钮。
symbolButton -image "cone.xpm" -c "cone"; 
intSlider -min -100 -max 100 -value 0;
"-min"最小值
"-max"最大值
"-value"当前值
"iconTextButton"命令 (图标文本按钮)
既有字又有图标的按钮,你可以只显示字或图标。
string $window = `window`;
columnLayout -adj 1;
iconTextButton -style "textOnly"
-image1 "sphere.xpm" -label "sphere";
iconTextButton -style "iconOnly"
-image1 "spotlight.xpm" -label "spotlight";
iconTextButton -style "iconAndTextHorizontal"
-image1 "cone.xpm" -label "cone";
iconTextButton -style "iconAndTextVertical"
-image1 "cube.xpm" -label "cube";
showWindow $window;

"symbolButton"命令 (符号按钮)
有图片的按钮。
symbolButton -image "cone.xpm" -c "cone";

"intSlider"命令 (整数型滑动条)
intSlider -min -100 -max 100 -value 0;
"-min"最小值
"-max"最大值
"-value"当前值

"iconTextButton"命令 (图标文本按钮)
既有字又有图标的按钮,你可以只显示字或图标。
string $window = `window`;
columnLayout -adj 1;
iconTextButton -style "textOnly"
-image1 "sphere.xpm" -label "sphere";
iconTextButton -style "iconOnly"
-image1 "spotlight.xpm" -label "spotlight";
iconTextButton -style "iconAndTextHorizontal"
-image1 "cone.xpm" -label "cone";
iconTextButton -style "iconAndTextVertical"
-image1 "cube.xpm" -label "cube";
showWindow $window;

"symbolButton"命令 (符号按钮)
有图片的按钮。
symbolButton -image "cone.xpm" -c "cone";

"intSlider"命令 (整数型滑动条)
intSlider -min -100 -max 100 -value 0;
"-min"最小值
"-max"最大值
"-value"当前值

"iconTextButton"命令 (图标文本按钮)
既有字又有图标的按钮,你可以只显示字或图标。
string $window = `window`;
columnLayout -adj 1;
iconTextButton -style "textOnly"
-image1 "sphere.xpm" -label "sphere";
iconTextButton -style "iconOnly"
-image1 "spotlight.xpm" -label "spotlight";
iconTextButton -style "iconAndTextHorizontal"
-image1 "cone.xpm" -label "cone";
iconTextButton -style "iconAndTextVertical"
-image1 "cube.xpm" -label "cube";
showWindow $window;

"symbolButton"命令 (符号按钮)
有图片的按钮。
symbolButton -image "cone.xpm" -c "cone";

"intSlider"命令 (整数型滑动条)
intSlider -min -100 -max 100 -value 0;
"-min"最小值
"-max"最大值
"-value"当前值

"iconTextButton"命令 (图标文本按钮)
既有字又有图标的按钮,你可以只显示字或图标。
string $window = `window`;
columnLayout -adj 1;
iconTextButton -style "textOnly"
-image1 "sphere.xpm" -label "sphere";
iconTextButton -style "iconOnly"
-image1 "spotlight.xpm" -label "spotlight";
iconTextButton -style "iconAndTextHorizontal"
-image1 "cone.xpm" -label "cone";
iconTextButton -style "iconAndTextVertical"
-image1 "cube.xpm" -label "cube";
showWindow $window;

"symbolButton"命令 (符号按钮)
有图片的按钮。
symbolButton -image "cone.xpm" -c "cone";

"intSlider"命令 (整数型滑动条)
intSlider -min -100 -max 100 -value 0;
"-min"最小值
"-max"最大值
"-value"当前值

"iconTextButton"命令 (图标文本按钮)
既有字又有图标的按钮,你可以只显示字或图标。
string $window = `window`;
columnLayout -adj 1;
iconTextButton -style "textOnly"
-image1 "sphere.xpm" -label "sphere";
iconTextButton -style "iconOnly"
-image1 "spotlight.xpm" -label "spotlight";
iconTextButton -style "iconAndTextHorizontal"
-image1 "cone.xpm" -label "cone";
iconTextButton -style "iconAndTextVertical"
-image1 "cube.xpm" -label "cube";
showWindow $window;

"symbolButton"命令 (符号按钮)
有图片的按钮。
symbolButton -image "cone.xpm" -c "cone";

"intSlider"命令 (整数型滑动条)
intSlider -min -100 -max 100 -value 0;
"-min"最小值
"-max"最大值
"-value"当前值

评论加载中…