0
我可以跟蹤這些用戶的點擊和他們釋放,但我想跟蹤行駛距離。如何找到行駛距離的Tkinter ButtonPress
從Tkinter的進口* 根= Tk的()類DragCursor()
:
def __init__(self, location):
self.label = location
location.bind('<ButtonPress-1>', self.StartMove)
location.bind('<ButtonRelease-1>', self.StopMove)
def StartMove(self, event):
startx = event.x
starty = event.y
print [startx, starty]
def StopMove(self, event):
self.StartMove
stopx = event.x
stopy = event.y
print [stopx, stopy]
location = Canvas(root, width = 300, height = 300)
DragCursor(location)
location.pack()
root.mainloop()
你的代碼示例的縮進被搞砸了。 – 2013-05-01 11:26:42