From the course: Python GUI Development with Tkinter
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Drawing complex shapes on the Canvas
From the course: Python GUI Development with Tkinter
Drawing complex shapes on the Canvas
- [Instructor] In addition to drawing lines, we can also draw a number of different shapes to the canvas, including rectangles, ovals, arcs, and polygons. In this video, we'll continue with the example canvas created in the previous video to learn how to draw those shapes, images, and other widgets to the canvas. We'll also learn how to control the order of items on the canvas and how to apply tags to them. The first item I want to show you is the rectangle. To draw a rectangle on the canvas, we use the canvas's create_rectangle function. The rectangle method takes four different parameters and those are X,Y pairs of coordinates for the two opposite corners of the rectangle. So if I pass in the coordinates, 160 and 120, that'll represent one corner of my rectangle, and then I'll pass in two more coordinates of 480 and 360, and those will represent the other corner of my rectangle. And so this method creates the rectangle object. And I've stored it to a variable. After that I can…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
Entering and displaying multiple lines with the Text widget11m 31s
-
(Locked)
Adding tags, marks, images, and widgets to the Text widget9m 57s
-
(Locked)
Building a hierarchical treeview7m 19s
-
(Locked)
Adding columns and selecting items in the Treeview7m 12s
-
(Locked)
Building cascading menus11m 5s
-
(Locked)
Drawing a basic line on the Canvas5m 21s
-
(Locked)
Drawing complex shapes on the Canvas9m 58s
-
(Locked)
Attaching a scroll bar to widgets6m 21s
-
(Locked)
Configuring widget styles9m 49s
-
(Locked)
Prompting users with the Messagebox and dialogs6m 11s
-
(Locked)
-
-
-
-