python-3.x - 为什么调用 root.destroy 仍然不能继续我的循环?
问题描述
我正在创建一个棋盘游戏,并且我正在使用 Tkinter 作为 GUI 界面。我创建了这样的主循环:
while gameOn == True: #The loop
main_game_AI() #This is the actual game
root.mainloop() #This puts together the window.
root.destroy() #This closes the mainloop so the loop can continue.
但是当我运行它时,循环只迭代了一次。函数的顺序有问题吗?
解决方案
root.mainloop()
在根窗口被销毁或调用root.quit()
. root.destroy()
因此,在用户退出您的程序之前,不会调用 yoru 调用。
推荐阅读
- asp.net-core - expires_in 或 expires_at 用于 OpenId 连接中的访问令牌?
- python - matplotlib scatter 失败并出现错误:'c' 参数有 n 个元素,不能与大小为 n 的 'x' 和大小为 n 的 'y' 一起使用
- c - 从非常量 char* 数组中读取
- angular - webpack-angular : bundle 包含整个 node_modules 库
- angular - Reducer 的 @ngrx/entity EntityAdapter 函数不会更改存储状态
- matlab - 无法在条形图上应用颜色图
- angular - 使用 NgModel 对象引用更改输入值。角 5
- api - 在从空手道调用 API 之前检查底层存储过程的运行状况/可用性
- php - 在覆盖php内容期间包含什么文件?
- reactjs - 隐藏后如何拆除组件?