from tkinter import *
root = Tk()
root.title("Графические примитивы")
root.minsize(width=500, height=400)
canv = Canvas(root, width=500, height=400, bg='lightgray', cursor='pencil')
canv.pack()
root.mainloop()from tkinter import *
root = Tk()
root.title("Графические примитивы")
root.minsize(width=500, height=400)
canv = Canvas(root, width=500, height=400, bg='lightgray', cursor='pencil')
canv.create_line(200,50,300,50, width=3, fill="blue")
canv.create_line(0,0,100,100, width=2, arrow=LAST)
canv.pack()
root.mainloop()from tkinter import *
root = Tk()
root.title("Графические примитивы")
root.minsize(width=500, height=400)
canv = Canvas(root, width=500, height=400, bg='lightgray', cursor='pencil')
x = 50
y = 300
canv.create_rectangle(x,y,x+80,y+50, fill="white", outline="blue")
canv.pack()
root.mainloop()from tkinter import *
root = Tk()
root.title("Графические примитивы")
root.minsize(width=500, height=400)
canv = Canvas(root, width=500, height=400, bg='lightgray', cursor='pencil')
canv.create_polygon([250,110],[200,150],[300,150], fill="red")
canv.pack()
root.mainloop()from tkinter import *
root = Tk()
root.title("Графические примитивы")
root.minsize(width=500, height=400)
canv = Canvas(root, width=500, height=400, bg='lightgray', cursor='pencil')
canv.create_polygon([250,110],[200,150],[300,150], fill="red")
canv.create_polygon([300,80],[400,80],[450,75],[450,200],[300,180],[330,160],outline="white", smooth=1)
canv.pack()
root.mainloop()from tkinter import *
root = Tk()
root.title("Графические примитивы")
root.minsize(width=500, height=400)
canv = Canvas(root, width=500, height=400, bg='lightgray', cursor='pencil')
canv.create_polygon([250,110],[200,150],[300,150], fill="red")
canv.create_polygon([300,80],[400,80],[450,75],[450,200],[300,180],[330,160],outline="white", smooth=1)
canv.create_oval([20,200],[150,300], fill="gray50") # создаем эллипс
canv.pack()
root.mainloop()from tkinter import *
root = Tk()
root.title("Графические примитивы")
root.minsize(width=500, height=400)
canv = Canvas(root, width=500, height=400, bg='lightgray', cursor='pencil')
canv.create_arc([160,230], [230,330], start=0, extent=140, fill="lightgreen")
canv.create_arc([250,230], [320,330], start=0, extent=140, style=CHORD, fill="green")
canv.create_arc([340,230], [410,330], start=0, extent=140, style=ARC, outline="darkgreen", width=2)
canv.create_text(20,330, text="Графические примитивы", font="Verdana 14", anchor="w", justify=CENTER, fill="red")
canv.pack()
root.mainloop()x=10
while x < 450:
canv.create_rectangle(x,400,x+50,450)
x = x + 60from tkinter import *
root = Tk()
root.title("Графические примитивы")
root.minsize(width=500, height=400)
c = Canvas(width=460,height=460,bg='grey80')
c.pack()
oval = c.create_oval(30,10,130,80)
rect = c.create_rectangle(180,10,280,80)
trian = c.create_polygon(330,80,380,10,430,80, fill='grey80', outline="black")
root.mainloop()from tkinter import *
root = Tk()
root.title("Графические примитивы")
root.minsize(width=500, height=400)
c = Canvas(width=460,height=460,bg='grey80')
c.pack()
oval = c.create_oval(30,10,130,80)
rect = c.create_rectangle(180,10,280,80)
trian = c.create_polygon(330,80,380,10,430,80, fill='grey80', outline="black")
c.move(rect,0,150)
c.itemconfig(trian,outline="red",width=3)
c.coords(oval,300,200,450,450)
root.mainloop()from tkinter import *
root = Tk()
root.title("Графические примитивы")
root.minsize(width=500, height=400)
c = Canvas(width=460,height=100,bg='grey80')
c.pack()
oval = c.create_oval(30,10,130,80,fill="orange")
c.create_rectangle(180,10,280,80,tag="rect",fill="lightgreen")
trian = c.create_polygon(330,80,380,10,430,80,fill='white',outline="black")
def oval_func(event):
c.delete(oval)
c.create_text(30,10,text="Здесь был круг",anchor="w")
def rect_func(event):
c.delete("rect")
c.create_text(180,10,text="Здесь был\nпрямоугольник",anchor="nw")
def triangle(event):
c.create_polygon(350,70,380,20,410,70,fill='yellow',outline="black")
c.tag_bind(oval,'<Button-1>',oval_func)
c.tag_bind("rect",'<Button-1>',rect_func)
c.tag_bind(trian,'<Button-1>',triangle)
mainloop()