CANVAS with Tkinter
Step 1: Import the TKinter library
from tkinter import *
Step 2: Make a window
window = Tk()
window.title("Welcome to the Loh Family app")
window.geometry('350x200')
//Add all your widgets here
//Add your canvas here
window.mainloop()
Step 3: Add Canvas
myCanvas = tkinter.Canvas(window, bg="white", height=300, width=300)
Step 4: Draw something
- Creating an Oval
oval = myCanvas.create_oval(x0, y0, x1, y1, options)
- Creating an arc
arc = myCanvas.create_arc(20, 50, 190, 240, start=0, extent=110, fill="red")
- Creating a Line
line = myCanvas.create_line(x0, y0, x1, y1, ..., xn, yn, options)
- Creating a polygon
oval = myCanvas.create_polygon(x0, y0, x1, y1, ...xn, yn, options)
- Creating a text
text = myCanvas.create_text(x0, y0,text="HELLO WORLD", fill="black", font=('Helvetica 15 bold'))
Exercise:
Try drawing the following pictures on Tkinter