Python 3 Tkinter Canvas Widget Example Script to Build PieChart Using Arcs GUI Desktop App Full Project For Beginners

Python 3 Tkinter Canvas Widget Example Script to Build PieChart Using Arcs GUI Desktop App Full Project For Beginners

 

Welcome folks today in this blog post we will be building a pie chart using canvas widget in tkinter using python. All the full source code of the application is given below.

 

 

Get Started

 

 

In order to get started just create an app.py file and copy paste the following code

 

Basic Example of Canvas Widget

 

app.py

 

from tkinter import *   
  
# window named top
top = Tk()  
# set height and width of window 
top.geometry("300x300")  
  
#creating a simple canvas with canvas widget  
cv = Canvas(top, bg = "yellow", height = "300")  
  
cv.pack()  
  
top.mainloop()

 

 

 

 

pie chart using arcs

 

app.py

 

import tkinter

# init tk
root = tkinter.Tk()

# creating canvas
mCanvas = tkinter.Canvas(root, bg="white", height=300, width=300)

# drawing two arcs
coord = 10, 10, 300, 300
arc1 = mCanvas.create_arc(coord, start=0, extent=150, fill="pink")
arc2 = mCanvas.create_arc(coord, start=150, extent=215, fill="blue")

# adding canvas to window and display it
mCanvas.pack()
root.mainloop()

 

See also  Python Tkinter GUI Script to Make a Windows Notepad to Make Notes Full Project For Beginners

 

Leave a Reply