有一个美好的早晨,
我正在和一位讲师一起准备机器人 Karl 的世界,以便在大学教授 Python,这不仅是熟悉的记忆。
世界已经准备就绪,应用程序使用了 TKInter 库。我有一个问题要问更有经验的 Python 专家,当我尝试在命令行中运行它时,我看到两个空的 TKInter 窗口,并显示消息“抛出异常!给定的机器人世界已经被删除”。在 IDLE 中也是如此。
由于该项目也可用于图像,因此我在这里使用存储库服务 uschovna.cz - Karel Robot保存了它。
我承认我对 TKInter 还不是很友好,但它已经被选中用于教学,所以我可能只需要在 robotswindow.py 类中添加一两个方法,一切都会正常运行。
以下是错误消息列表:
Starting with command line:
>>> from robot import *
===== Module robot.color ===== START
===== Module robot.color ===== STOP
===== Module robot.dir4 ===== START
===== Module robot.dir4 ===== STOP
===== Module robot.robotworld ===== START
===== Module robot.robotworld ===== STOP
===== Module robot.robotwindow ===== START
=== ROBOTS_ICON_DIRECTORY = '/home/wanbli/robot/IMGR/'
===== Module robot.robotwindow ===== STOP
>>> rwd = new_empty_world(3, 3)
>>> rww = create_window_for(rwd)
I see two empty TK windows and message "Exception thrown! The given robot has already been removed.".
---
Starting with IDLE:
>>> from robot import *
##### Package with classes implementing the world of the robot Karel.
===== Module robot.color ===== START
===== Module robot.color ===== STOP
===== Module robot.dir4 ===== START
===== Module robot.dir4 ===== STOP
===== Module robot.robotworld ===== START
===== Module robot.robotworld ===== STOP
===== Module robot.robotwindow ===== START
=== ROBOTS_ICON_DIRECTORY = '/home/wanbli/robot/IMGR/'
===== Module robot.robotwindow ===== STOP
>>> rwd = new_empty_world(3, 3); rwd
<robot.robotworld.RobotWorld object at 0x00000181D4D86830>
>>> rww = create_window_for(rwd); rww
Traceback (most recent call last):
File "<pyshell#17>", line 1, in <module>
rww = create_window_for(rwd); rww
File "/home/wanbli/robot/robotwindow.py", line 104, in create_window_for
window = RobotWindow(world)
File "/home/wanbli/robot/robotwindow.py", line 34, in __init__
for _ in range(world.rows)]
File "/home/wanbli/robot/robotworld.py", line 202, in rows
self._check_world_alive()
File "/home/wanbli/robot/robotworld.py", line 382, in _check_world_alive
raise RWError(msg)
robot.robotworld.RWError:
The robot world in question has already been removed.
你知道如何解决这个问题吗?
卢德克·斯塔斯特尼