473,549 Members | 2,592 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

setting icon using 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

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":"vfcu pdate.py","icon _resources":[(1,"rivatek.ico ")]}])

That doesn't work either:

running py2exe
[...]
copying C:\Python23\Lib \site-packages\wx\wxm sw251h_html_vc. dll -> C:\cygwin\home\ admin\othertool s\dist
copying C:\Python23\Lib \site-packages\wx\wxb ase251h_vc.dll -> C:\cygwin\home\ admin\othertool s\dist
copying C:\PYTHON23\w9x popen.exe -> C:\cygwin\home\ admin\othertool s\dist
copying C:\WINDOWS\SYST EM\python23.dll -> C:\cygwin\home\ admin\othertool s\dist
copying C:\Python23\Lib \site-packages\py2exe \run_w.exe -> C:\cygwin\home\ admin\othertool s\dist\vfcupdat e.exe
Traceback (most recent call last):
File "setup.py", line 5, in ?
setup(windows=[{"script":"vfcu pdate.py","icon _resources":[(1,"rivatek.ico ")]}])
File "C:\PYTHON23\li b\distutils\cor e.py", line 149, in setup
dist.run_comman ds()
File "C:\PYTHON23\li b\distutils\dis t.py", line 907, in run_commands
self.run_comman d(cmd)
File "C:\PYTHON23\li b\distutils\dis t.py", line 927, in run_command
cmd_obj.run()
File "C:\Python23\Li b\site-packages\py2exe \build_exe.py", line 197, in run
self.create_bin aries(py_files, extensions, dlls)
File "C:\Python23\Li b\site-packages\py2exe \build_exe.py", line 395, in create_binaries
arcname, target.script)
File "C:\Python23\Li b\site-packages\py2exe \build_exe.py", line 577, in build_executabl e
add_icon(unicod e(exe_path), unicode(ico_fil ename), 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!
Jul 18 '05 #1
11 15745
> 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":"vfcu pdate.py","icon _resources":[(1,"rivatek.ico ")]}])

That doesn't work either: File "C:\Python23\Li b\site-packages\py2exe \build_exe.py", line 577, in build_executabl e
add_icon(unicod e(exe_path), unicode(ico_fil ename), ico_id)
RuntimeError: MapExistingFile : The handle is invalid.


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!!
Jul 18 '05 #2
Grant Edwards <gr****@visi.co m> wrote in
news:sl******** ***********@gra nte.rivatek.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
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":"vfcu pdate.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?


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.n et>

Jul 18 '05 #3
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).
Jul 18 '05 #4
Grant Edwards <gr****@visi.co m> writes:
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":"vfcu pdate.py","icon _resources":[(1,"rivatek.ico ")]}])

That doesn't work either:

File "C:\Python23\Li b\site-packages\py2exe \build_exe.py", line 577, in build_executabl e
add_icon(unicod e(exe_path), unicode(ico_fil ename), ico_id)
RuntimeError: MapExistingFile : The handle is invalid.


Never mind....

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

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


The bug should be fixed in CVS. Since py2exe now can also be built with
MingW32, you could try that, even if you don't have MSVC. Or you have
to wait for the release.

Thomas
Jul 18 '05 #5
On 2004-06-30, simo <si************ @yahoo.co.uk> wrote:
I think you have to have win32all/pywin32 installed to do
resource/icon handling.
I do.
This works fine for me on Windows 98SE/XP/2000:
Are you sure it works on 98SE? Others have reported it only
works on NT/2K/XP.
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).


I've done that. The desktop icon and start menu icon are set
by InnoSetup, but the icon doesn't show up in the window banner
or in the task bar. I was assuming that setting the icon
resource in the executable would fix that.

--
Grant Edwards grante Yow! I'm having fun
at HITCHHIKING to CINCINNATI
visi.com or FAR ROCKAWAY!!
Jul 18 '05 #6
On 2004-06-30, Thomas Heller <th*****@python .net> wrote:
Never mind....

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

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


The bug should be fixed in CVS. Since py2exe now can also be built with
MingW32, you could try that, even if you don't have MSVC. Or you have
to wait for the release.


Thanks! If I run out of things to do, I'll install MingW32 and
try to build the CVS code. Otherwise I'll wait for the next
release.

--
Grant Edwards grante Yow! It was a JOKE!! Get
at it?? I was receiving
visi.com messages from DAVID
LETTERMAN!! YOW!!
Jul 18 '05 #7
Grant Edwards wrote:
On 2004-06-30, Thomas Heller <th*****@python .net> wrote:

Never mind....

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

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


The bug should be fixed in CVS. Since py2exe now can also be built with
MingW32, you could try that, even if you don't have MSVC. Or you have
to wait for the release.

Thanks! If I run out of things to do, I'll install MingW32 and
try to build the CVS code. Otherwise I'll wait for the next
release.

Or if you don't have time for that you could try this build which is
from latest CVS:
http://davidf.sjsoft.com/files/py2ex...in32-py2.3.exe

Untested :-)
David
Jul 18 '05 #8
On 2004-06-30, David Fraser <da****@sjsoft. com> wrote:
Or if you don't have time for that you could try this build
which is from latest CVS:
http://davidf.sjsoft.com/files/py2ex...in32-py2.3.exe

Untested :-)


Tested (at least a little bit), and it appears to work.

Thanks!

The correct icons show up in the desktop explorer (which is
new), but I still don't get my icons showing up in the window's
banner or in the taskbar when the program is running. :/

--
Grant Edwards grante Yow! Kids, don't gross me
at off... "Adventures with
visi.com MENTAL HYGIENE" can be
carried too FAR!
Jul 18 '05 #9
On 2004-07-01, Grant Edwards <gr****@visi.co m> wrote:
The correct icons show up in the desktop explorer (which is
new), but I still don't get my icons showing up in the window's
banner or in the taskbar when the program is running. :/


I guess you have to set that at runtime. I had thought that if
the .exe file had icon resources, Windows would use them by
default, but I guess not. [In wxPython you call the SetIcon()
method of the top-level frame.]

--
Grant Edwards grante Yow! I hope something GOOD
at came in the mail today so
visi.com I have a REASON to live!!
Jul 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1373
by: Haim Ashkenazi | last post by:
Hi I'm trying to build a binary with py2exe. I've used the method suggested in the py2exe wiki about adding icon resources to apps. it build ok on win2k, but when I try to build the same on win98 I get this error: copying C:\Python23\Lib\site-packages\py2exe\run.exe -> C:\My Documents\NS_Backup\dist\NS_Backup.exe Traceback (most recent...
1
1853
by: sarmin kho | last post by:
Hi Pythoners, i remember that i saw posting about changing the icon of a python executable but i kind of lost where to find the posting... basically, this is my first time using the py2exe to create python executable... it came out with an executable file with an icon that i would like to change... any guide please... many thanks...
2
3517
by: Joe Wong | last post by:
Hi, I have encountered an error whenever I put the "icon_resources" line in my setup.py file: from distutils.core import setup import py2exe setup(
1
2280
by: hansolox1 | last post by:
The following program simply sets the icon of a form called form1. When I get the name of the embedded icon using GetManifestResourceNames(), I store the name in a string variable called s. The value of s is "test2.icon1.ico". This program will compile and run just fine from visual studio .net 2003 using .net 1.1 and also will compile and...
0
1139
by: Vyz | last post by:
I have given icon like this to main frame of my program ib=wx.IconBundle() ib.AddIconFromFile("SriPadma.ico",wx.BITMAP_TYPE_ANY) self.SetIcons(ib and then I have made binary with py2exe and in setup file mentioned it as icon resource. windows = }
2
1436
by: Martin | last post by:
If i create an app using py2exe/py2app is there then a way on windows/ mac to get access to a file dragged and dropped on to the .exe/.app icon? Martin
1
48046
Plater
by: Plater | last post by:
C# (and possibly VB.NET) in VS2005 can be a bit tricky. Here's my little rundown: Add an icon file to your project (new or exisiting, whichever) Open the icon file is VS and edit as desired. (Note: On the left hand side is a small preview of the icon, extra sizes can be added to the SAME icon file there as well as cycling through...
2
3040
by: flarefight | last post by:
I have created an app using python and then converting it to an exe using py2exe, and have the following code: "icon_resources": in my py2exe setup file, the appFavicon works fine and it sets that as the app icon thats fine, but the program creates data files (like documents) and i wanted them to have a different icon... I package my...
0
1921
by: vishnu1986 | last post by:
Hi guys, I saw quite a few posts regarding this but I was unable to solve this problem that I am facing. First off, when I do the following in my setup.py, windows= } ], Python crashes and I am unable to run the script using python setup.py py2exe.
0
7527
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7459
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7967
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7819
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5377
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3505
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1953
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1064
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.