Learn Python tkinter GUI canvases easy 🖍️

preview_player
Показать описание
Python, canvas, 2D graphics, tutorial, beginners,

#Python #2D #canvas #graphics #widget #tutorial #beginners
Рекомендации по теме
Комментарии
Автор

# canvas = widget that is used to draw graphs, plots, images in a window

from tkinter import *

window = Tk()

canvas = Canvas(window, height=500, width=500)
#canvas.create_line(0, 0, 500, 500, fill="blue", width=5)
#canvas.create_line(0, 500, 500, 0, fill="red", width=5)
#canvas.create_rectangle(50, 50, 250, 250, fill="purple")
#points = [250, 0, 500, 500, 0, 500]
#canvas.create_polygon(points, fill="yellow", outline="black", width=5)
#canvas.create_arc(0, 0, 500, 500, style=PIESLICE, start=270, width=5)
canvas.create_arc(0, 0, 500, 500, fill="red", extent=180, width=10)
canvas.create_arc(0, 0, 500, 500, fill="white", extent=180, start=180, width=10)
canvas.create_oval(190, 190, 310, 310, fill="white", width=10)
canvas.pack()

window.mainloop()

BroCodez
Автор

for the white hemisphere you can also do extent= -180 and not add in the start

aaronellman
Автор

Hi, I have added into Notebook the 3 Tabs, in one Tab window is located canvas. My question is how to determine the height and width of the canvas in the tab?
I will use these parameters to draw some elements.

elektropuls
Автор

whats the app/website hes using to create??

hetpatel
Автор

Bro I have a question about previous lesson. Why bg, fg and font attributes not working in labels and buttons?

shahzodsayfiddinov