GUIによる項目の選択

チェックボックスとラジオボタン

いくつかある項目の中から複数または、一つだけの項目を選びたい時にはcheckBoxとradioButtonを使用する。

checkBox
オンとオフができるコントロール。
例えば、以下のようにするとXというラベルのついたxCheckBoxという名前のcheckBoxが作られる。
checkBox -label "X" xCheckBox;
xCheckBoxという名前のcheckBoxの現在の値は以下のコマンドで得ることができる。
checkBox -q -value xCheckBox;
オンならtrue、オフならfalseが返される。
checkBoxGrp
複数のcheckBoxをまとめたもの。
radioButton
複数のボタンのうち一つだけがオンになるもの。
複数のradioButtonを一組のものとしてまとめるにはradioCollectionを使用する。
どのradioButtonが選ばれているかは以下のコマンドで得ることができる。
radioButton -q -select (radioButton名);
これによってオンになっているradioButtonの名前が返される。
radioButtonGrp
複数のradioButtonをまとめたもの。

radioButtonの使用例

ラジオボタンによってプリミティブ(球、キューブのうちのどれか)を作るGUIを作ってみよう。

window -title "radioButton1" window1;
columnLayout;
text -label "make Primitive";
radioCollection radioCollection1;
	radioButton -label "Sphere" -select sphereButton;
	radioButton -label "Cube" cubeButton;
button -label "OK"
	-command "$selected = `radioCollection -q -select radioCollection1`;\
	if($selected == \"sphereButton\") sphere;\
	else if($selected == \"cubeButton\") nurbsCube;";
button -label "Close" -command "deleteUI window1";
showWindow;
[image of example]

練習

まとめ

参考


Prev | Next
Home | Contents
abe@injapan.net