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
- How to Create custom Turtle shapes in Python?
- Python Tkinter - Canvas Widget
- Python Tkinter | Moving objects using Canvas.move() method
- Python | Create a GUI Marksheet using Tkinter
- Create First GUI Application using Python-Tkinter
- Create a Yes/No Message Box in Python using tkinter
- Create Copy-Move GUI using Tkinter in Python
- Create Countdown Timer using Python-Tkinter
- Python Tkinter | Create LabelFrame and add widgets to it
- Python | Create a digital clock using Tkinter
- Create Air Canvas using Python-OpenCV
- Create MySQL Database Login Page in Python using Tkinter
- How to create an empty class in Python?
- How to create a list of object in Python class
- Create Table Using Tkinter
- Create Find and Replace features in Tkinter Text Widget
- Python | Drawing different shapes on PyGame window
- Draw Color Filled Shapes in Turtle - Python
- Python GUI - tkinter
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.