tkinter TclError:读取位图文件时出错 [英] tkinter TclError: error reading bitmap file

查看:3036
本文介绍了tkinter TclError:读取位图文件时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置这样的应用程序图标(python3 / tkinter):

I am trying to set an application icon (python3 / tkinter) like this:

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

无论我做什么,我都会收到一条错误消息(闲置),说:

no matter what I do, I keep getting an error message (Idle), saying:

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

什么我做错了吗?

推荐答案

问题不是代码,而是图标。我尝试用另一个程序创建一个 xbm 而不是Gimp(一些KDE图标编辑器),虽然看起来很丑陋,但它确实显示了一个图标。
我想我必须找到一个为我的Python程序提供可理解图标的创建者。

The problem is not the code, but the icon. I tried creating an xbm with another program than Gimp (some KDE icon editor), and although it looks terrifyingly ugly, it does show an icon. I guess I have to find a creator that gives an "understandable" icon for my Python program.

iconbitmap 方法结果只是黑色和白色,所以它毕竟没用。

The iconbitmap method turned out to be black and white only, so it was useless after all.

经过长时间的搜索后,我找到了设置的解决方案Python 3的应用程序图标的颜色(在Linux上)。我发现它这里

After a long search, I found the solution to set the color of an application's icon for Python 3 (on Linux). I found it here:

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

这篇关于tkinter TclError:读取位图文件时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆