You've got an issue working against you that isn't of your own making. The general rule is when in a turtle canvas, use turtle methods. But turtle doesn't have an inherent 'Motion' event type, so you were trying to use the raw Canvas one as a substitute. Thus the conflict.
您自己遇到的一个问题是,当您处于快速移动的事件处理程序内部时,首先需要禁用事件处理程序,然后在退出时重新启用。否则,事件会重叠并且发生坏事。 (无意的递归和其他问题。)
我已经按照您的意图重写了下面的程序,使其可以正常工作。解决方法是添加缺少的turtle方法,以便我们可以停留在turtle域内:
import tkinter as tk
from turtle import RawTurtle, TurtleScreen
from functools import partial
def onscreenmove(self, fun, add=None): # method missing from turtle.py
if fun is None:
self.cv.unbind('')
else:
def eventfun(event):
fun(self.cv.canvasx(event.x) / self.xscale, -self.cv.canvasy(event.y) / self.yscale)
self.cv.bind('', eventfun, add)<