File: radio_set.py

package info (click to toggle)
textual 2.1.2-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 55,080 kB
  • sloc: python: 85,423; lisp: 1,669; makefile: 101
file content (42 lines) | stat: -rw-r--r-- 1,486 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import RadioButton, RadioSet


class RadioChoicesApp(App[None]):
    CSS_PATH = "radio_set.tcss"

    def compose(self) -> ComposeResult:
        with Horizontal():
            # A RadioSet built up from RadioButtons.
            with RadioSet(id="focus_me"):
                yield RadioButton("Battlestar Galactica")
                yield RadioButton("Dune 1984")
                yield RadioButton("Dune 2021")
                yield RadioButton("Serenity", value=True)
                yield RadioButton("Star Trek: The Motion Picture")
                yield RadioButton("Star Wars: A New Hope")
                yield RadioButton("The Last Starfighter")
                yield RadioButton(
                    "Total Recall :backhand_index_pointing_right: :red_circle:"
                )
                yield RadioButton("Wing Commander")
            # A RadioSet built up from a collection of strings.
            yield RadioSet(
                "Amanda",
                "Connor MacLeod",
                "Duncan MacLeod",
                "Heather MacLeod",
                "Joe Dawson",
                "Kurgan, [bold italic red]The[/]",
                "Methos",
                "Rachel Ellenstein",
                "Ramírez",
            )

    def on_mount(self) -> None:
        self.query_one("#focus_me").focus()


if __name__ == "__main__":
    RadioChoicesApp().run()