mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Select widget (#2501)
* overlay rule * select WIP * select control, made binding description optional * changelog * style tweak * Added constrain * changelog * test fix * drop markup, tidy * tidy * select namespace * tests * docs * Added changed event * changelog * expanded * tests and snapshits * examples and docs * simplify * update reactive attributes * type fix * docstrings * allow renderables * superfluous init * typing fix * optimization * revert optimizations * fixed words * changelog * docstrings * don't need this * changelog * comment * Update docs/widgets/select.md Co-authored-by: Dave Pearson <davep@davep.org> * review changes * review updates --------- Co-authored-by: Dave Pearson <davep@davep.org>
This commit is contained in:
11
docs/examples/widgets/select.css
Normal file
11
docs/examples/widgets/select.css
Normal file
@@ -0,0 +1,11 @@
|
||||
Screen {
|
||||
align: center top;
|
||||
}
|
||||
|
||||
Select {
|
||||
width: 60;
|
||||
margin: 2;
|
||||
}
|
||||
Input {
|
||||
width: 60;
|
||||
}
|
||||
26
docs/examples/widgets/select_widget.py
Normal file
26
docs/examples/widgets/select_widget.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from textual import on
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.widgets import Header, Select
|
||||
|
||||
LINES = """I must not fear.
|
||||
Fear is the mind-killer.
|
||||
Fear is the little-death that brings total obliteration.
|
||||
I will face my fear.
|
||||
I will permit it to pass over me and through me.""".splitlines()
|
||||
|
||||
|
||||
class SelectApp(App):
|
||||
CSS_PATH = "select.css"
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Header()
|
||||
yield Select((line, line) for line in LINES)
|
||||
|
||||
@on(Select.Changed)
|
||||
def select_changed(self, event: Select.Changed) -> None:
|
||||
self.title = str(event.value)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = SelectApp()
|
||||
app.run()
|
||||
Reference in New Issue
Block a user