- 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 - Canvas Polygon Widget
Polygon widget is used to draw a polygon shape in canvas. The syntax for polygon widget is shown below −
canvasName create polygon x1 y1 x2 y2 ... xn yn options
x1 y1 and x2 y2 ... xn yn are used to determine the end points of a polygon.
Options
The options available for the polygon widget are listed below in the following table −
Sr.No. | Syntax & Description |
---|---|
1 | -outline color Determines the outline color. |
2 | -fill color The fill color fills the oval with the color. |
3 | -stipple bitmap The stipple pattern to use if the -fill option is being used. |
4 | -width number Determines the width. |
5 | -smooth boolean This can be set to true make the line segments to be rendered with a set of Bezier splines. |
6 | -splinesteps number Determines the number of line segment for bezier splines. |
A simple example for polygon widget is shown below −
#!/usr/bin/wish canvas .myCanvas -background red -width 200 -height 200 pack .myCanvas .myCanvas create polygon 50 50 100 80 120 120 100 190 -fill yellow -outline green
When we run the above program, we will get the following output −