পৃষ্ঠাসমূহ

Search Your Article

CS

 

Welcome to GoogleDG – your one-stop destination for free learning resources, guides, and digital tools.

At GoogleDG, we believe that knowledge should be accessible to everyone. Our mission is to provide readers with valuable ebooks, tutorials, and tech-related content that makes learning easier, faster, and more enjoyable.

What We Offer:

  • 📘 Free & Helpful Ebooks – covering education, technology, self-development, and more.

  • 💻 Step-by-Step Tutorials – practical guides on digital tools, apps, and software.

  • 🌐 Tech Updates & Tips – simplified information to keep you informed in the fast-changing digital world.

  • 🎯 Learning Support – resources designed to support students, professionals, and lifelong learners.

    Latest world News 

     

Our Vision

To create a digital knowledge hub where anyone, from beginners to advanced learners, can find trustworthy resources and grow their skills.

Why Choose Us?

✔ Simple explanations of complex topics
✔ 100% free access to resources
✔ Regularly updated content
✔ A community that values knowledge sharing

We are continuously working to expand our content library and provide readers with the most useful and relevant digital learning materials.

📩 If you’d like to connect, share feedback, or suggest topics, feel free to reach us through the Contact page.

Pageviews

Tuesday, April 4, 2017

Tk - Canvas Widgets

Canvas is used for providing drawing areas. The syntax for canvas widget is shown below −
canvas canvasName options

Options

The options available for the canvas widget are listed below in the following table −
S.No. Syntax & Description
1 -background color
Used to set background color for widget.
2 -closeenough distance
Sets the closeness of mouse cursor to a displayable item. The default is 1.0 pixel. This value may be a fraction and must be positive.
3 -scrollregion boundingBox
The bounding box for the total area of this canvas.
4 -height number
Used to set height for widget.
5 -width number
Sets the width for widget.
6 -xscrollincrement size
The amount to scroll horizontally when scrolling is requested.
7 -yscrollincrement size
The amount to scroll vertically when scrolling is requested.
A simple example for canvas widget is shown below −
#!/usr/bin/wish

canvas .myCanvas -background red -width 100 -height 100 
pack .myCanvas
When we run the above program, we will get the following output −
Canvas Widget Example

Widgets for Drawing in Canvas

The list of the available widgets for drawing in canvas is listed below −
S.No. Widget & Description
1 Line Draws a line.
2 Arc Draws an arc.
3 Rectangle Draws a rectangle.
4 Oval Draws an oval.
5 Polygon Draws a polygon.
6 Text Draws a text.
7 Bitmap Draws a bitmap.
8 Image Draws an image.
An example using different canvas widgets is shown below −
#!/usr/bin/wish

canvas .myCanvas -background red -width 200 -height 200 
pack .myCanvas
.myCanvas create arc 10 10 50 50 -fill yellow
.myCanvas create line 10 30 50 50 100 10 -arrow both -fill yellow -smooth true
   -splinesteps 2
.myCanvas create oval 50 50 100 80 -fill yellow
.myCanvas create polygon 50 150 100 80 120 120 100 190 -fill yellow -outline green
.myCanvas create rectangle 150 150 170 170  -fill yellow
.myCanvas create text 170 20 -fill yellow -text "Hello" -font {Helvetica -18 bold}
.myCanvas create bitmap 180 50 -bitmap info
When we run the above program, we will get the following output −
Canvas Widget Example2

No comments:

Post a Comment