Rework the layout of the radio button example

Time to start to show off the new compose method.
This commit is contained in:
Dave Pearson
2023-02-27 09:10:10 +00:00
parent f436489efa
commit 23c0587efb

View File

@@ -6,17 +6,18 @@ class RadioChoicesApp(App[None]):
CSS_PATH = "radio_button.css" CSS_PATH = "radio_button.css"
def compose(self) -> ComposeResult: def compose(self) -> ComposeResult:
yield RadioSet( with RadioSet():
RadioButton("Battlestar Galactica"), yield RadioButton("Battlestar Galactica")
RadioButton("Dune 1984"), yield RadioButton("Dune 1984")
RadioButton("Dune 2021", id="focus_me"), yield RadioButton("Dune 2021", id="focus_me")
RadioButton("Serenity", value=True), yield RadioButton("Serenity", value=True)
RadioButton("Star Trek: The Motion Picture"), yield RadioButton("Star Trek: The Motion Picture")
RadioButton("Star Wars: A New Hope"), yield RadioButton("Star Wars: A New Hope")
RadioButton("The Last Starfighter"), yield RadioButton("The Last Starfighter")
RadioButton("Total Recall :backhand_index_pointing_right: :red_circle:"), yield RadioButton(
RadioButton("Wing Commander"), "Total Recall :backhand_index_pointing_right: :red_circle:"
) )
yield RadioButton("Wing Commander")
def on_mount(self) -> None: def on_mount(self) -> None:
self.query_one("#focus_me", RadioButton).focus() self.query_one("#focus_me", RadioButton).focus()