如何使用图像作为按钮功能Tkinter

问题描述

原始代码

search_button = Button(Frame3,text="Search",command=lambda: displaySelected(),bg="black",fg="white",font=('Arial',10),padx=5,pady=5)
search_button.place(x=210,y=190)

原始输出如何: Click to view for better visualisation (focus on the blue circle,ignore the other features there)

displaySelected()的作用是: Basically show data based on the Country and Institution user selects

我尝试过的事情:

search_pic = PhotoImage(file="search.png")
search_button = Button(Frame3,image=search_pic,y=190)

基本上,我想执行相同的功能,只是我不想使用按钮“搜索”,而是希望将其替换为png文件,以获取更好的外观。但是,当我运行代码时,由于某种原因我的png没有显示出来?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)