PyQT设置图标,任务栏图标



代码部分:

if __name__ =='__main__':
    QtCore.QTextCodec.setCodecForCStrings(QtCore.QTextCodec.codecForName("utf-8"))

    app = QtGui.QApplication(sys.argv)
    mainWindow = QtGui.QMainWindow()
  
    ui = Ui_MainWindow() #窗口类
    ui.setupUi(mainWindow)
   
    #设置窗口图标
    icon = QtGui.QIcon()
    icon.addPixmap(QtGui.QPixmap("my.ico"),QtGui.QIcon.Normal, QtGui.QIcon.Off)
    mainWindow.setWindowIcon(icon)
   
    mainWindow.show()
   

    sys.exit(app.exec_())    
    pass
pass

用Pyinstaller 打包(Python打包方法——Pyinstaller :https://www.cnblogs.com/gopythoner/p/6337543.html):

    pyinstaller -F HDR_RunScripts.py -w --icon=em.ico

你可能感兴趣的:(pyqt,pyinstaller)