У меня есть вот такой класс окна:
class DrawingWindow(QMainWindow):
    def __init__(self, coordinates):
        super().__init__()
        self.setWindowTitle("Transparent Drawing Window")
        self.setGeometry(0, 0, QApplication.desktop().screenGeometry().width(),
                         QApplication.desktop().screenGeometry().height())
        self.setAttribute(Qt.WA_TranslucentBackground, True)
        self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)

        self.painter = QPainter()
        self.painter.setRenderHint(QPainter.Antialiasing)

        self.pen_color = QColor(255, 0, 0)  # Set the initial pen color to red
        self.pen_width = 4  # Set the initial pen width to 4

        self.coordinates = coordinates  # Store the coordinates for drawing rectangles

        self.starting_point = None

        self.setFrameStyle(QFrame.Box)  # Set functional frame shape

    def paintEvent(self, event):
        self.painter.begin(self)
        self.painter.setPen(Qt.NoPen)
        self.painter.setBrush(QBrush(Qt.transparent))
        self.painter.drawRect(QRect(0, 0, self.width(), self.height()))  # Draw a transparent background

        self.painter.setPen(QPen(QColor(self.pen_color), self.pen_width))
        self.painter.setBrush(QBrush(Qt.transparent))

        self.painter.drawRect(self.coordinates[0], self.coordinates[1], self.coordinates[2], self.coordinates[3])  # Draw rectangles using the provided coordinates

        self.painter.end()

    def mousePressEvent(self, event):
        self.starting_point = event.pos()


    def mouseMoveEvent(self, event):
        if self.starting_point:
            current_point = event.pos()
            if current_point.x() > self.coordinates[0] + self.coordinates[2]:
                self.coordinates[2] = current_point.x() - self.coordinates[0]
            if current_point.y() > self.coordinates[1] + self.coordinates[3]:
                self.coordinates[3] = current_point.y() - self.coordinates[1]

            if current_point.x() < self.coordinates[0] + self.coordinates[2]:
                self.coordinates[2] += self.coordinates[0] - current_point.x()
                self.coordinates[0] = current_point.x()

            if current_point.y() < self.coordinates[1] + self.coordinates[3]:
                self.coordinates[3] += self.coordinates[1] - current_point.y()
                self.coordinates[1] = current_point.y()

            self.update()
        self.ending_point = event.pos()


    def mouseReleaseEvent(self, event):
        '''if self.starting_point :

            #self.coordinates.append((x, y, width, height))
            if self.ending_point.x() > self.coordinates[0] + self.coordinates[2]:
                self.coordinates[2] = self.ending_point.x() - self.coordinates[0]
            if self.ending_point.y() > self.coordinates[1] + self.coordinates[3]:
                self.coordinates[3] = self.ending_point.y() - self.coordinates[1]

            if self.ending_point.x() < self.coordinates[0] + self.coordinates[2]:
                self.coordinates[2] += self.coordinates[0] - self.ending_point.x()
                self.coordinates[0] = self.ending_point.x()

            if self.ending_point.y() < self.coordinates[1] + self.coordinates[3]:
                self.coordinates[3] += self.coordinates[1] - self.ending_point.y()
                self.coordinates[1] = self.ending_point.y()

            self.update()'''

        self.starting_point = None
Как добавить к нему кнопки?