Python PyQt5.QtWidgets.QAbstractButton() Examples

The following are 7 code examples for showing how to use PyQt5.QtWidgets.QAbstractButton(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module PyQt5.QtWidgets , or try the search function .

Example 1
Project: pyweed   Author: iris-edu   File: OptionsWidget.py    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
def getInputValue(self, key):
        """
        Get the value of a single input. This is intended to Pythonify the Qt values that come natively
        from the widgets. (ie. return a Python date rather than a QDate).

        This is used internally by getOptions()
        """
        one_input = self.inputs.get(key)
        if one_input:
            if isinstance(one_input, QtWidgets.QDateTimeEdit):
                # DateTime
                return one_input.dateTime().toString(QtCore.Qt.ISODate)
            elif isinstance(one_input, QtWidgets.QAbstractButton):
                # Radio/checkbox button
                return str(one_input.isChecked())
            elif isinstance(one_input, QtWidgets.QComboBox):
                return one_input.currentText()
            elif hasattr(one_input, 'text'):
                return one_input.text()
            raise Exception("Couldn't identify the QWidget type for %s (%s)" % (key, one_input))
        return None 
Example 2
Project: tinydecred   Author: decred   File: qutilities.py    License: ISC License 6 votes vote down vote up
def paintEvent(self, e):
        """
        QAbstractButton method. Paint the button.
        """
        painter = QtGui.QPainter(self)
        painter.setPen(QtCore.Qt.NoPen)
        painter.setRenderHint(QtGui.QPainter.Antialiasing, True)
        painter.setBrush(self.switchBrush if self.on else self.disabledBrush)
        painter.setOpacity(0.6)
        painter.drawRoundedRect(
            self.slotRect, self.slotHeight / 2, self.slotHeight / 2,
        )
        painter.setOpacity(1.0)
        painter.drawEllipse(
            QtCore.QRect(self.xPos, 0, self.fullHeight, self.fullHeight,)
        ) 
Example 3
Project: pyweed   Author: iris-edu   File: OptionsWidget.py    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
def setInputValue(self, key, value):
        """
        Set the input value based on a string from the options
        """
        one_input = self.inputs.get(key)
        if one_input:
            if isinstance(one_input, QtWidgets.QDateTimeEdit):
                # Ugh, complicated conversion from UTCDateTime
                dt = QtCore.QDateTime.fromString(value, QtCore.Qt.ISODate)
                one_input.setDateTime(dt)
            elif isinstance(one_input, QtWidgets.QDoubleSpinBox):
                # Float value
                one_input.setValue(float(value))
            elif isinstance(one_input, QtWidgets.QComboBox):
                # Combo box
                index = one_input.findText(value)
                if index > -1:
                    one_input.setCurrentIndex(index)
            elif isinstance(one_input, QtWidgets.QLineEdit):
                # Text input
                one_input.setText(value)
            elif isinstance(one_input, QtWidgets.QAbstractButton):
                # Radio/checkbox button
                one_input.setChecked(strtobool(str(value)))
            else:
                raise Exception("Don't know how to set an input for %s (%s)" % (key, one_input)) 
Example 4
Project: awesometts-anki-addon   Author: AwesomeTTS   File: stripper.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _ui_buttons(self):
        """
        Adjust title of the OK button.
        """

        buttons = super(BrowserStripper, self)._ui_buttons()
        buttons.findChild(QtWidgets.QAbstractButton, 'okay').setText("&Remove Now")

        return buttons

    # Events ################################################################# 
Example 5
Project: awesometts-anki-addon   Author: AwesomeTTS   File: templater.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _ui_buttons(self):
        """
        Adjust title of the OK button.
        """

        buttons = super(Templater, self)._ui_buttons()
        buttons.findChild(QtWidgets.QAbstractButton, 'okay').setText("&Insert")

        return buttons

    # Events ################################################################# 
Example 6
Project: awesometts-anki-addon   Author: AwesomeTTS   File: generator.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _ui_buttons(self):
        """
        Adjust title of the OK button.
        """

        buttons = super(BrowserGenerator, self)._ui_buttons()
        buttons.findChild(QtWidgets.QAbstractButton, 'okay').setText("&Generate")

        return buttons

    # Events ################################################################# 
Example 7
Project: awesometts-anki-addon   Author: AwesomeTTS   File: generator.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _ui_buttons(self):
        """
        Adjust title of the OK button.
        """

        buttons = super(EditorGenerator, self)._ui_buttons()
        buttons.findChild(QtWidgets.QAbstractButton, 'okay').setText("&Record")

        return buttons

    # Events #################################################################