标签:bsp import ora cat pytho python commons 背景图片 file
PyQt5 给无边框窗口添加背景图片
#! /usr/bin/env python
# -*- coding:utf-8 -*-
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.QtCore import Qt
class NoBorderWindow(QMainWindow):
def __init__(self):
super().__init__()
self.window_UI()
self.setObjectName("w")
self.qss()
def window_UI(self):
self.resize(950, 200)
self.setWindowFlags(Qt.FramelessWindowHint)
def qss(self):
self.qssfile = "./qss/noborder.qss"
self.style = CommonStyleSheet.loadqss(self.qssfile)
self.setStyleSheet(self.style)
class CommonStyleSheet:
def __init__(self):
pass
@staticmethod
def loadqss(style):
with open (style, "r", encoding="utf-8") as f:
return f.read()
if __name__ == "__main__":
app = QApplication(sys.argv)
win = NoBorderWindow()
win.show()
sys.exit(app.exec_())
Qss文件
#w{background-image:url(./images/bg.gif);}
标签:bsp import ora cat pytho python commons 背景图片 file
原文地址:https://www.cnblogs.com/tylerwu/p/12812991.html