Canvas class is used to create different shapes with the help of some functions which are defined under Canvas class. Any shape that Canvas class creates requires a canvas, so before creating any shapes a Canvas object is required and needs to be packed to the main window.
Canvas Methods for shapes:
Canvas.create_oval(x1, y1, x2, y2, options = …): It is used to create a oval, pieslice and chord.
Canvas.create_rectangle(x1, y1, x2, y2, options = …): It is used to create rectangle and square.
Canvas.create_arc(x1, y1, x2, y2, options = …) This is used to create an arc.
Canvas.create_polygon(coordinates, options = …) THis is used to create any valid shapes.
We are using a class to show the working of functions that helps to creates different shapes.
Class parameters –
Data members used: master, canvas
Member functions used:
Widgets used: Canvas
Tkinter method used:
Below is the Python code –
- Python Tkinter | Create different type of lines using Canvas class
- Python Tkinter | Moving objects using Canvas.move() method
- Python Tkinter | Create LabelFrame and add widgets to it
- Python | Create a digital clock using Tkinter
- How to create a list of object in Python class
- Python | Drawing different shapes on PyGame window
- Python GUI - tkinter
- Different messages in Tkinter | Python
- Python | after method in Tkinter
- RadioButton in Tkinter | Python
- minsize() method in Tkinter | Python
- Python | Loan calculator using Tkinter
- Python | grid() method in Tkinter
- Collapsible Pane in Tkinter | Python
- iconphoto() method in Tkinter | Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.