【问题标题】:Icon does not appear when I use iconbitmap()使用 iconbitmap() 时图标不出现
【发布时间】:2021-01-04 22:02:45
【问题描述】:

操作系统:Linux - Ubantu

我使用的图片:最初是 .ico,但我在线转换为 .xbm

我尝试了不同的图片和不同的网站,但似乎没有任何效果

代码:

from tkinter import *
from PIL import ImageTk, Image

root = Tk()

root.title("B")
root.iconbitmap('@/home/zaki/Pictures/mar.xbm')


root.mainloop()

窗口正常显示,但没有图标

【问题讨论】:

  • 使用 ico 代替 xbm?或者去here

标签: python image user-interface tkinter python-imaging-library


【解决方案1】:

尝试使用iconphoto() 方法。

from tkinter import *

root = Tk()

img = PhotoImage(file="image.png")  # Replace "image.png" with any image file.
root.iconphoto(False, img)

root.mainloop()

在带有 Python 3.6 的 Ubuntu 18.04 上工作。

参考资料: https://www.geeksforgeeks.org/iconphoto-method-in-tkinter-python/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-23
    • 2022-10-01
    相关资源
    最近更新 更多