Python PyInstaller并包含图标文件 [英] Python PyInstaller and include icon file

查看:219
本文介绍了Python PyInstaller并包含图标文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PyInstaller(v1.5)构建可执行文件 - 另外,我正在使用GUI2EXE来帮助我。我的脚本需要一个位于工作目录中的图标文件:

I am building an executable using PyInstaller (v1.5) -- also, I am using GUI2EXE to assist me. My script calls for an icon file located in the working directory:

icon_file = '\pics\myicon.ico'

当我构建可执行文件时,我不想包含工作目录,而是我的可执行文件中包含的图标文件。有没有办法做到这一点?

When I build the executable, i would like to not have to include the "working directory", rather have the icon file included right in my executable. Is there a way to do this?

如果这还没有,我想要一个包含我的图标文件的文件(我的可执行文件)。

If this doesn't make since, I want one file (my executable) that includes my icon file.


  1. 如何创建一个文件以包含图标文件?

  2. 如何更新我的文件?正确访问该图标文件的脚本代码?

我也希望对任何图像文件甚至数据文件执行此操作。 。

I'm also looking to do this for any image file or even data file...

谢谢!

推荐答案

所以而不是实际的图标分布式可执行文件,您正在查看包含您的python脚本将在运行时从磁盘打开/读取的图标或其他图像?

So rather than the actual icon of the distributed executable, you're looking at including an icon or other image that your python script will open/read from disk at runtime?

其他数据可以捆绑在您的exe和pyinstaller提供了一种在运行时访问它的方法。这个问题显示了如何将它包含在.spec中,答案显示了如何通过脚本访问它:

Additional data can be bundled in your exe, and pyinstaller provides a method of accessing it at runtime. This question shows how to include it in your .spec, and the answer shows how to access it via your script:

使用PyInstaller(--onefile)捆绑数据文件

这篇关于Python PyInstaller并包含图标文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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