python - 如何在按钮中制作图像?
问题描述
我是这个网站的新手,但我有一个问题。这是我在 Tkinter 中的代码。我的问题是,当我将图像放入按钮时,它不会显示它。只有在这个程序中,因为如果我在一个新的干净文件中写同样的东西,它就可以工作。有什么问题 ?
def newWindow():
root.destroy() #this destroy the main window
window = Tk()
window.title("Provisory title")
window.resizable(False,False)
window.geometry("420x430")
#BUTTON
bt3 = Button(window)
#BUTTON POSITIONING
bt3.place(x = 10, y = 10)
#image button
calc = PhotoImage(file= "icon_Calculator.png")
bt3.config(image = calc, width="100",height="100")
解决方案
推荐阅读
- python - 使用来自具有特定列值的另一个数据框的行创建一个新的数据框
- c# - 如何使用 MessageWebSocket 发送 ping 以保持与服务器的连接
- json - 动态键值的json解析中的颤振问题
- javascript - Javascript仅操作多个组件中的一个
- google-apps-script - 未找到脚本函数:doGet (AGAIN !!! )
- html - 从输入中移除焦点时的css选择器
- xamarin - AndroidX 迁移错误 Android.Content.Res.Resources+NotFoundException: 'Resource ID #0x7f0b0047'
- python - 用户输入 n 的值后如何创建 n 个 tkinter 文本小部件
- javascript - 回调返回的对象本身没有运行方法
- asp.net-mvc - 在公共静态无效 mvc 属性中尝试捕获异常处理后,我如何拒绝继续子代码行