- 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 - Radio Button Widget
Radio button widget implements a multiple-choice button, which is a way to offer many possible selections to the user and lets user choose only one of them. The syntax for radio button widget is shown below −
radiobutton radiobuttonName options
Options
The options available for the radio button widget are listed below in the following table −
Sr.No. | Syntax & Description |
---|---|
1 | -font fontDescriptor Used to set font for widget. |
2 | -height number Used to set height for widget. |
3 | -command action Sets the command action for button. |
4 | -text text Sets the text for the widget. |
5 | -width number Sets the width for widget. |
6 | -variable variableName Sets the variable for widget. |
7 | -value variableValue Sets the variable with variable value. |
A simple radio button widget example is shown below −
#!/usr/bin/wish grid [frame .gender ] grid [label .myLabel -text "Male" -textvariable myLabel1 ] grid [radiobutton .gender.maleBtn -text "Male" -variable gender -value "Male" -command "set myLabel1 Male"] -row 1 -column 2 grid [radiobutton .gender.femaleBtn -text "Female" -variable gender -value "Female" -command "set myLabel1 Female"] -row 1 -column 3 .gender.maleBtn select
When we run the above program, we will get the following output −
tk_selection_widgets.htm
Advertisements