我在PyQt4中有一個小程序,我想將程序編譯成Exe。我正在使用py2exe來做到這一點。我可以使用下面的代碼在Windows標題欄中成功設置圖標,但是當我將它編譯爲exe時,圖標會丟失,並且我會看到默認的Windows應用程序。這裏是我的程序:PyQt4中Exe的窗口圖標
import sys
from PyQt4 import QtGui
class Icon(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.setGeometry(300, 300, 250, 150)
self.setWindowTitle('Icon')
self.setWindowIcon(QtGui.QIcon('c:/python26_/repy26/icons/iqor1.ico'))
app = QtGui.QApplication(sys.argv)
icon = Icon()
icon.show()
sys.exit(app.exec_())
****這裏是setup.py對py2exe ****
from distutils.core import setup
import py2exe
setup(windows=[{"script":"iconqt.py"
,"icon_resources": [(1, "Iqor1.ico")]}]
,options={"py2exe":{"includes":["sip", "PyQt4.QtCore"]}})
什麼.PRO文件? Py2exe使用setup.py。這個答案沒有意義。 – James 2010-11-12 19:10:50
是的,我的糟糕,我認爲他們使用了與C++中相同的過程。您評論的最後部分是不必要的。 – 2010-11-13 09:35:49