Canvas Widget
- Now, when we create an image, there's a couple of things which are required. The first thing is the X and Y positions of this image in the canvas. Given that we have a width of 200 and a height of 224, I want my image to be bang in the center of the canvas. So I can provide the X value as half of the width and the Y value as half of the height.
- PhotoImage(): this class comes from tkinter and it's basically a way to read through a file and to get hold of a particular image at a particular file location.
window = Tk()
window.title("Pomodoro")
window.config(padx=100, pady=50, bg=YELLOW)
canvas = Canvas(width=200, height=224, bg=YELLOW, highlightthickness=0)
tomato_img = PhotoImage(file="tomato.png")
canvas.create_image(100, 112, image=tomato_img)
canvas.create_text(100, 130, text="00:00", fill="white", font=(FONT_NAME, 35, "bold"))
canvas.pack()