
- 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
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Tk - Basic Widgets
Basic widgets are common widgets available in almost all Tk applications. The list of available basic widgets is given below −
Sr.No. | Widgets & Description |
---|---|
1 | Label
Widget for displaying single line of text. |
2 | Button
Widget that is clickable and triggers an action. |
3 | Entry
Widget used to accept a single line of text as input. |
4 | Message
Widget for displaying multiple lines of text. |
5 | Text
Widget for displaying and optionally edit multiple lines of text. |
6 | Toplevel
Widget used to create a frame that is a new top level window. |
A simple Tk example is shown below using basic widgets −
#!/usr/bin/wish grid [label .myLabel -text "Label Widget" -textvariable labelText] grid [text .myText -width 20 -height 5] .myText insert 1.0 "Text\nWidget\n" grid [entry .myEntry -text "Entry Widget"] grid [message .myMessage -background red -foreground white -text "Message\nWidget"] grid [button .myButton1 -text "Button" -command "set labelText clicked"]
When we run the above program, we will get the following output −

Advertisements