Esempio n. 1
0
    def paintEvent(self, paintEvent):
        painter = QPainter(self)

        font = painter.font()
        font.setPixelSize(14)
        font.setBold(True)
        painter.setFont(font)

        # clear background
        painter.setBackground(QColor("#1D212D"))
        painter.eraseRect(self.rect())

        self.apply_camera(painter)

        self.draw_links(painter)

        self.draw_rooms(painter)

        self.draw_solution_paths(painter)

        self.draw_ants(painter)

        # reset transform
        painter.resetMatrix()

        self.draw_room_names(painter)
Esempio n. 2
0
    def paintEvent(self, event):
        painter = QPainter(self)

        # clear background
        painter.setBackground(QCOLOR_BKG_EMPTY)
        painter.eraseRect(self.rect())

        # draw memory view layer
        painter.drawPixmap(QPoint(), self.bytes_pixmap)

        # draw cursors layer
        painter.drawPixmap(QPoint(), self.cursors_pixmap)
    def paintEvent(self, event: QPaintEvent):
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)

        painter.eraseRect(event.rect())

        painter.setBrush(QBrush(self._bg))
        painter.drawRect(event.rect())

        if self.mode == 'revealed':
            self.setFrameStyle(QFrame.Panel | QFrame.Plain)
            self.setLineWidth(0)
            self.setMidLineWidth(0)
            if self.content in self.content_colors.keys():
                font = QFontDatabase.systemFont(QFontDatabase.FixedFont)
                font.setPixelSize(int(self.width() * 5 / 6))
                painter.setPen(self.content_colors[self.content])
                painter.setFont(font)
                flags = Qt.AlignCenter | Qt.TextJustificationForced
                painter.drawText(event.rect(), flags, self.content)

            if self.content == 'bomb':
                loc = 'exploded_bomb' if self.was_clicked_bomb else 'bomb'
                painter.drawImage(event.rect(),
                                  QImage(self.image_locations[loc]))

        if self.mode == 'hidden':
            self.setFrameStyle(QFrame.Panel | QFrame.Raised)
            self.setLineWidth(3)
            self.setMidLineWidth(2)

        if self.mode == 'false_bomb':
            painter.drawImage(event.rect(),
                              QImage(self.image_locations['false_bomb']))

        if self.mode == 'flag':
            self.setFrameStyle(QFrame.Panel | QFrame.Raised)
            self.setLineWidth(3)
            self.setMidLineWidth(2)
            painter.drawImage(event.rect(),
                              QImage(self.image_locations['flag']))

        super(CellWidget, self).paintEvent(event)