import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
class WindowPattern(QMainWindow):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.resize(500, 300)
self.setWindowTitle("设置窗口样式")
self.setWindowFlags(Qt.WindowMaximizeButtonHint | Qt.WindowStaysOnTopHint)
# 最大化、最小化、关闭
# self.setWindowFlags(Qt.WindowMaximizeButtonHint | Qt.WindowMinimizeButtonHint | Qt.WindowCloseButtonHint)
self.setObjectName("MainWindow")
self.setStyleSheet("#MainWindow{border-image:url(image/img1.png);}")
if __name__ == "__main__":
app = QApplication(sys.argv)
main = WindowPattern()
main.show()
sys.exit(app.exec_())
标签:__,窗口,Qt,样式,self,PyQT5,PyQt5,import,main
From: https://www.cnblogs.com/jackchen28/p/18239646