py2exe setup.py 带有图标

发布于 2024-07-08 13:11:45 字数 33 浏览 7 评论 0原文

编译Python程序时如何为我的exe文件制作图标?

How do I make icons for my exe file when compiling my Python program?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

贩梦商人 2024-07-15 13:11:45

我不久前正在搜索这个,发现了这个: http ://www.mail-archive.com/[email protected]/msg05619.html

引用上述链接:

setup.py 文件:PY_PROG =

“trek10.py”APP_NAME =“Trek_Game”

cfg = {

'名称':APP_NAME, 
  '版本':'1.0', 
  '描述':'', 
  '作者':'', 
  '作者电子邮件':'', 
  '网址':'', 

  'py2exe.target':'', 
  'py2exe.icon':'icon.ico', #64x64 
  'py2exe.binary':APP_NAME, #去掉.exe,它将被添加 

  'py2app.target':'', 
  'py2app.icon':'图标.icns', #128x128 

  'cx_freeze.cmd':'~/src/cx_Freeze-3.0.3/FreezePython', 
  'cx_freeze.target':'', 
  “cx_freeze.binary”:APP_NAME, 
  } 
  

--剪断--

I was searching for this a while ago, and found this: http://www.mail-archive.com/[email protected]/msg05619.html

Quote from above link:

The setup.py File: PY_PROG =

'trek10.py' APP_NAME = 'Trek_Game'

cfg = {

'name':APP_NAME,
'version':'1.0',
'description':'',
'author':'',
'author_email':'',
'url':'',

'py2exe.target':'',
'py2exe.icon':'icon.ico', #64x64
'py2exe.binary':APP_NAME, #leave off the .exe, it will be added

'py2app.target':'',
'py2app.icon':'icon.icns', #128x128

'cx_freeze.cmd':'~/src/cx_Freeze-3.0.3/FreezePython',
'cx_freeze.target':'',
'cx_freeze.binary':APP_NAME,
}

--snip--

七度光 2024-07-15 13:11:45

其他答案中回答了链接图标。 创建这个东西就像使用 png2ico 一样简单。 它从 1 个或多个 png 创建一个 ico 文件并处理多种尺寸等,例如:

png2ico myicon.ico logo16x16.png logo32x32.png

将创建尺寸为 16x16 和 32x32 的 myicon.ico。 尺寸必须是 8 平方的倍数,且不大于 256x256。

Linking the icons is answered in other answers. Creating the thing is as easy as using png2ico. It creates an ico file from 1 or more png's and handles multiple sizes etc, like:

png2ico myicon.ico logo16x16.png logo32x32.png

Will create myicon.ico with sizes 16x16 and 32x32. Sizes must be multiples of 8 squares, and no larger than 256x256.

遥远的她 2024-07-15 13:11:45

py2exe 有点过时,并已与 pyinstaller 一起继续(其本身也有点过时;svn 版本是最新的)
http://pyinstaller.python-hosting.com/

运行完 pyinstaller 的初始脚本后从 Makespec.py 生成规范文件,编辑规范文件并查找 EXE 部分。 在其末尾只需添加您的 ico 定义; 所以

控制台=真)

将变为

console=True, icon='mine.ico' )

也就是说,如果 mine.ico 文件与 Makespec.py 文件位于同一文件夹中。 还有一个命令行选项可以将图标输入其中。 我认为是

python Makespec.py -i 'mine.ico' /path/to/file.py

py2exe is a little dated, and has been continued with pyinstaller (which itself is a little dated; the svn release is the most up to date)
http://pyinstaller.python-hosting.com/

After running through the initial scripts for pyinstaller and generating the spec file from Makespec.py, edit the spec file and look for the EXE section. At the tail end of that just add in your ico definition; so

console=True)

would become

console=True, icon='mine.ico' )

That is, if the mine.ico file were in the same folder as the Makespec.py file. There's also a command line option for feeding the icon into it. I think it was

python Makespec.py -i 'mine.ico' /path/to/file.py
一向肩并 2024-07-15 13:11:45

我没有使用 py2exe 的经验,但快速Google 搜索发现这个,如果您要求在 exe 文件中嵌入图标。

如果您想创建 .ico 文件,我强烈建议您搜索图标设计器或成品图标。 当然,您可以通过在 Paint 中创建 16x16、32x32 或 64x64 像素图像并将其重命名为 .ico 来相当轻松地创建 Win 3.x 样式图标。 但为 Windows 创建现代多分辨率图标要复杂得多。

(我正想问你是为什么操作系统编译的,当我意识到“exe”听起来很Windows,果然......)

I have no experience with py2exe but a quick google search found this, if embedding icons in exe files was what you asked for.

If you want to create .ico files, I'd really suggest you search for a icon designer or finished icons. Sure you can create a Win 3.x style icon fairly easy by creating a 16x16, 32x32, or 64x64 px image in paint, and rename it to .ico. But to create modern multi resolution icons for windows is a lot more complicated.

(I was about to ask what OS you was compiling for, when I realized "exe" sounds very windows, and sure enough...)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文