- 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 - Grid Widget
The grid widget used to layout widgets in specific rows and columns. The syntax for grid widget is shown below −
grid gridName options
Options
The options available for the grid widget are listed below in the following table −
Sr.No. | Syntax & Description |
---|---|
1 | -column number Sets the column position for widget. |
2 | -row number Sets the row position for widget. |
3 | -columnspan number Number of columns to be used for this widget. Defaults to 1. |
4 | -rowspan number Number of rows to be used for this widget. Defaults to 1. |
5 | -sticky side Sets the edge of the cell to which the widget should stick to. Valid values can be n for top, s for bottom, e for right, w for left, or a combination of these letters. |
A simple example for grid widget is shown below −
#!/usr/bin/wish frame .myFrame1 -background red -relief ridge -borderwidth 8 -padx 10 -pady 10 -height 100 -width 100 frame .myFrame2 -background blue -relief ridge -borderwidth 8 -padx 10 -pady 10 -height 100 -width 50 grid .myFrame1 -columnspan 10 -rowspan 10 -sticky w grid .myFrame2 -column 10 -row 2
When we run the above program, we will get the following output −
tk_layout_widgets.htm
Advertisements