Esempio n. 1
0
 def paintEvent(self, e):
     txt = self.currentText()
     if txt.startswith('no'):
         super(LineStyleComboBox, self).paintEvent(e)
         return
     lineStyle = lineStyles[lineStylesText[txt]]
     p = qt.QStylePainter(self)
     p.setPen(self.palette().color(qt.QPalette.Text))
     opt = qt.QStyleOptionComboBox()
     self.initStyleOption(opt)
     p.drawComplexControl(qt.QStyle.CC_ComboBox, opt)
     painter = qt.QPainter(self)
     painter.save()
     painter.setRenderHint(qt.QPainter.Antialiasing, False)
     rect = p.style().subElementRect(qt.QStyle.SE_ComboBoxFocusRect, opt,
                                     self)
     rect.adjust(+5, 0, -5, 0)
     pen = qt.QPen()
     pen.setColor(qt.QColor(self.parent().color))
     pen.setWidth(self.parent().widthSpinBox.value() * 1.5)
     pen.setStyle(lineStyle)
     painter.setPen(pen)
     middle = (rect.bottom() + rect.top()) / 2
     painter.drawLine(rect.left(), middle, rect.right(), middle)
     painter.restore()
Esempio n. 2
0
 def paintEvent(self, event):
     painter = qt.QStylePainter(self)
     if self.isVertical:
         painter.rotate(270)
         painter.translate(-self.height(), 0)
     else:
         painter.translate(0, -2)
     painter.drawControl(qt.QStyle.CE_PushButton, self.getStyleOptions())
Esempio n. 3
0
 def paintEvent(self, event):
     """
     :param qt.QPaintEvent event: Qt event
     """
     # Inherite paint event to be able to custom initStyleOption.
     # It's a protected function that can't be hinerited by Python.
     painter = qt.QStylePainter(self)
     painter.setPen(self.palette().color(qt.QPalette.Text))
     # draw the combobox frame, focusrect and selected etc.
     opt = qt.QStyleOptionComboBox()
     self.initStyleOption(opt)
     painter.drawComplexControl(qt.QStyle.CC_ComboBox, opt)
     # draw the icon and text
     painter.drawControl(qt.QStyle.CE_ComboBoxLabel, opt)
Esempio n. 4
0
    def paintEvent(self, e):
        txt = self.currentText()
        if txt == '':
            return
        if txt.startswith('no'):
            super(SymbolComboBox, self).paintEvent(e)
            return
        lineSymbol = lineSymbols[lineSymbolsText[txt]]
        p = qt.QStylePainter(self)
        p.setPen(self.palette().color(qt.QPalette.Text))
        opt = qt.QStyleOptionComboBox()
        self.initStyleOption(opt)
        p.drawComplexControl(qt.QStyle.CC_ComboBox, opt)
        painter = qt.QPainter(self)
        painter.save()
        painter.setRenderHint(qt.QPainter.Antialiasing, True)
        rect = p.style().subElementRect(qt.QStyle.SE_ComboBoxFocusRect, opt,
                                        self)
        rect.adjust(+5, 0, -5, 0)

        symbolFC = qt.QColor(self.parent().color)
        symbolEC = qt.QColor(self.parent().color)
        symbolSize = self.parent().sizeSpinBox.value() * 2
        symbolPath = qt.QPainterPath(lineSymbol)
        scale = symbolSize
        painter.scale(scale, scale)
        symbolOffset = qt.QPointF(
            (rect.left() + rect.right() - symbolSize) * 0.5 / scale,
            (rect.top() + rect.bottom() - symbolSize) * 0.5 / scale)
        symbolPath.translate(symbolOffset)
        symbolBrush = qt.QBrush(symbolFC, qt.Qt.SolidPattern)
        symbolPen = qt.QPen(symbolEC, 1. / scale, qt.Qt.SolidLine)
        painter.setPen(symbolPen)
        painter.setBrush(symbolBrush)
        painter.drawPath(symbolPath)
        painter.restore()