- Tcl Tutorial
- Tcl - Home
- Tcl - Overview
- Tcl - Environment Setup
- Tcl - Special Variables
- Tcl - Basic Syntax
- Tcl - Commands
- Tcl - Data Types
- Tcl - Variables
- Tcl - Operators
- Tcl - Decisions
- Tcl - Loops
- Tcl - Arrays
- Tcl - Strings
- Tcl - Lists
- Tcl - Dictionary
- Tcl - Procedures
- Tcl - Packages
- Tcl - Namespaces
- Tcl - File I/O
- Tcl - Error Handling
- Tcl - Built-in Functions
- Tcl - Regular Expressions
- Tk Tutorial
- Tk - Overview
- Tk - Environment
- Tk - Special Variables
- Tk - Widgets Overview
- Tk - Basic Widgets
- Tk - Layout Widgets
- Tk - Selection Widgets
- Tk - Canvas Widgets
- Tk - Mega Widgets
- Tk - Fonts
- Tk - Images
- Tk - Events
- Tk - Windows Manager
- Tk - Geometry Manager
- Tcl/Tk Useful Resources
- Tcl/Tk - Quick Guide
- Tcl/Tk - Useful Resources
- Tcl/Tk - Discussion
Tk - Combobox Widget
Combobox widget is a widget that combines an entry with a list of choices available to the use. The syntax for combobox widget is shown below −
combobox comboboxName options
Options
The options available for the combobox widget are listed below in table.
Sr.No. | Syntax & Description |
---|---|
1 | -background color Used to set background color for widget. |
2 | -borderwidth width Used to draw with border in 3D effects. |
3 | -font fontDescriptor Used to set font for widget. |
4 | -foreground color Used to set foreground color for widget. |
5 | -textvariable varName Variable associated with the widget. When the text of widget changes, the variable is set to text of widget. |
6 | -values array Arbitrary values for combobox widget. |
7 | -width number Sets the width for widget. |
8 | -justify alignment Sets the alignment of text, which can be left, center, or right. |
9 | -state requiredState Sets the state, which can be read_only, disabled, or normal. |
10 | -postcommand command Procedure to be executed post action. |
A simple example for combobox widget is shown below −
#!/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"
When we run the above program, we will get the following output −