将TurtleScreen添加到画布:“顶级”对象没有属性“调用”

我正在尝试将TurtleScreen添加到tkinter Canvas中。下面的代码显示了我正在使用它的功能的开始,直到它中断为止:

def draw():
    top = Toplevel()
    top.title("Your Drawing!")
    canvas = Canvas(top)
    canvas.pack()
    ts = turtle.TurtleScreen(canvas)  # this is the line causing an exception (line 36 in traceback)

这是回溯:

Exception in Tkinter callback
Traceback (most recent call last):
  File "/Users/Blake/anaconda3/lib/python3.7/tkinter/__init__.py",line 1705,in __call__
    return self.func(*args)
  File "GUI.py",line 36,in draw
    ts = turtle.TurtleScreen(canvas)
  File "/Users/Blake/anaconda3/lib/python3.7/turtle.py",line 1001,in __init__
    rootwindow.call('wm','attributes','.','-topmost','1')
AttributeError: 'Toplevel' object has no attribute 'call'

我不知道为什么要尝试调用Toplevel对象(我假设它正在尝试调用top对象)。据我从the docs所知,我做的正确。怎么了?

wgq82265218 回答:将TurtleScreen添加到画布:“顶级”对象没有属性“调用”

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2919977.html

大家都在问