(self, event)
QWidget.paintEvent() implementation
QWidget.paintEvent() implementation
QWidget . paintEvent () implementation
def paintEvent(self, event):
        """QWidget.paintEvent() implementation
        """
        painter = QPainter(self)
        painter.fillRect(event.rect(), self.palette().color(QPalette.Window))
        painter.setPen(Qt.black)

        block = self._editor.firstVisibleBlock()
        blockNumber = block.blockNumber()
        top = int(
            self._editor.blockBoundingGeometry(block).translated(
                self._editor.contentOffset()).top())
        bottom = top + int(self._editor.blockBoundingRect(block).height())

        boundingRect = self._editor.blockBoundingRect(block)
        availableWidth = self.__width - self._RIGHT_MARGIN - self._LEFT_MARGIN
        availableHeight = self._editor.fontMetrics().height()
        while block.isValid() and top <= event.rect().bottom():
            if block.isVisible() and bottom >= event.rect().top():
                number = str(blockNumber + 1)
                painter.drawText(self._LEFT_MARGIN, top,
                                 availableWidth, availableHeight,
                                 Qt.AlignRight, number)
                # if boundingRect.height() >= singleBlockHeight * 2:  # wrapped block
                #     painter.fillRect(1, top + singleBlockHeight,
                #                      self.__width - 2,
                #                      boundingRect.height() - singleBlockHeight - 2,
                #                      Qt.darkGreen)

            block = block.next()
            boundingRect = self._editor.blockBoundingRect(block)
            top = bottom
            bottom = top + int(boundingRect.height())
            blockNumber += 1
def paintEvent ( self , event ) : painter = QPainter ( self ) painter . fillRect ( event . rect ( ) , self . palette ( ) . color ( QPalette . Window ) ) painter . setPen ( Qt . black ) block = self . _editor . firstVisibleBlock ( ) blockNumber = block . blockNumber ( ) top = int ( self . _editor . blockBoundingGeometry ( block ) . translated ( self . _editor . contentOffset ( ) ) . top ( ) ) bottom = top + int ( self . _editor . blockBoundingRect ( block ) . height ( ) ) boundingRect = self . _editor . blockBoundingRect ( block ) availableWidth = self . __width - self . _RIGHT_MARGIN - self . _LEFT_MARGIN availableHeight = self . _editor . fontMetrics ( ) . height ( ) while block . isValid ( ) and top <= event . rect ( ) . bottom ( ) : if block . isVisible ( ) and bottom >= event . rect ( ) . top ( ) : number = str ( blockNumber + 1 ) painter . drawText ( self . _LEFT_MARGIN , top , availableWidth , availableHeight , Qt . AlignRight , number ) # if boundingRect.height() >= singleBlockHeight * 2:  # wrapped block #     painter.fillRect(1, top + singleBlockHeight, #                      self.__width - 2, #                      boundingRect.height() - singleBlockHeight - 2, #                      Qt.darkGreen) block = block . next ( ) boundingRect = self . _editor . blockBoundingRect ( block ) top = bottom bottom = top + int ( boundingRect . height ( ) ) blockNumber += 1