Exemplo n.º 1
0
 def set_regex_validator(self,
                         regex: str,
                         flags=0) -> gui.RegularExpressionValidator:
     validator = gui.RegularExpressionValidator(self)
     validator.set_regex(regex, flags)
     self.set_validator(validator)
     return validator
Exemplo n.º 2
0
def test_regularexpressionvalidator():
    val = gui.RegularExpressionValidator()
    val.set_regex("[0-9]")
    with open("data.pkl", "wb") as jar:
        pickle.dump(val, jar)
    with open("data.pkl", "rb") as jar:
        val = pickle.load(jar)
    assert val.get_regex() == "[0-9]"
    assert val.is_valid_value("0")
Exemplo n.º 3
0
 def _create_widget(self) -> widgets.LineEdit:
     widget = widgets.LineEdit()
     if self.notempty:
         val = custom_validators.NotEmptyValidator()
         widget.set_validator(val)
     if self.regex is not None:
         val = gui.RegularExpressionValidator()
         val.set_regex(self.regex)
         widget.set_validator(val)
     if self.value is not None:
         widget.set_value(self.value)
     return widget