#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Eugene,OR
    Posts
    2
    Rep Power
    0

    Question custom icons through py2exe


    Hi, I'm a relative beginner to programming -- not quite been codinga year, but I'm getting pretty good at python, and beginning to learn Java.

    Anyway, I'm learning how to use py2exe (I'm on WIndows 2000, btw) and I would like to make a custom icon for my program "a.py"

    C:\a.py is the directory for my program, C:\setup.py is my distutils setup file, and C:\icon.ico is my icon file.

    My setup file is this:

    #!/usr/bin/env python

    from distutils.core import setup
    import py2exe

    setup(name="a",
    version="1.0",
    description="Writes newlines correctly from downloaded text files",
    icon_file = "icon.ico",
    author="Rowen",
    author_email="rowenlemmings@hotmail.com",
    url="http://lemmingsinc.cjb.net",
    scripts=["a.py"],
    )


    the icon_file variable I found from a pygame tutorial on this...don't have the URL on me anymore, but it may not even work without pygame (I wrote it in plain python). I have tried building the exe two ways: with the icon_file variable both ways and w/o it both ways. They all work, but none of them gives me the right icon!

    C:>setup.py py2exe

    That just makes C:\dist\a\a.exe and all those files, but w/o the icon

    C:>setup.py py2exe --icon "C:\icon.ico"

    ends up doing the same thing, though the py2exe documentation says that it should make the exe have that icon!

    Please help me, I don't know what else to do. Again, I'm running on Windows 2k, and I really need the icon file so it looks better for distribution (as is part of my setup.py file, it's just a simple little file utility I want to start off a small online software company, I'm still in HS, so don't expect big things ; D)

    Thank you in advance for any help you can give!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Location
    Colorado, USA
    Posts
    68
    Rep Power
    11

    Try this--it may help


    example from my setup.py at the end of my setup() section

    windows = [
    {
    "script": "test.pyw",
    "icon_resources": [(1,"favicon.ico")],
    }
    ],


    not sure what the '1' means in the args, but it worked for me.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Eugene,OR
    Posts
    2
    Rep Power
    0

    wow...


    hehe -- over a year passed but someone eventually responded ^_^.

    Anyway, the "1" as args prolly just means True, use icons. Don't know for sure -- could also be a len(list) of the rest of the args.

    Thanks for replying btw ^_^
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Location
    Colorado, USA
    Posts
    68
    Rep Power
    11
    Originally Posted by rowenlemmings
    hehe -- over a year passed but someone eventually responded ^_^.

    Anyway, the "1" as args prolly just means True, use icons. Don't know for sure -- could also be a len(list) of the rest of the args.

    Thanks for replying btw ^_^
    Just turned out that I ran into the same problem, and found your post via google.
    I found another reference somewhere else, and thought I would add this info here, since I found this post before the solution.
  8. #5
  9. slightly insane code guru
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2004
    Location
    Indianapolis, IN
    Posts
    871
    Rep Power
    18
    it could also be the fact that some icon resources (such as various DLLs) contain more than one icon in them, and thus the "1" is simply specifying the first (in this case only) icon.

IMN logo majestic logo threadwatch logo seochat tools logo