import sys from PyQt4 import QtGui from PyQt4 import QtCore #Icon继承了QtGui.QWidget这个类 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("1.png")) app=QtGui.QApplication(sys.argv) icon=Icon() icon.show() sys.exit(app.exec_())
原文:http://www.cnblogs.com/yufenghou/p/3776585.html