Python 3 Tkinter Canvas Class Tutorial to Draw Circle,Rectangles,Arcs,Oval and Lines Shapes in GUI Desktop Full Project For Beginners

Python 3 Tkinter Canvas Class Tutorial to Draw Circle,Rectangles,Arcs,Oval and Lines Shapes in GUI Desktop Full Project For Beginners

 

Welcome folks today in this blog post we will be looking at canvas class to draw cricle,rectangles,arcs,ovals and lines shapes in tkinter gui desktop app in python. All the full source code of the application is given below.

 

 

Get Started

 

 

In order to get started you need to install the below library using the pip command as shown below

 

pip install tkinter

 

After installing this library you need to make an app.py file and copy paste the following code

 

app.py

 

import tkinter as tk

window = tk.Tk()

canvas = tk.Canvas(window, bg="white", width=300, height=300)

canvas.pack()

canvas.create_oval((0, 0, 300, 300), fill="yellow")

canvas.create_arc((50, 100, 100, 150), extent=180, fill="black")

canvas.create_arc((200, 100, 250, 150), extent=180, fill="black")

canvas.create_line((50, 200, 110, 240), fill="red", width=5)
canvas.create_line((110, 240, 190, 240), fill="red", width=5)
canvas.create_line((190, 240, 250, 200), fill="red", width=5)

window.mainloop()

 

See also  Python 3 Tkinter Whatsapp Web API Bot to Send Bulk SMS Messages to Multiple Contact From Excel & CSV File GUI Desktop App Full Project For Beginners

 

If you execute the above python script by typing the below command

 

python app.py

 

 

Leave a Reply