试试看:import sys
from PyQt5.QtCore import Qt, QRectF
from PyQt5.QtGui import QPainter, QPen, QColor, QBrush, QPainterPath
from PyQt5.QtWidgets import QWidget, QApplication
class MainWindow(QWidget):
BorderColor = QColor(0, 0, 0, 255)
BackgroundColor = QColor(255, 165, 0, 180)
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.setWindowFlags(Qt.FramelessWindowHint)
self.setAttribute(Qt.WA_TranslucentBackground, True)
def paintEvent(self, event):
super(MainWindow, self).paintEvent(event)
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing)
rectPath = QPainterPath()
height = self.height() - 8
rectPath.addRoundedRect(QRectF(2, 2, self.width()-4, height), 15, 15)
painter.setPen(QPen(self.BorderColor, 2, Qt.SolidLine,
<