【问题标题】:Using an image as a button in Python 3.5 Tkinter在 Python 3.5 Tkinter 中使用图像作为按钮
【发布时间】:2016-06-02 20:37:39
【问题描述】:

使用 tkinter,如何制作一个不是文字的图片按钮?

【问题讨论】:

  • Image on a button的可能重复
  • 互联网上一定有数以百万计的示例,并且此功能已被广泛记录。在问这样一个基本问题之前,你应该做一些研究。

标签: python button tkinter python-3.5


【解决方案1】:

一些搜索显示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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-20
    • 2022-01-18
    • 1970-01-01
    • 1970-01-01
    • 2019-04-20
    • 2012-01-05
    • 1970-01-01
    相关资源
    最近更新 更多