python - Tkinter“pyimage5 不存在”
问题描述
我已经查看了几个类似的问题,但没有任何效果。我有一个 Tkinter 程序,按下按钮时会打开第二个窗口。第一个窗口中的所有图像都很好,但是当我打开第二个窗口时,当我要制作一个带有图像的按钮时,我会收到以下错误消息:
_tkinter.TclError: image "pyimage5" doesn't exist
图像的定义和存储方式如下:
add_icon = PhotoImage(file = 'data/add_icon.gif'), subtract_icon = PhotoImage(file = 'data/subtract_icon.gif')
他们是这样称呼的:
Button(edit, image = add_icon, command = add_new_pref, relief = FLAT) .grid(row = 2, column = 0, sticky = NSEW) Button(edit, image = subtract_icon, command = remove_pref, relief = FLAT) .grid(row = 3, column = 0, sticky = NSEW)
图像是在创建新窗口后定义的。有任何想法吗?
解决方案
推荐阅读
- angular - 检测 Angular 应用程序中缺失的增强导入
- c# - 如何从 Windows 窗体中的另一个类修改 PictureBox?C#
- javascript - 我已经从 javascript 将表格附加到 html 中,但现在我想通过传递它们的 id 从字体真棒图标调用 onclick 函数
- oauth-2.0 - oauth 2.0 - Resource owner password flow, can use windows login user credentials
- r - 在 Tidyverse 管道中使用汇总值进行归一化
- c# - wpf 列表框绑定 XElement 未更新
- android - TouchableOpacity onPress 在 Android 上不起作用
- max - 最大运费 prestashop 1.7
- phpstorm - Why is yarn not found as a package manager in PhpStorm?
- google-apps-script - appmaker 中的手风琴