当我想关闭应用程序时,我收到以下错误:
Exception _tkinter.TclError: 'invalid command name ".47045488"' in <bound method
RootJoint.__del__ of <skeleton.RootJoint object at 0x0000000002CDDBA8>> ignored
这是来自的相关部分RootJoint
:
def __init__(self, canvas):
self.parent = None
self.angle = 0.0
self.distance = 0.0
topleft = 0 - Joint.SQUARE_HALF_SIDE, 0 + Joint.SQUARE_HALF_SIDE
bottomright = 0 + Joint.SQUARE_HALF_SIDE, 0 - Joint.SQUARE_HALF_SIDE
self._joint = canvas.create_rectangle(*(topleft + bottomright))
canvas.itemconfig(self._joint, fill=RootJoint.COLOR_NORMAL)
self.canvas = canvas
def __del__(self):
self.canvas.delete(self._joint)
这是创建画布和根关节的地方:
def main():
root = tk.Tk()
root.geometry('640x480')
canvas = tk.Canvas(root)
canvas.pack(fill=tk.BOTH, expand=True)
rootjoint = skeleton.RootJoint(canvas)
root.mainloop()
为什么会出现此错误,我该如何解决?