Пример #1
0
    def __init__(self, text_edit, hide_timer_on=False, as_tooltip=False):
        """ Create a call tip manager that is attached to the specified Qt
            text edit widget.
        """
        assert isinstance(text_edit, (QTextEdit, QPlainTextEdit))
        super(CallTipWidget, self).__init__(None, Qt.ToolTip)
        self.app = QCoreApplication.instance()
        self.as_tooltip = as_tooltip

        self.hide_timer_on = hide_timer_on
        self.tip = None
        self._hide_timer = QBasicTimer()
        self._text_edit = text_edit

        # Setup
        if sys.platform == 'darwin':
            # This keeps the hints below other applications
            self.setWindowFlags(Qt.SplashScreen)
        else:
            self.setWindowFlags(Qt.ToolTip | Qt.FramelessWindowHint)

        self.setTextInteractionFlags(Qt.TextSelectableByMouse)
        self.setFont(text_edit.document().defaultFont())
        self.setForegroundRole(QPalette.ToolTipText)
        self.setBackgroundRole(QPalette.ToolTipBase)
        self.setPalette(QToolTip.palette())

        self.setAlignment(Qt.AlignLeft)
        self.setIndent(1)
        self.setFrameStyle(QFrame.NoFrame)
        self.setMargin(1 + self.style().pixelMetric(
            QStyle.PM_ToolTipLabelFrameWidth, None, self))
Пример #2
0
    def initUI(self):
        ml = QVBoxLayout(self)
        ul = QHBoxLayout(self)
        dl = QHBoxLayout(self)
        ml.addLayout(ul)
        ml.addLayout(dl)

        col = QColor(0, 0, 0)
        self.colorText = 'Color Nmae: {}'
        self.btn = QPushButton('Dialog', self)
        self.btn.move(20, 20)
        self.btn.clicked.connect(self.showDialog)

        self.btn2 = QPushButton('Color', self)
        self.btn2.move(20, 40)
        self.btn2.clicked.connect(self.showColorDialoge)

        self.frm = QFrame(self)
        self.frm.setStyleSheet("QWidget { background-color: %s }" % col.name())
        self.frm.setGeometry(130, 50, 100, 100)

        self.le = QLineEdit(self)
        self.le.move(130, 22)

        self.label = QLabel(self.colorText.format(None), self)
        self.label.setGeometry(20, 80, 100, 30)

        self.timer = QBasicTimer()
        self.pb = QProgressBar(self)
        self.step = 0
        self.pb.setGeometry(20, 170, 300, 20)

        # calendar
        self.timeLable = QLabel('time is: ', self)
        # self.timeLable.setGeometry(20, 120, 100, 30)
        cal = QCalendarWidget(self)
        cal.clicked[QDate].connect(self.showDate)

        ul.addWidget(self.timeLable)
        dl.addWidget(cal)

        self.setLayout(ml)
        self.setGeometry(300, 300, 550, 550)
        self.setWindowTitle('Dialog')
        self.show()
Пример #3
0
    def __init__(self, text_edit, hide_timer_on=False):
        """ Create a call tip manager that is attached to the specified Qt
            text edit widget.
        """
        assert isinstance(text_edit, (QTextEdit, QPlainTextEdit))
        super(CallTipWidget, self).__init__(None, Qt.ToolTip)
        self.app = QCoreApplication.instance()

        self.hide_timer_on = hide_timer_on
        self._hide_timer = QBasicTimer()
        self._text_edit = text_edit

        self.setFont(text_edit.document().defaultFont())
        self.setForegroundRole(QPalette.ToolTipText)
        self.setBackgroundRole(QPalette.ToolTipBase)
        self.setPalette(QToolTip.palette())

        self.setAlignment(Qt.AlignLeft)
        self.setIndent(1)
        self.setFrameStyle(QFrame.NoFrame)
        self.setMargin(1 + self.style().pixelMetric(
            QStyle.PM_ToolTipLabelFrameWidth, None, self))