Tcl-tk-tk-button-widget
提供:Dev Guides
Tk-ボタンウィジェット
Tkボタンウィジェットは、アクションをトリガーするクリック可能なウィジェットです。 ボタンウィジェットの構文は以下に示されています-
button buttonName options
オプション
ボタンウィジェットに利用可能なオプションは、以下の表に記載されています-
Sr.No. | Syntax & Description |
---|---|
1 |
-font fontDescriptor ウィジェットのフォントを設定するために使用されます。 |
2 |
-height number ウィジェットの高さを設定するために使用されます。 |
3 |
-command action ボタンのコマンドアクションを設定します。 |
4 |
-text text ウィジェットのテキストを設定します。 |
5 |
-width number ウィジェットの幅を設定します。 |
シンプルなボタンウィジェットは以下に示されています-
#!/usr/bin/wish
grid [label .myLabel -text "Click the buttons" -textvariable labelText]
grid [button .myButton1 -text "Button 1" -font {Helvetica -18 bold} -height 5 -width 10
-command "set labelText clicked_top_btn"]
grid [button .myButton2 -text "Button 2" -font {Helvetica -18 bold} -height 5 -width 10
-command "set labelText clicked_bottom_btn"]
上記のプログラムを実行すると、次の出力が得られます-
Button1をクリックすると、次の出力が得られます-
Button2をクリックすると、次の出力が得られます-