mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Make a start on the SelectionList example apps
This commit is contained in:
10
docs/examples/widgets/selection_list.css
Normal file
10
docs/examples/widgets/selection_list.css
Normal file
@@ -0,0 +1,10 @@
|
||||
Screen {
|
||||
align: center middle;
|
||||
}
|
||||
|
||||
SelectionList {
|
||||
padding: 1;
|
||||
border: solid $accent;
|
||||
width: 80%;
|
||||
height: 80%;
|
||||
}
|
||||
28
docs/examples/widgets/selection_list.py
Normal file
28
docs/examples/widgets/selection_list.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.widgets import Footer, Header, SelectionList
|
||||
|
||||
|
||||
class SelectionListApp(App[None]):
|
||||
CSS_PATH = "selection_list.css"
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Header()
|
||||
yield SelectionList[int](
|
||||
("Falken's Maze", 0, True),
|
||||
("Black Jack", 1),
|
||||
("Gin Rummy", 2),
|
||||
("Hearts", 3),
|
||||
("Bridge", 4),
|
||||
("Checkers", 5),
|
||||
("Chess", 6, True),
|
||||
("Poker", 7),
|
||||
("Fighter Combat", 8, True),
|
||||
)
|
||||
yield Footer()
|
||||
|
||||
def on_mount(self) -> None:
|
||||
self.query_one(SelectionList).border_title = "Shall we play some games?"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
SelectionListApp().run()
|
||||
29
docs/examples/widgets/selection_list_selections.py
Normal file
29
docs/examples/widgets/selection_list_selections.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.widgets import Footer, Header, SelectionList
|
||||
from textual.widgets.selection_list import Selection
|
||||
|
||||
|
||||
class SelectionListApp(App[None]):
|
||||
CSS_PATH = "selection_list.css"
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Header()
|
||||
yield SelectionList[int](
|
||||
Selection("Falken's Maze", 0, True),
|
||||
Selection("Black Jack", 1),
|
||||
Selection("Gin Rummy", 2),
|
||||
Selection("Hearts", 3),
|
||||
Selection("Bridge", 4),
|
||||
Selection("Checkers", 5),
|
||||
Selection("Chess", 6, True),
|
||||
Selection("Poker", 7),
|
||||
Selection("Fighter Combat", 8, True),
|
||||
)
|
||||
yield Footer()
|
||||
|
||||
def on_mount(self) -> None:
|
||||
self.query_one(SelectionList).border_title = "Shall we play some games?"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
SelectionListApp().run()
|
||||
Reference in New Issue
Block a user