Tcl-tk-tk-scrollbar-widget
提供:Dev Guides
Tk-スクロールバーウィジェット
スクロールバーウィジェットは、テキストウィジェットまたはキャンバスウィジェットなしで動作できるスクロールウィジェットです。 スクロールバーウィジェットの構文を以下に示します。
scrollbar scrollbarName options
オプション
スクロールバーウィジェットで使用可能なオプションを以下の表にリストします。
Sr.No. | Syntax & Description |
---|---|
1 |
-background color ウィジェットの背景色を設定するために使用されます。 |
2 |
-borderwidth width 3D効果でボーダー付きで描画するために使用されます。 |
3 |
-orien orientation ウィジェットの方向を設定します。 水平または垂直のいずれかです。 |
4 |
-relief condition このウィジェットの3Dレリーフを設定します。 状態は、隆起、沈没、平坦、隆起、中実、または溝のいずれかです。 |
5 |
-command command コマンドはビューをスクロールバーウィジェットにリンクします。 |
スクロールバーウィジェットの簡単な例を以下に示します-
#!/usr/bin/wish
grid [tk::listbox .l -yscrollcommand ".s1 set" -xscrollcommand ".s2 set" -height 5 -width
20] -column 0 -row 0 -sticky nwes
grid [ttk::scrollbar .s1 -command ".l yview" -orient vertical -background yellow
-borderwidth 5 -relief ridge] -column 1 -row 0 -sticky ns
grid [ttk::scrollbar .s2 -command ".l xview" -orient horizontal -background yellow
-borderwidth 5 -relief ridge] -column 0 -row 1 -sticky ew
for {set index 0} {$index<100} {incr index} {
.l insert end "A long line of text for testing scrollbar."
}
上記のプログラムを実行すると、次の出力が得られます-