Qt4 pyInstaller 2.0和qt setWindowIcon命令存在问题
简单Qt应用程序:Qt4 pyInstaller 2.0和qt setWindowIcon命令存在问题,qt4,pyqt,pyinstaller,Qt4,Pyqt,Pyinstaller,简单Qt应用程序: from PyQt4 import QtGui, QtCore import sys, atexit class ApplicationWindow(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setWindowTit
from PyQt4 import QtGui, QtCore
import sys, atexit
class ApplicationWindow(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.setWindowTitle("application main window")
self.file_menu = QtGui.QMenu('&File', self)
self.menuBar().addMenu(self.file_menu)
self.menuBar().addSeparator()
self.main_widget = QtGui.QWidget(self)
qApp = QtGui.QApplication(sys.argv)
aw = ApplicationWindow()
aw.show()
sys.exit(qApp.exec_())
qApp.exec_()
运行的没有问题,我可以建立一个exe使用pyInstaller也运行良好
我添加以下行:
iconfile = QtGui.QIcon('C:/pyinstaller/img/image1.png')
aw.setWindowIcon(iconfile)
就在aw.show()之前(在整个代码的其他地方也尝试过)
作为python文件,这个运行很好,但是当使用pyInstaller构建时,exe在运行时崩溃,我尝试过使用资源文件和其他图像格式,但问题仍然存在
有人能帮忙吗
感谢通过恢复到pyInstaller v.1.5.1解决了(某种程度上),这显然是v2.0中的一个bug