首页 > 解决方案 > 如何在按钮中制作图像?

问题描述

我是这个网站的新手,但我有一个问题。这是我在 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")

标签: pythonimagebuttontkinter

解决方案


推荐阅读