【发布时间】:2016-06-02 20:37:39
【问题描述】:
使用 tkinter,如何制作一个不是文字的图片按钮?
【问题讨论】:
-
Image on a button的可能重复
-
互联网上一定有数以百万计的示例,并且此功能已被广泛记录。在问这样一个基本问题之前,你应该做一些研究。
标签: python button tkinter python-3.5
使用 tkinter,如何制作一个不是文字的图片按钮?
【问题讨论】:
标签: python button tkinter python-3.5
一些搜索显示Image on a button。它使用PhotoImage 函数。解释其中包含的一些代码:
from Tkinter import * # Import tkinter
root=Tk() # Create an instance using Tk()
b=Button(root,justify = LEFT) # Create a button
photo=PhotoImage(file="mine32.gif") # Give photo an image
b.config(image=photo,width="10",height="10") # Configure the earlier instance to use the photo
b.pack(side=LEFT) # Pack up the button
root.mainloop() # Create everything
【讨论】: