Usage of the textual.on
decorator in parent/mixin classes
#3948
Unanswered
joshua-dean
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is more of a question of usage/feasibility than an outright feature request, so apologies if I've improperly categorized the issue.
Versions:
python 3.11.7
textual 0.46.0
The
textual.on
decorator is useful, but does not function if used in an inherited class:Clicking the
Placeholder
in this example yields:widget handle_click
widget on_click
mixin on_click
but does not produce
mixin handle_click
.The logic for this appears to be at the
_MessagePumpMeta
level, asclass_dict
will not contain methods fromOnClickMixin
, so no methods in the mixin ever get checked for the_textual_on
attribute.Changing
OnClickMixin
to inheritMessagePump
does cause all four toasts to appear. Is this within the intended use of theMessagePump
class, or could utilizing it in this way create problems in the future?If it is not good practice or the intended usage, would it be useful to implement a base class for this purpose, and/or change the logic in
_MessagePumpMeta
to accommodate this use case?Beta Was this translation helpful? Give feedback.
All reactions