python - _tkinter.TclError:图像“.64485752”不存在
问题描述
我写了一个重启程序,但它不起作用
retry = Button(text="play again", width=11, bg="black", fg="grey99", command=restart)
retry.pack()
重启功能如下
def restart():
global window
window.destroy() # destroy and create a new one
window = Tk()
global screenheight
global screenwidth
screenwidth = window.winfo_screenwidth()
screenheight = window.winfo_screenheight()
window.geometry("{0}x{1}+0+0".format(window.winfo_screenwidth(), window.winfo_screenheight()))
window.title("Predict future")
canvas = Canvas(window, width=screenwidth, height=screenwidth, bg="ghost white")
canvas.place(x=500, y=300)
taiji = PhotoImage(file="taiji.gif")
taijitu = Label(image=taiji)
intro = Button(window, image=taijitu, command=New)
intro.place(x=-120, y=-60)
所以它只是破坏旧的并创建一个新窗口,但照片图像没有显示(我猜它已经被垃圾收集了)。
解决方案
推荐阅读
- c# - Nunit-Console:有没有办法使用带有命令行选项的测试选择语言
- apache-flink - flink 1.10 DataStream API 中的 JSON 数据聚合
- javascript - 使用 Vuejs 嵌套 v-for
- javascript - 如何从子组件更改父组件的状态?
- javascript - jQuery val() 给出奇怪的输出
- mongodb - Spring Data Mongo - 在嵌入文档中应用唯一的组合字段
- arrays - 无法将类型“[ArrayImages]”的值转换为预期的参数类型“[UIImage?]”
- python - 在 python 3 中获取 REST API 服务器响应时间
- excel - 对文件夹中的所有文件运行 excel 宏脚本
- r - R Plotly - 带有条形总数的堆叠条形图