Exemple #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()
Exemple #2
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.State_Raised | QStyle.State_Active | QStyle.State_MouseOver
         s = self.style()
         s.drawPrimitive(QStyle.PE_PanelButtonTool, tool, painter, self)
     painter.drawText(
         0, 0,
         self.width(),
         ls, Qt.AlignCenter | Qt.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.AlignCenter | Qt.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()
Exemple #3
0
 def paintEvent(self, ev):
     if self.mouse_over:
         p = QPainter(self)
         tool = QStyleOption()
         tool.rect = self.rect()
         tool.state = QStyle.State_Raised | QStyle.State_Active | QStyle.State_MouseOver
         s = self.style()
         s.drawPrimitive(QStyle.PE_PanelButtonTool, tool, p, self)
         p.end()
     return QLabel.paintEvent(self, ev)
Exemple #4
0
 def paintEvent(self, ev):
     if self.mouse_over:
         p = QPainter(self)
         tool = QStyleOption()
         tool.rect = self.rect()
         tool.state = QStyle.State_Raised | QStyle.State_Active | QStyle.State_MouseOver
         s = self.style()
         s.drawPrimitive(QStyle.PE_PanelButtonTool, tool, p, self)
         p.end()
     return QLabel.paintEvent(self, ev)