Is there a built-in way to make a "grid" RadioSet? #3157
Answered
by
davep
Apocryphon-X
asked this question in
Q&A
-
I want to see if it is possible to get something like this in |
Beta Was this translation helpful? Give feedback.
Answered by
davep
Aug 24, 2023
Replies: 2 comments 1 reply
-
Right now, the default is this: |
Beta Was this translation helpful? Give feedback.
0 replies
-
You could style the from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import RadioButton, RadioSet
class RadioChoicesApp(App[None]):
CSS = """
Screen {
align: center middle;
}
Horizontal {
align: center middle;
height: auto;
}
RadioSet {
width: 45%;
layout: grid;
grid-size: 2;
}
"""
def compose(self) -> ComposeResult:
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")
def on_mount(self) -> None:
self.query_one("#focus_me").focus()
if __name__ == "__main__":
RadioChoicesApp().run() |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Apocryphon-X
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could style the
RadioSet
so that it islayout: grid
. For example: