PyQt5 给无边框widget窗口添加背景图片

#! /usr/bin/env python

# -*- coding:utf-8 -*-

import sys

from PyQt5.QtWidgets import QApplication, QWidget

from PyQt5.QtCore import Qt

from PyQt5.QtGui import QPalette, QBrush, QPixmap

class NoBorderWindow(QWidget):

    def __init__(self):

        super().__init__()

        self.window_UI()

        self.drawn()   

    def window_UI(self):

        self.resize(950, 200) 

        self.setWindowFlags(Qt.FramelessWindowHint)

    def drawn(self):

        self.palette = QPalette()

        self.palette.setBrush(QPalette.Background, QBrush(QPixmap("./images/bg.gif")))

        self.setPalette(self.palette)



if __name__ == "__main__":

    app = QApplication(sys.argv)

    win = NoBorderWindow()    

    win.show()

    sys.exit(app.exec_())

 

PyQt5 给无边框widget窗口添加背景图片

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
  • 2021-11-24
  • 2021-12-31
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-18
  • 2021-12-21
  • 2022-12-23
  • 2022-12-23
  • 2021-12-03
  • 2021-10-08
相关资源
相似解决方案