mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
snapshot
This commit is contained in:
38
tests/snapshot_tests/snapshot_apps/screen_switch.py
Normal file
38
tests/snapshot_tests/snapshot_apps/screen_switch.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.screen import Screen
|
||||
from textual.widgets import Static, Header, Footer
|
||||
|
||||
|
||||
class ScreenA(Screen):
|
||||
BINDINGS = [("b", "switch_to_b", "Switch to screen B")]
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Header()
|
||||
yield Static("A")
|
||||
yield Footer()
|
||||
|
||||
def action_switch_to_b(self):
|
||||
self.app.switch_screen(ScreenB())
|
||||
|
||||
|
||||
class ScreenB(Screen):
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Header()
|
||||
yield Static("B")
|
||||
yield Footer()
|
||||
|
||||
|
||||
class ModalApp(App):
|
||||
BINDINGS = [("a", "push_a", "Push screen A")]
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Header()
|
||||
yield Footer()
|
||||
|
||||
def action_push_a(self) -> None:
|
||||
self.push_screen(ScreenA())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = ModalApp()
|
||||
app.run()
|
||||
Reference in New Issue
Block a user