Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter
- def destroy():
- destroy_object = [e1, e2, e3, e4, button, label1, label2, label3, label4, canvas]
- for object_name in destroy_object:
- object_name.destroy()
- e1.delete(0, 'end')
- e2.delete(0, 'end')
- e3.delete(0, 'end')
- e4.delete(0, 'end')
- prepare()
- def draw():
- canvas.grid(row=4, column=0, columnspan=4)
- master.geometry("450x450")
- x1 = int(e1.get())
- y1 = int(e3.get())
- x2 = int(e2.get())
- y2 = int(e4.get())
- canvas.create_oval(x1, y1, x2, y2)
- master.bind("<KeyPress>", handle_keypress)
- master = tkinter.Tk()
- label = tkinter.Label(master)
- entry = tkinter.Entry(master)
- master.geometry("150x150")
- canvas = tkinter.Canvas(master, bg="white")
- def handle_keypress(event):
- if event.keysym == "space":
- destroy()
- canvas.bind("<KeyPress>", handle_keypress)
- def prepare():
- global e1, e2, e3, e4, button, label1, label2, label3, label4
- label1 = tkinter.Label(text="X1")
- label1.grid(row=0, column=0)
- e1 = tkinter.Entry(master, width=5)
- e1.grid(row=0, column=1)
- label2 = tkinter.Label(text="X2")
- label2.grid(row=1, column=0)
- e2 = tkinter.Entry(master, width=5)
- e2.grid(row=1, column=1)
- label3 = tkinter.Label(text="Y1")
- label3.grid(row=0, column=2)
- e3 = tkinter.Entry(master, width=5)
- e3.grid(row=0, column=3)
- label4 = tkinter.Label(text="Y2")
- label4.grid(row=1, column=2)
- e4 = tkinter.Entry(master, width=5)
- e4.grid(row=1, column=3)
- button = tkinter.Button(master, text="Создать Овал", command=draw)
- button.grid(row=3, column=0, columnspan=4)
- prepare()
- master.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement