PyQt5 利用paintEvent绘制窗口背景图片
作者:互联网
PyQt5 利用paintEvent绘制窗口背景图片
#! /usr/bin/env python
# -*- coding:utf-8 -*-
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtGui import QIcon, QPixmap, QPainter
import sys
class M_Win(QWidget):
def __init__(self):
super().__init__()
self.m_ui()
def m_ui(self):
self.resize(950, 200)
self.setWindowTitle("利用PaintEvent绘制窗口图片")
self.setWindowIcon(QIcon("./icon/title.png"))
def paintEvent(self, event):
painter = QPainter(self)
pixmap = QPixmap("./images/bg.gif")
painter.drawPixmap(self.rect(), pixmap)
if __name__ == "__main__":
app = QApplication(sys.argv)
win = M_Win()
win.show()
sys.exit(app.exec_())
标签:__,self,PyQt5,sys,paintEvent,import,背景图片 来源: https://www.cnblogs.com/tylerwu/p/12850035.html