Tcl-tk-tk-combobox-widget

提供:Dev Guides
移動先:案内検索

Tk-コンボボックスウィジェット

Comboboxウィジェットは、エントリと、使用可能な選択肢のリストを組み合わせたウィジェットです。 comboboxウィジェットの構文は以下のとおりです-

combobox comboboxName options

オプション

comboboxウィジェットで使用可能なオプションを以下の表にリストします。

Sr.No. Syntax & Description
1

-background color

ウィジェットの背景色を設定するために使用されます。

2

-borderwidth width

3D効果でボーダー付きで描画するために使用されます。

3

-font fontDescriptor

ウィジェットのフォントを設定するために使用されます。

4

-foreground color

ウィジェットの前景色を設定するために使用されます。

5

-textvariable varName

ウィジェットに関連付けられた変数。 ウィジェットのテキストが変更されると、変数はウィジェットのテキストに設定されます。

6

-values array

コンボボックスウィジェットの任意の値。

7

-width number

ウィジェットの幅を設定します。

8

-justify alignment

テキストの配置を設定します。左、中央、または右に設定できます。

9

-state requiredState

状態を設定します。read_only、disabled、またはnormalのいずれかです。

10

-postcommand command

アクション後に実行されるプロシージャ。

コンボボックスウィジェットの簡単な例を以下に示します-

#!/usr/bin/wish

set mylist [list C C++ Lua Tcl]
pack [ttk::combobox .s1  -textvariable combovalue -values $mylist -background yellow
   -font {Helvetica -18 bold} -foreground red -width 40 -justify left -state normal]
set combovalue "C"

上記のプログラムを実行すると、次の出力が得られます-

コンボボックスの例