Пример #1
0
    def __init__(self, combobox_obj, regexp=None, parent=None):
        """
        Initialize an instance of the :class:`~ComboBoxValidator` class.

        Parameters
        ----------
        combobox_obj : :obj:`~PyQt5.QtWidgets.ComboBox` object
            Combobox object for which the editable line must be validated.

        Optional
        --------
        regexp : str or None. Default: None
            The regular expression pattern to use for validating an input
            string if it is not found in `combobox_obj`.
            If *None*, no regular expression is used.
        parent : :obj:`~PyQt5.QtCore.QObject` object or None. Default: None
            The parent object to use for this validator or *None* for no
            parent.

        """

        # Save the completer of the provided combobox
        self.completer = combobox_obj.completer()

        # Check provided regexp
        if regexp is None:
            # If regexp is None, set the pattern to one that rejects all
            regexp = r"$.^"

        # Call super constructor
        super().__init__(QC.QRegularExpression(regexp), parent)
Пример #2
0
    def __init__(self):
        super().__init__()

        # Variables
        expr = QtCore.QRegularExpression(r"^[\de\-.,+:;]+$")
        self.validator_text = QtGui.QRegularExpressionValidator(expr)
        self.validator_value = QtGui.QDoubleValidator()

        # Signals
        self.validator_text.changed.connect(self.changed)
        self.validator_value.changed.connect(self.changed)
Пример #3
0
    def __init__(self):
        super().__init__()

        # Variables
        self._composition = {}

        # Widgets
        self._widget = ColoredLineEdit()
        self._widget.setEnabled(False)
        self._widget.setValidator(
            QtGui.QRegularExpressionValidator(
                QtCore.QRegularExpression(r"^(?!\s*$).+")))

        self._suffix = QtWidgets.QCheckBox("auto")
        self._suffix.setChecked(True)

        # Signals
        self._widget.textChanged.connect(self.fieldChanged)
        self._suffix.stateChanged.connect(self._on_auto_changed)
Пример #4
0
 def __init__(self):
     super().__init__(QtCore.QRegularExpression(r"^[\w ]+$"))