Skip to content
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

Merged
merged 1 commit into from
Mar 6, 2023

Conversation

davep
Copy link
Contributor

@davep davep commented Mar 4, 2023

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.

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.
@davep davep added the documentation Improvements or additions to documentation label Mar 4, 2023
@davep davep self-assigned this Mar 4, 2023
Copy link
Contributor

@rodrigogiraoserrao rodrigogiraoserrao left a 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(
Copy link
Contributor

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 👍

@willmcgugan willmcgugan merged commit 623b70d into Textualize:main Mar 6, 2023
rodrigogiraoserrao added a commit that referenced this pull request Mar 6, 2023
In the aftermath of #1935 and #1940 this fell through the cracks.
willmcgugan pushed a commit that referenced this pull request Mar 6, 2023
In the aftermath of #1935 and #1940 this fell through the cracks.
@davep davep deleted the expand-radioset-examples branch March 6, 2023 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend the RadioSet reference example to make it clear how to use the Changed event
3 participants