Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

py2exe and disappeared icon

I am using pyqt, icon is added.

icon.addPixmap(QtGui.QPixmap(_fromUtf8("favicon.ico")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
MainWindow.setWindowIcon(icon)

In setup.py for py2exe, I am trying to add my icon to resources.

from distutils.core import setup 
import py2exe 
setup(
    console=[{
            "script" : "manage.py",
            "icon_resources": [(1, "favicon.ico")]
    }],
    options={
        "py2exe" : {"includes" : ["sip",]}
    }
) 

When I start my program from IDE as python script, I see my icon. When I create exe program with py2exe, my program works well, but icon dissappears.

like image 978
Meloun Avatar asked Mar 24 '23 17:03

Meloun


1 Answers

The problem is that py2exe doesn't include the qt icon reader plugin. Data_files parameter added.

from distutils.core import setup 
import py2exe 
setup(    
    options={
       "py2exe" : {"includes" : ["sip",]}
    },
    data_files = [
      ('imageformats', [
        r'C:\programs\Python271\Lib\site-packages\PyQt4\plugins\imageformats\qico4.dll'
        ])],
    console=[{          
       "script" : "manage.py"       
    }]
) 
like image 77
Meloun Avatar answered Apr 01 '23 08:04

Meloun