我试图不明白为什么当我在画布中画线表示鼠标位置时,create_rectangle activefill 不起作用
有人可以解释我为什么吗?
非常感谢
from tkinter import *
def drawmouseposition(event):
canvas.delete('mousepos')
dashes = [5, 25]
x = canvas.create_line(event.x, 0, event.x, 1000, dash=dashes, tags='mousepos')
y = canvas.create_line(0, event.y, 1000, event.y, dash=dashes, tags='mousepos')
root = Tk()
root.rowconfigure(0, weight=1)
root.columnconfigure(0, weight=1)
canvas = Canvas(root)
canvas.grid(row=0,column=0, sticky="nsew", '+')
canvas.bind('<Motion>', drawmouseposition)
rec = canvas.create_rectangle(10,10,100,100, activefill='red')
root.mainloop()