使用py2exe设置图标? [英] setting icon using py2exe?

查看:190
本文介绍了使用py2exe设置图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图通过py2exe为可执行文件生成

设置图标。根据各种来源,有两个答案:


1)在命令行上执行:


python setup.py py2exe --icon foo.ico


产生使用错误:


错误: - 图标无法识别


2)根据 http://starship.python。 net / crew / thel ... gi / CustomIcons

您可以在setup.py中设置icon_resources,如下所示:


#setup .py
来自distutils.core导入设置的


导入py2exe

setup(windows = [{" script":" vfcupdate.py" ;,icon_resources:[(1," rivatek.ico")]}})


这也不起作用:


运行py2exe

[...]

复制C:\Python23 \Lib \site-packages \ wx \wxmsw251h_html_vc.dll - > C:\ cygwin \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ C:\ cygwin \home \ admin \othertools \dist

复制C:\ PYTHON23 \w9xpopen.exe - > C:\cygwin \\\\\\\\\\\\\\\\\\\\\\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ C:\ cygwin \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ C:\ cygwin \home \ admin \othertools \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ .py",第5行,在?b / b
setup(windows = [{" script":" vfcupdate.py"," icon_resources":[(1," rivatek.ico" )]}})

文件" C:\ PYTHON23 \lib \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ()

文件" C:\PYTHON23 \lib \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

文件" C:\ PYTHON23 \lib \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ >
文件" C:\Python23 \Lib \site-packages \ py2exe \ build_exe.py",第197行,在运行中

self.create_binaries(py_files,扩展,dll)

文件" C:\Python23 \Lib \site-packages \ py2exe \ build_exe.py" ,第395行,在create_binaries中

arcname,target.script)

文件C:\Python23 \Lib\site-packages \py2exe\build_exe .py",第577行,在build_executable中

add_icon(unicode(exe_path),unicode(ico_filename),ico_id)

RuntimeError:MapExistingFile:句柄无效。 />
有没有人真的可以设置py2exe生成的可执行文件的图标




-

格兰特爱德华兹格兰特哇!现在我正在专注于特定的坦克大战



visi.com世界末日
第二次世界大战!

I''m trying in vain to set the icon for the executable generated
by py2exe. According to various sources there are two answers:

1) Do it on the command line:

python setup.py py2exe --icon foo.ico

That generates a usage error:

error: --icon not recognized

2) According to http://starship.python.net/crew/thel...gi/CustomIcons
you can set the icon_resources in the setup.py like this:

# setup.py
from distutils.core import setup
import py2exe
setup(windows=[{"script":"vfcupdate.py","icon_resources":[(1,"rivatek.ico")]}])

That doesn''t work either:

running py2exe
[...]
copying C:\Python23\Lib\site-packages\wx\wxmsw251h_html_vc.dll -> C:\cygwin\home\admin\othertools\dist
copying C:\Python23\Lib\site-packages\wx\wxbase251h_vc.dll -> C:\cygwin\home\admin\othertools\dist
copying C:\PYTHON23\w9xpopen.exe -> C:\cygwin\home\admin\othertools\dist
copying C:\WINDOWS\SYSTEM\python23.dll -> C:\cygwin\home\admin\othertools\dist
copying C:\Python23\Lib\site-packages\py2exe\run_w.exe -> C:\cygwin\home\admin\othertools\dist\vfcupdate.exe
Traceback (most recent call last):
File "setup.py", line 5, in ?
setup(windows=[{"script":"vfcupdate.py","icon_resources":[(1,"rivatek.ico")]}])
File "C:\PYTHON23\lib\distutils\core.py", line 149, in setup
dist.run_commands()
File "C:\PYTHON23\lib\distutils\dist.py", line 907, in run_commands
self.run_command(cmd)
File "C:\PYTHON23\lib\distutils\dist.py", line 927, in run_command
cmd_obj.run()
File "C:\Python23\Lib\site-packages\py2exe\build_exe.py", line 197, in run
self.create_binaries(py_files, extensions, dlls)
File "C:\Python23\Lib\site-packages\py2exe\build_exe.py", line 395, in create_binaries
arcname, target.script)
File "C:\Python23\Lib\site-packages\py2exe\build_exe.py", line 577, in build_executable
add_icon(unicode(exe_path), unicode(ico_filename), ico_id)
RuntimeError: MapExistingFile: The handle is invalid.
Has anybody really been able to set the icon for the executable
generated by py2exe?

--
Grant Edwards grante Yow! Now I''m concentrating
at on a specific tank battle
visi.com toward the end of World
War II!

推荐答案

> 2)根据 http://starship.python.net/ crew / thel ... gi / CustomIcons
你可以在setup.py中设置icon_resources,如下所示:

#setup.py
from distutils.core import setup
import py2exe
setup(windows = [{" script":" vfcupdate.py"," icon_resources":[(1," rivatek.ico") ]})

这也不起作用:
File" C:\Python23 \Lib\site-packages \ py2exe\build_exe.py",第577行,在build_executable中
add_icon(unicode(exe_path),unicode(ico_filename),ico_id)
RuntimeError:MapExistingFile:句柄无效。
you can set the icon_resources in the setup.py like this:

# setup.py
from distutils.core import setup
import py2exe
setup(windows=[{"script":"vfcupdate.py","icon_resources":[(1,"rivatek.ico")]}])

That doesn''t work either: File "C:\Python23\Lib\site-packages\py2exe\build_exe.py", line 577, in build_executable
add_icon(unicode(exe_path), unicode(ico_filename), ico_id)
RuntimeError: MapExistingFile: The handle is invalid.




没关系....


进一步的谷歌搜索显示这是一个已知的bug在

下运行Win98 / Me:

http://groups.google.com/groups?th=4d594c535345b98b


-

格兰特爱德华兹格兰特哇!在不同的MAGNATES,MOGULS

visi.com& NABOBS在我的

哥特式日光浴室里嬉戏!!



Never mind....

Further googling reveals this is a known bug when running under
Win98/Me:

http://groups.google.com/groups?th=4d594c535345b98b

--
Grant Edwards grante Yow! Four thousand
at different MAGNATES, MOGULS
visi.com & NABOBS are romping in my
gothic solarium!!


Grant Edwards< gr **** @ visi.com>写在

新闻:sl ******************* @ grante.rivatek.com:
Grant Edwards <gr****@visi.com> wrote in
news:sl*******************@grante.rivatek.com:
我正在徒劳地设置py2exe生成的可执行文件的图标。根据各种来源,有两个答案:

1)在命令行上执行:

python setup.py py2exe --icon foo.ico
<这会产生一个使用错误:

错误: - 图标无法识别


适用于版本< 0.4

它不再支持0.5+

2)根据
http://starship.python.net/crew/thel...gi/CustomIcons
你可以设置setup.py中的icon_resources如下:

#setup.py
来自distutils.core import setup
import py2exe
setup(windows = [{" script" ;:vfcupdate.py,icon_resources:[(1," riv
atek.ico")]}])
.... RuntimeError:MapExistingFile:句柄无效。

有没有人能真正设置py2exe生成的可执行文件的图标?
I''m trying in vain to set the icon for the executable generated
by py2exe. According to various sources there are two answers:

1) Do it on the command line:

python setup.py py2exe --icon foo.ico

That generates a usage error:

error: --icon not recognized
that is for versions < 0.4
it is not longer supported in 0.5+
2) According to
http://starship.python.net/crew/thel...gi/CustomIcons
you can set the icon_resources in the setup.py like this:

# setup.py
from distutils.core import setup
import py2exe
setup(windows=[{"script":"vfcupdate.py","icon_resources":[(1,"riv
atek.ico")]}]) .... RuntimeError: MapExistingFile: The handle is invalid.

Has anybody really been able to set the icon for the executable
generated by py2exe?




是的,在这里工作正常:

windows = [

{''script'':" hexedit_wx.py",''icon_resources'':[(0x0004,

''bigicon.ico'')]},

],


i被告知该ID没那么重要,它只需要

第一个图标资源。我在某个地方看到了4的使用,所以我测试了那个

的数字,因为它适用于我,我没有改变它


chris


-

Chris< cl ****** @ gmx.net>



yes, works fine here:
windows = [
{ ''script'': "hexedit_wx.py", ''icon_resources'': [(0x0004,
''bigicon.ico'')]},
],

i was told that the ID does not matter that much, it will just take the
first icon resource. i somewhere saw the use of 4, so i tested with that
number and since it worked for me, i didn''t change it

chris

--
Chris <cl******@gmx.net>


我认为你必须安装win32all / pywin32来执行

资源/图标处理。


这对我来说在Windows 98SE上运行正常/ XP / 2000:


设置(

windows = [

{

" script" ;:" hellow.py",

" icon_resources":[(1," hellow.ico")]

}

],




如果你不能让它工作,你可以只包括.ico文件

使用data_files = [" hellow.ico"],然后创建快捷方式,

指向图标,使用您的安装程序,例如InnoSetup

(有点像我在Linux下做的)。
I think you have to have win32all/pywin32 installed to do
resource/icon handling.

This works fine for me on Windows 98SE/XP/2000:

setup(
windows = [
{
"script": "hellow.py",
"icon_resources": [(1, "hellow.ico")]
}
],
)

If you can''t get this to work, you could just include the .ico file
using data_files=["hellow.ico"], and then create the shortcuts,
pointing to the icon, using your install program, e.g. InnoSetup
(kinda like I do under Linux).


这篇关于使用py2exe设置图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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