setting icon using py2exe?

From: Grant Edwards (grante_at_visi.com)
Date: 06/29/04

  • Next message: vm_usenet: "Stderr and Pythonw"
    Date: 29 Jun 2004 19:22:52 GMT
    
    

    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/theller/moin.cgi/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!
    

  • Next message: vm_usenet: "Stderr and Pythonw"

    Relevant Pages

    • py2exe Icon Resources
      ... I have created an app using python and then converting it to an exe ... in my py2exe setup file, the appFavicon works fine and it sets that as ... fine so that it loads on double click, what i cant do is set the icon ...
      (comp.lang.python)
    • Re: py2exe 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 ... fine so that it loads on double click, what i cant do is set the icon ...
      (comp.lang.python)
    • Re: win XP + wxPython + py2exe
      ... but if I compile it using py2exe it looks like any ugly standard ... from distutils.core import setup ... installs manifest and icon into the .exe ...
      (comp.lang.python)
    • Re: py2exe icon resource on win98
      ... Thomas Heller wrote: ... >> in the py2exe wiki about adding icon resources to apps. ... it's win98 first edition without any updates ...
      (comp.lang.python)
    • Re: Help. Excel icon masking other desktop icons.
      ... Try creating a New user account and see if the problem exists there. ... > default icon but in vain. ... > normal during the starting of the startup but masked once it reached the end. ...
      (microsoft.public.office.misc)