美文网首页
PyQt5之Icon的使用

PyQt5之Icon的使用

作者: _Mirage | 来源:发表于2020-03-31 17:51 被阅读0次

重点是 from PyQt5.QtGui import QIcon

QIcon接受的参数: image.png

一般给个本地文件路径就行了.

代码:

# coding='utf-8'

import sys
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtGui import QIcon


class Gui(QWidget):
    def __init__(self):
        super().__init__()

    def start(self):
        self.setGeometry(250, 250, 800, 600)
        self.setWindowTitle('第二个Icon')
        self.setWindowIcon(QIcon('./图片素材/app图标/5.png'))
        self.show()

main = QApplication(sys.argv)
gui = Gui()
gui.start()
sys.exit(main.exec_())

运行结果: image.png

相关文章

网友评论

      本文标题:PyQt5之Icon的使用

      本文链接:https://www.haomeiwen.com/subject/xwawuhtx.html