-
Notifications
You must be signed in to change notification settings - Fork 829
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
Add an example of using a RadioSet.Changed message #1935
Conversation
Unlike a few other widgets, the RadioSet is pretty much all about reacting to the selection result; the question of how you go about it has already come up and while the message is documented, complete with all properties, it can't hurt to have an illustrative example of code that uses it. Here I add an extra RadioSet example that sits with the message in the reference. This should help the reader better follow how to use it, and also gives something to link to if someone hasn't got that far into the documentation yet but is attempting to use the RadioSet.
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.
Great idea.
Do you think it is worth highlighting the line(s) that implement the handler and/or add a written note in the example? (Those that are marked with # (n)!
in the code.)
self.query_one("#focus_me", RadioButton).focus() | ||
|
||
def on_radio_set_changed(self, event: RadioSet.Changed) -> None: | ||
self.query_one("#pressed", Label).update( |
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.
Oh, I didn't know I could write queries like this! Cool 👍
Unlike a few other widgets, the RadioSet is pretty much all about reacting to the selection result; the question of how you go about it has already come up and while the message is documented, complete with all properties, it can't hurt to have an illustrative example of code that uses it.
Here I add an extra RadioSet example that sits with the message in the reference. This should help the reader better follow how to use it, and also gives something to link to if someone hasn't got that far into the documentation yet but is attempting to use the RadioSet.