-
Notifications
You must be signed in to change notification settings - Fork 815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop explicit sender attribute from messages #1940
Conversation
I'll review properly tomorrow morning, if this doesn't go in beforehand, but much like with the alternate compose method I'm throwing a very hearty OH HELL YES at this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of tweaks needed around ToggleButton
and friends, but otherwise looks good. This is a really nice spring-clean!
src/textual/widgets/_radio_set.py
Outdated
self.post_message_no_wait( | ||
self.Changed(self, cast(RadioButton, event.input)) | ||
) | ||
self.post_message(self.Changed(self, cast(RadioButton, event.radio_button))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect we don't need this cast now.
super().__init__(sender) | ||
self.input = sender | ||
super().__init__() | ||
self._toggle_button = toggle_button | ||
"""A reference to the toggle button that was changed.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This docstring can go now.
"""A reference to the toggle button that was changed.""" | ||
self.value = value | ||
"""The value of the toggle button after the change.""" | ||
|
||
@property | ||
def control(self) -> ToggleButton: | ||
"""Alias for self.toggle_button.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will need a reword given that toggle_button
was moved to being "private". Actually, I'm wondering if control
should move to the two individual child message classes.
Rectifies two API issues.
The
sender
attribute create boiler plate when sending messages. It was also a source of confusion as to its purpose.Having two messages
post_message
andpost_message_no_wait
is rather ugly, and difficult to explain. Awaiting posting something on a message queue is only necessary if the queue is bounded, but they aren't any more.sender
from the Message base class.post_message
. There is now justpost_message
which is syncronous.control
alias to messages from controls.See CHANGELOG for details