<pre style="font-family: 宋体; font-size: 12pt; background-color: rgb(255, 255, 255);"><pre name="code" class="python">import sys from PyQt5.QtWidgets import QApplication, QWidget from PyQt5.QtGui import QIcon class Example(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): self.setGeometry(300, 300, 300, 200) #前两个为窗口位置(x, y)坐标,后两个为窗口大小(300x200) self.setWindowTitle('Icon') self.setWindowIcon(QIcon('C:\\Users\\hengli\\Pictures\\CameraMan\\ss.jpg')) #图标的位置 self.show() if __name__ == '__main__': app = QApplication(sys.argv) ex = Example() sys.exit((app.exec_()))
原文:http://blog.csdn.net/u013511642/article/details/45341475