Is there any way to update labels/text of RadioSet
widget?
#3764
sambitnayak
started this conversation in
General
Replies: 2 comments
-
There isn't currently a method of changing a |
Beta Was this translation helpful? Give feedback.
0 replies
-
Just to follow up: it seemed like a sensible thing to want to do, so we've added the ability to assign to the So from that release, assuming you give your buttons their own ID, you can query them back and assign the new label: from textual.app import App, ComposeResult
from textual.widgets import RadioSet, RadioButton
class RadioLabelsApp(App[None]):
BINDINGS = [("s", "swap")]
def compose(self) -> ComposeResult:
yield RadioSet(
RadioButton("Alpha", id="one"),
RadioButton("Beta", id="two")
)
def action_swap(self) -> None:
self.query_one("#one", RadioButton).label = "Gamma"
self.query_one("#two", RadioButton).label = "Delta"
if __name__ == "__main__":
RadioLabelsApp().run() |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
A newbie question...
Let's imagine a quiz-type dialog using a
Label
/Static
for the question and aRadioSet
for the answer options.Just like using
Label
/Static
update()
to change the question, is there a way to change the labels/text of theRadioSet
?Or is it better to remove existing
RadioSet
and create a new one for the new options?Thanks.
Beta Was this translation helpful? Give feedback.
All reactions