mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
* compositor refactor and trasparent screens * multuple layers * catch screen stack error * refinement * error messages * capture screen stack * new border type * Background screen * borders and bindings * snapshot * screen docs * fix for missing screens * screens docs * fix for non updating transparent screens * fix background resize * changelog * copy * superfluous function * update diagram * inline code * Update CHANGELOG.md Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com> * Update docs/guide/screens.md Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com> * superfluous file * Explicit None * Apply suggestions from code review Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com> * docstring * update docstring * docstring make property private * Apply suggestions from code review Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com> * docstring * update docstring * Apply suggestions from code review Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com> * docstrings * remove comment, add docstring * Apply suggestions from code review Co-authored-by: Dave Pearson <davep@davep.org> --------- Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com> Co-authored-by: Dave Pearson <davep@davep.org>
51 lines
1.4 KiB
Python
51 lines
1.4 KiB
Python
from textual.app import App, ComposeResult
|
|
from textual.containers import Grid
|
|
from textual.screen import Screen
|
|
from textual.widgets import Button, Footer, Header, Label
|
|
|
|
TEXT = """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.
|
|
And when it has gone past, I will turn the inner eye to see its path.
|
|
Where the fear has gone there will be nothing. Only I will remain."""
|
|
|
|
|
|
class QuitScreen(Screen):
|
|
"""Screen with a dialog to quit."""
|
|
|
|
def compose(self) -> ComposeResult:
|
|
yield Grid(
|
|
Label("Are you sure you want to quit?", id="question"),
|
|
Button("Quit", variant="error", id="quit"),
|
|
Button("Cancel", variant="primary", id="cancel"),
|
|
id="dialog",
|
|
)
|
|
|
|
def on_button_pressed(self, event: Button.Pressed) -> None:
|
|
if event.button.id == "quit":
|
|
self.app.exit()
|
|
else:
|
|
self.app.pop_screen()
|
|
|
|
|
|
class ModalApp(App):
|
|
"""A app with a modal dialog."""
|
|
|
|
CSS_PATH = "modal01.css"
|
|
BINDINGS = [("q", "request_quit", "Quit")]
|
|
|
|
def compose(self) -> ComposeResult:
|
|
yield Header()
|
|
yield Label(TEXT * 8)
|
|
yield Footer()
|
|
|
|
def action_request_quit(self) -> None:
|
|
self.push_screen(QuitScreen())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app = ModalApp()
|
|
app.run()
|