编译python代码时如何包含图标文件? [英] How do I include icon files when compiling my python code?

查看:86
本文介绍了编译python代码时如何包含图标文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够为可执行文件设置常规图标,但是,我在正确编译代码时遇到问题,因此当我使用tkinter为新窗口调用该文件时,它会显示图标文件(例如帮助,关于等).

I am able to set the general Icon for the executable, however, I am having issues compiling the code correctly so that it displays the icon file when I call it for new windows with tkinter (like help, about, etc.).

我的代码如下:

Window.iconbitmap(r'snake.ico')

感谢您的帮助!谢谢.

推荐答案

感谢@ acw1668的帮助!答案是:

Thank you for the help @acw1668! The answer is:

  1. 将png或ico转换为base64,例如 https://onlinepngtools.com/convert-png-to-base64 (其他转换工具提供了HTML等转换功能.请确保在开始时删除"data:...".仅使用原始文本.)

  1. convert png or ico to base64 e.g. https://onlinepngtools.com/convert-png-to-base64 (Other convert tools offer conversion for HTML etc. make sure to delete 'data:...' at the beginning. Use only the raw text).

Image_Data = 'iVBORw0KGgoAAAANSUhEUgAAAQ='
window.iconphoto(True, tk.PhotoImage(data=Image_Data))

这篇关于编译python代码时如何包含图标文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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