Py2exe package, solution to the icon display problem under vista/win7

Source: Internet
Author: User

In windows, the commonly used tool for packaging programs written in python is py2exe. This tool only requires some scripts to package the python program into an exe file. The execution of the exe program does not require the system to install the python environment in advance. The following script is not missing during packaging of common gui programs in windows: [python] setup (windows = [{"script": "with_gui.py", "icon_resources ": [(1, "myicon. ico ")]}],) the icon_resources parameter is the focus of our discussion. The exe program is packaged according to the above Code. In windows XP or server 2003, we can see the exe icon. However, when the program is copied to vista/win7, the exe icon is indeed changed to the default "window" icon, Which is used no matter how the attempt mode is changed. First, introduce the ico file, which is helpful for understanding the solution. Ico files are in windows chip format. The folders and execution files we see are displayed with different Icons. When we switch the view mode (Thumbnails, Tiles, Icons, List, Details) the icon of the file will be displayed in "different" sizes. Specifically, it should be different Icon files (sizes are also different ). The ico file can contain multiple Icon files to adapt to different view modes. These Icon files are usually stored in the order of size. The ico size supported in windows XP/server 2003 is 16x16, 32x32, and 48x48. Vista/win7 supports a maximum of 256x256. Posted a solution on the py2exe official website (the cost of blood, sweat, and tears. The key problem lies in the order of the icon in the ico file. XP and server 2003 do not have high requirements on the order. The icons can be displayed in the ascending or descending order of the size, the supervisor can only be in reverse order under vista/win7. If you use the png2ico tool, you can use the following command to generate a myicon. ico file: [python] png2ico myicon. ico icon_128x128.png icon_64x64.png icon_48x48.png icon_32x32.png icon_16x16.png instead of [python] png2ico myicon. ico icon_16x16.png icon_32x32.png invalid icon_128x128.png please note that the ico file generated by png2ico is not very good and the icon file cannot reach 256x256. You have to choose a size like 248x248 to replace it. We recommend an online Conversion Tool ConvertIcon !, Only png2ico can define the icon order, while ConvertIcon! The icon files are stored sequentially from small to large. However, another ico editing tool can solve this problem-Greenfish Icon Editor Pro, which can not only edit Icon files, but also modify the order of Icon files. In summary, use the online tool ConvertIcon! To generate the ico file, then use Greenfish Icon Editor Pro to modify the details of icons of different sizes, and modify the Icon order.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.