Beispiel #1
0
 def paintEvent(self, ev):
     shown = self.button.isChecked()
     ls = self.fm.lineSpacing()
     painter = QPainter(self)
     if self.mouse_over:
         tool = QStyleOption()
         tool.rect = self.rect()
         tool.state = QStyle.StateFlag.State_Raised | QStyle.StateFlag.State_Active | QStyle.StateFlag.State_MouseOver
         s = self.style()
         s.drawPrimitive(QStyle.PrimitiveElement.PE_PanelButtonTool, tool,
                         painter, self)
     painter.drawText(
         0, 0, self.width(), ls,
         Qt.AlignmentFlag.AlignCenter | Qt.TextFlag.TextSingleLine,
         self.text)
     text = _('Hide') if shown else _('Show')
     f = self.font()
     f.setBold(True)
     painter.setFont(f)
     painter.drawText(
         0,
         self.height() - ls, self.width(), ls,
         Qt.AlignmentFlag.AlignCenter | Qt.TextFlag.TextSingleLine, text)
     x = (self.width() - ICON_SZ) // 2
     y = ls + (self.height() - ICON_SZ - 2 * ls) // 2
     pmap = self.bright_icon if shown else self.dull_icon
     painter.drawPixmap(x, y, pmap)
     painter.end()
Beispiel #2
0
 def paintEvent(self, ev):
     if self.mouse_over:
         p = QPainter(self)
         tool = QStyleOption()
         tool.rect = self.rect()
         tool.state = QStyle.StateFlag.State_Raised | QStyle.StateFlag.State_Active | QStyle.StateFlag.State_MouseOver
         s = self.style()
         s.drawPrimitive(QStyle.PrimitiveElement.PE_PanelButtonTool, tool, p, self)
         p.end()
     return QLabel.paintEvent(self, ev)
Beispiel #3
0
 def paintEvent(self, ev):
     if self.mouse_over:
         p = QStylePainter(self)
         tool = QStyleOption()
         tool.initFrom(self)
         tool.rect = self.rect()
         tool.state = QStyle.StateFlag.State_Raised | QStyle.StateFlag.State_Active | QStyle.StateFlag.State_MouseOver
         p.drawPrimitive(QStyle.PrimitiveElement.PE_PanelButtonTool, tool)
         p.end()
     QWidget.paintEvent(self, ev)
Beispiel #4
0
 def style_option(self):
     opt = QStyleOption()
     opt.initFrom(self)
     opt.state |= QStyle.StateFlag.State_Horizontal
     return opt