矩形小部件用于在画布中绘制矩形。矩形小部件的语法如下所示-
canvasName create rectangle x1 y1 x2 y2 options
x1 y1和x2 y2是矩形的端点。
Rectangle - 参数
下表列出了可用于矩形窗口小部件的选项-
| Sr.No. | Syntax & Remark |
|---|---|
| 1 |
-outline color 确定轮廓颜色。 |
| 2 |
-fill color 填充颜色用该颜色填充椭圆形。 |
| 3 |
-stipple bitmap 如果使用-fill选项,则使用点画模式。 |
| 4 |
width number 确定宽度。 |
矩形小部件的一个简单示例如下所示-
#!/usr/bin/wishcanvas .myCanvas -background red -width 200 -height 200 pack .myCanvas .myCanvas create rectangle 50 50 100 80 -fill yellow
当无涯教程运行上面的程序时,将获得以下输出-