-
Notifications
You must be signed in to change notification settings - Fork 780
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Select.from_values class method for initializing with iterator (#…
…3743) * prototype to use class method to initialize Select object using an iterator * add docstring and optional arguments to Select.from_values() * add test widget for Select.from_values() and update documentation to include an example for its use * add snapshot tests to Select.from_values() class method and update snapshots to include results * address review comments --------- Co-authored-by: Rodrigo Girão Serrão <[email protected]>
- Loading branch information
1 parent
d04c838
commit 87ef1bb
Showing
6 changed files
with
276 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.tcss" | ||
|
||
def compose(self) -> ComposeResult: | ||
yield Header() | ||
yield Select.from_values(LINES) | ||
|
||
@on(Select.Changed) | ||
def select_changed(self, event: Select.Changed) -> None: | ||
self.title = str(event.value) | ||
|
||
|
||
if __name__ == "__main__": | ||
app = SelectApp() | ||
app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.