0
我想製作一個程序,點擊該程序將刪除封閉區域中的所有對象。Python/Tkinter - 刪除封閉區域中的所有對象
這裏是我的示例代碼:
import tkinter as tk
root = tk.Tk()
cv = tk.Canvas(root, height=400, width=400)
cv.pack()
cv.create_rectangle(50, 50, 100, 100)
cv.create_line(60, 60, 80, 80)
cv.create_line(60, 80, 80, 60)
def onclick():
todel = cv.find_enclosed(50, 50, 100, 100)
cv.delete(todel)
cv.bind("<Button-1>", onclick())
root.mainloop()
在單擊它應該刪除在矩形的兩條線,但由於某些原因,它沒有。我怎樣才能做到這一點?
感謝所有的項目!有效 – Leero11