Ejemplo n.º 1
0
 def __init__(self, parent=None, **kwargs):
     # type: (Optional[QWidget], Any) -> None
     super().__init__(parent, **kwargs)
     self.__text = ""
     self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
     if sys.platform != "darwin":
         font = QApplication.font("QWidget")
         self.setFont(qfont_scaled(font, 0.85))
         self.setAttribute(Qt.WA_SetFont, False)
Ejemplo n.º 2
0
 def __init__(self, parent=None, **kwargs):
     # type: (Optional[QWidget], Any) -> None
     super().__init__(parent, **kwargs)
     self.__text = ""
     self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
     if sys.platform != "darwin":
         font = QApplication.font("QToolButton")
         font.setPointSize(12)
         self.setFont(font)
         self.setAttribute(Qt.WA_SetFont, False)
Ejemplo n.º 3
0
    def __init__(self, *args, **kwargs):
        self.__pressed = -1  # Tracking the pressed section index
        super().__init__(*args, **kwargs)

        def set_pressed(index):
            self.__pressed = index
        self.sectionPressed.connect(set_pressed)
        self.sectionEntered.connect(set_pressed)
        # Workaround for QTBUG-89910
        self.setFont(QApplication.font("QHeaderView"))
Ejemplo n.º 4
0
    def __init__(self, parent=None, **kwargs):
        # type: (Optional[QWidget], Any) -> None
        self.__nativeStyling = False
        self.position = ToolBoxTabButton.OnlyOneTab
        self.selected = ToolBoxTabButton.NotAdjacent
        font = kwargs.pop("font", None)  # type: Optional[QFont]
        super().__init__(parent, **kwargs)

        if font is None:
            self.setFont(QApplication.font("QAbstractButton"))
            self.setAttribute(Qt.WA_SetFont, False)
        else:
            self.setFont(font)
Ejemplo n.º 5
0
def show_tool_tip(pos: QPoint, text: str, widget: Optional[QWidget] = None,
                  rect=QRect(), elide=Qt.ElideRight):
    """
    Show a plain text tool tip with limited length, eliding if necessary.
    """
    if widget is not None:
        screen = widget.screen()
    else:
        screen = QApplication.screenAt(pos)
    font = QApplication.font("QTipLabel")
    fm = QFontMetrics(font)
    geom = screen.availableSize()
    etext = fm.elidedText(text, elide, geom.width())
    if etext != text:
        text = f"<span>{etext}</span>"
    QToolTip.showText(pos, text, widget, rect)
Ejemplo n.º 6
0
def show_tip(widget: QWidget,
             pos: QPoint,
             text: str,
             timeout=-1,
             textFormat=Qt.AutoText,
             wordWrap=None):
    propname = __name__ + "::show_tip_qlabel"
    if timeout < 0:
        timeout = widget.toolTipDuration()
    if timeout < 0:
        timeout = 5000 + 40 * max(0, len(text) - 100)
    tip = widget.property(propname)
    if not text and tip is None:
        return

    def hide():
        w = tip.parent()
        w.setProperty(propname, None)
        tip.timer.stop()
        tip.close()
        tip.deleteLater()

    if not isinstance(tip, QLabel):
        tip = QLabel(objectName="tip-label", focusPolicy=Qt.NoFocus)
        tip.setBackgroundRole(QPalette.ToolTipBase)
        tip.setForegroundRole(QPalette.ToolTipText)
        tip.setPalette(QToolTip.palette())
        tip.setFont(QApplication.font("QTipLabel"))
        tip.timer = QTimer(tip, singleShot=True, objectName="hide-timer")
        tip.timer.timeout.connect(hide)
        widget.setProperty(propname, tip)
        tip.setParent(widget, Qt.ToolTip)

    tip.setText(text)
    tip.setTextFormat(textFormat)
    if wordWrap is None:
        wordWrap = textFormat != Qt.PlainText
    tip.setWordWrap(wordWrap)

    if not text:
        hide()
    else:
        tip.timer.start(timeout)
        tip.show()
        tip.move(pos)
Ejemplo n.º 7
0
    def __init__(self, *args, **kwargs):
        self.__nativeStyling = False
        self.position = QStyleOptionToolBox.OnlyOneTab
        self.selected = QStyleOptionToolBox.NotAdjacent
        font = kwargs.pop("font", None)
        palette = kwargs.pop("palette", None)

        QToolButton.__init__(self, *args, **kwargs)

        if font is None:
            self.setFont(QApplication.font("QAbstractButton"))
            self.setAttribute(Qt.WA_SetFont, False)
        else:
            self.setFont(font)
        if palette is None:
            self.setPalette(QApplication.palette("QAbstractButton"))
            self.setAttribute(Qt.WA_SetPalette, False)
        else:
            self.setPalette(palette)
Ejemplo n.º 8
0
    def __init__(self, *args, **kwargs):
        self.__nativeStyling = False
        self.position = QStyleOptionToolBox.OnlyOneTab
        self.selected = QStyleOptionToolBox.NotAdjacent
        font = kwargs.pop("font", None)
        palette = kwargs.pop("palette", None)

        super().__init__(*args, **kwargs)

        if font is None:
            self.setFont(QApplication.font("QAbstractButton"))
            self.setAttribute(Qt.WA_SetFont, False)
        else:
            self.setFont(font)
        if palette is None:
            self.setPalette(QApplication.palette("QAbstractButton"))
            self.setAttribute(Qt.WA_SetPalette, False)
        else:
            self.setPalette(palette)
Ejemplo n.º 9
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.setFont(QApplication.font("QAbstractButton"))