Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 21, 2025
1 parent 3d4af63 commit d1c2908
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ipywidgets_jsonschema/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,11 +439,16 @@ def pattern_checker(val):
def _register_observer(h, n, t):
widget.observe(h, names=n, type=t)

warning_label = ipywidgets.Label("", layout=ipywidgets.Layout(color="red", display="none"))
warning_label = ipywidgets.Label(
"", layout=ipywidgets.Layout(color="red", display="none")
)

def _observer(change):
if not pattern_checker(widget.value):
pattern = schema.get("pattern", ".*")
warning_label.value = f"Warning: Input does not match the specified pattern"
warning_label.value = (
f"Warning: Input does not match the specified pattern"
)
warning_label.layout.display = "block"
change.owner.layout.border = "2px solid red"
else:
Expand All @@ -452,6 +457,7 @@ def _observer(change):
warning_label.layout.display = "none"

widget.observe(_observer, names="value", type="change")

def _setter(_d):
if pattern_checker(_d):
widget.value = _d
Expand Down

0 comments on commit d1c2908

Please sign in to comment.