You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you assign a message type to a class variable belonging to a class that derives from MessagePump, non-decorated message handlers stop working because the message type's handler_name incorrectly gets reassigned to use the name of the class containing the class variable as the namespace.
I ran into this when writing a general class for input prompts/modals, where I was using class variables to specify what event to treat as the "submit" event.
Simple example, where on_button_pressed won't be run unless EVENT_TYPE is removed:
fromtextual.appimportApp, ComposeResultfromtextual.widgetsimportButtonclassMyApp(App):
# prevents on_button_pressed from runningEVENT_TYPE=Button.Presseddefcompose(self) ->ComposeResult:
yieldButton("Click me")
defon_button_pressed(self) ->None:
self.query_one(Button).label="Clicked!"if__name__=='__main__':
MyApp().run()
# prints "on_my_app_pressed"!print(Button.Pressed.handler_name)
The text was updated successfully, but these errors were encountered:
If you assign a message type to a class variable belonging to a class that derives from MessagePump, non-decorated message handlers stop working because the message type's
handler_name
incorrectly gets reassigned to use the name of the class containing the class variable as the namespace.I ran into this when writing a general class for input prompts/modals, where I was using class variables to specify what event to treat as the "submit" event.
Simple example, where
on_button_pressed
won't be run unlessEVENT_TYPE
is removed:The text was updated successfully, but these errors were encountered: