import sys
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtGui import QIcon
#demo_2:显示一个窗体,设置一个图标
class Example(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()
    def initUI(self): #定义初始化界面的方法
        self.resize(200,200)
        self.setWindowTitle('Example')
        self.move(200,200)
        self.setWindowIcon(QIcon('1.png')) #设置窗体标题图标
        self.show()

if __name__ == '__main__':
    app=QApplication(sys.argv)  #所有的PyQt5应用必须创建一个应用(Application)对象
    widgets=Example()
    widgets.show()
    sys.exit(app.exec())

PyQt5-显示一个窗体,设置标题和图标-2

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
  • 2022-12-23
  • 2021-12-15
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-25
  • 2022-12-23
  • 2022-12-23
  • 2022-01-04
  • 2022-12-23
  • 2021-12-08
  • 2021-11-26
相关资源
相似解决方案