- Tcl - Regular Expressions
- Tcl - Built-in Functions
- Tcl - Error Handling
- Tcl - File I/O
- Tcl - Namespaces
- Tcl - Packages
- Tcl - Procedures
- Tcl - Dictionary
- Tcl - Lists
- Tcl - Strings
- Tcl - Arrays
- Tcl - Loops
- Tcl - Decisions
- Tcl - Operators
- Tcl - Variables
- Tcl - Data Types
- Tcl - Commands
- Tcl - Basic Syntax
- Tcl - Special Variables
- Tcl - Environment Setup
- Tcl - Overview
- Tcl - Home
Tk Tutorial
- Tk - Geometry Manager
- Tk - Windows Manager
- Tk - Events
- Tk - Images
- Tk - Fonts
- Tk - Mega Widgets
- Tk - Canvas Widgets
- Tk - Selection Widgets
- Tk - Layout Widgets
- Tk - Basic Widgets
- Tk - Widgets Overview
- Tk - Special Variables
- Tk - Environment
- Tk - Overview
Tcl/Tk Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Tk - Images
The image widget is used to create and manipulate images. The syntax for creating image is as follows −
image create type name options
In the above syntax type is photo or bitmap and name is the image identifier.
Options
The options available for image create are psted below in the following table −
Sr.No. | Syntax & Description |
---|---|
1 | -file fileName The name of the image file name. |
2 | -height number Used to set height for widget. |
3 | -width number Sets the width for widget. |
4 | -data string Image in base 64 encoded string. |
A simple example for image widget is shown below −
#!/usr/bin/wish image create photo imgobj -file "/Users/rajkumar/Desktop/F Drive/pictur/vb/Forests/ 680049.png" -width 400 -height 400 pack [label .myLabel] .myLabel configure -image imgobj
When we run the above program, we will get the following output −
The available function for image are psted below in the following table −
Sr.No. | Syntax & Description |
---|---|
1 | image delete imageName Deletes the image from memory and related widgets visually. |
2 | image height imageName Returns the height for image. |
3 | image width imageName Returns the width for image. |
4 | image type imageName Returns the type for image. |
5 | image names Returns the pst of images pve in memory. |
A simple example for using the above image widget commands is shown below −
#!/usr/bin/wish image create photo imgobj -file "/Users/rajkumar/images/680049.png" -width 400 -height 400 pack [label .myLabel] .myLabel configure -image imgobj puts [image height imgobj] puts [image width imgobj] puts [image type imgobj] puts [image names] image delete imgobj
The image will be deleted visually and from memory once "image delete imgobj" command executes. In console, the output will be pke the following −
400 400 photo imgobj ::tk::icons::information ::tk::icons::error ::tk::icons:: warning ::tk::icons::questionAdvertisements