-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
in the following code only the second @on decorator works as expected.
When I comment out the second @on decorator, the first works as expected.
Is this a bug or can I only use one @on decorator in a class?
class MyClass(ModalScreen)
def compose(self)->ComposeResult:
yield Grid(
Label("Add A Playlist Item", id="pl_title"),
Static(id="pl_image"),
Label("Name"),
Input(id="pl_name",validators=[Length(minimum=2,maximum=30)]),
Label("Category"),
Input(id="pl_cat"),
Label("URL"),
Input(id="pl_uri",validators=[URL()]),
Static(), #place holder
Button("Cancel",id="cancel"),
Button("OK",id="save"),
id="dialog",
)
@on(Input.Submitted,"#pl_name")
def show_invalid_reasons(self, event: Input.Submitted) -> None:
if not event.validation_result.is_valid:
self.input_error = True
self.notify(str(event.validation_result.failure_descriptions),severity="error", timeout=10)
else:
self.input_error = False
@on(Input.Changed, "#pl_uri")
def show_invalid_reasons(self, event: Input.Changed) -> None:
# Updating the UI to show the reasons why validation failed
if not event.validation_result.is_valid:
self.input_error = True
else:
self.input_error = False
Metadata
Metadata
Assignees
Labels
No labels