python-3.x – tkinter TclError:读取位图文件的错误

栏目: Python · 发布时间: 7年前

内容简介:http://stackoverflow.com/questions/11176638/tkinter-tclerror-error-reading-bitmap-file

我试图设置一个应用程序图标(python3 / tkinter),如下所示:

Interface()
root.title("Quicklist Editor")
root.iconbitmap('@/home/jacob/.icons/qle_icon.ico')
root.resizable(0, 0)
root.mainloop()

不管我做什么,我会收到一条错误消息(Idle),说:

return self.tk.call('wm', 'iconbitmap', self._w, bitmap)
_tkinter.TclError: error reading bitmap file "/home/jacob/.icons/qle_icon.ico"

我究竟做错了什么?

问题不在于代码,而是图标.我尝试用Gimp(一些KDE图标编辑器)创建另一个程序的xbm,尽管它看起来很可怕,但却显示出一个图标.

我想我必须找到一个创建者,为我的 Python 程序提供一个“可理解”的图标.

编辑

iconbitmap方法只是黑色和白色,所以没有用.

经过漫长的搜索,我找到了解决方案来设置Python 3应用程序图标的颜色(在 Linux 上).我发现它 here

root = Tk()
img = PhotoImage(file='your-icon')
root.tk.call('wm', 'iconphoto', root._w, img)

http://stackoverflow.com/questions/11176638/tkinter-tclerror-error-reading-bitmap-file


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

The Nature of Code

The Nature of Code

Daniel Shiffman / The Nature of Code / 2012-12-13 / GBP 19.95

How can we capture the unpredictable evolutionary and emergent properties of nature in software? How can understanding the mathematical principles behind our physical world help us to create digital w......一起来看看 《The Nature of Code》 这本书的介绍吧!

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具