📅  最后修改于: 2022-03-11 14:45:38.458000             🧑  作者: Mango
import tkinter as tk
root = tk.Tk()
root.geometry("400x400")
frame = tk.Frame()
frame.master.title("UI PNC")
def XL(event):
print("Position:", event.x,event.y)
canvas=tk.Canvas(frame)
canvas.create_rectangle(20,20,200,200,fill="red",tags="UI")
canvas.tag_bind("UI","",XL)
canvas.pack(expand=True, fill="both")
frame.pack(expand=True, fill="both")
root.mainloop()