mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Experiment with recording at all levels
More attempts to figure out why I'm getting the async issue with messages and the pilot.
This commit is contained in:
@@ -545,27 +545,29 @@ class PriorityOverlapWidget(Static, can_focus=True):
|
|||||||
"""A focusable widget with a priority binding."""
|
"""A focusable widget with a priority binding."""
|
||||||
|
|
||||||
BINDINGS = [
|
BINDINGS = [
|
||||||
Binding("0", "app.record('widget_0')", "0", priority=False),
|
Binding("0", "record('widget_0')", "0", priority=False),
|
||||||
Binding("a", "app.record('widget_a')", "a", priority=False),
|
Binding("a", "record('widget_a')", "a", priority=False),
|
||||||
Binding("b", "app.record('widget_b')", "b", priority=False),
|
Binding("b", "record('widget_b')", "b", priority=False),
|
||||||
Binding("c", "app.record('widget_c')", "c", priority=True),
|
Binding("c", "record('widget_c')", "c", priority=True),
|
||||||
Binding("d", "app.record('widget_d')", "d", priority=False),
|
Binding("d", "record('widget_d')", "d", priority=False),
|
||||||
Binding("e", "app.record('widget_e')", "e", priority=True),
|
Binding("e", "record('widget_e')", "e", priority=True),
|
||||||
Binding("f", "app.record('widget_f')", "f", priority=True),
|
Binding("f", "record('widget_f')", "f", priority=True),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
async def action_record( self, key: str ) -> None:
|
||||||
|
await self.app.action_record( key )
|
||||||
|
|
||||||
class PriorityOverlapScreen(Screen):
|
class PriorityOverlapScreen(Screen):
|
||||||
"""A screen with a priority binding."""
|
"""A screen with a priority binding."""
|
||||||
|
|
||||||
BINDINGS = [
|
BINDINGS = [
|
||||||
Binding("0", "app.record('screen_0')", "0", priority=False),
|
Binding("0", "record('screen_0')", "0", priority=False),
|
||||||
Binding("a", "app.record('screen_a')", "a", priority=False),
|
Binding("a", "record('screen_a')", "a", priority=False),
|
||||||
Binding("b", "app.record('screen_b')", "b", priority=True),
|
Binding("b", "record('screen_b')", "b", priority=True),
|
||||||
Binding("c", "app.record('screen_c')", "c", priority=False),
|
Binding("c", "record('screen_c')", "c", priority=False),
|
||||||
Binding("d", "app.record('screen_d')", "c", priority=True),
|
Binding("d", "record('screen_d')", "c", priority=True),
|
||||||
Binding("e", "app.record('screen_e')", "e", priority=False),
|
Binding("e", "record('screen_e')", "e", priority=False),
|
||||||
Binding("f", "app.record('screen_f')", "f", priority=True),
|
Binding("f", "record('screen_f')", "f", priority=True),
|
||||||
]
|
]
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
@@ -574,6 +576,8 @@ class PriorityOverlapScreen(Screen):
|
|||||||
def on_mount(self) -> None:
|
def on_mount(self) -> None:
|
||||||
self.query_one(PriorityOverlapWidget).focus()
|
self.query_one(PriorityOverlapWidget).focus()
|
||||||
|
|
||||||
|
async def action_record( self, key: str ) -> None:
|
||||||
|
await self.app.action_record( key )
|
||||||
|
|
||||||
class PriorityOverlapApp(AppKeyRecorder):
|
class PriorityOverlapApp(AppKeyRecorder):
|
||||||
"""An application with a priority binding."""
|
"""An application with a priority binding."""
|
||||||
@@ -593,6 +597,9 @@ class PriorityOverlapApp(AppKeyRecorder):
|
|||||||
def on_mount(self) -> None:
|
def on_mount(self) -> None:
|
||||||
self.push_screen("main")
|
self.push_screen("main")
|
||||||
|
|
||||||
|
async def action_record( self, key: str ) -> None:
|
||||||
|
await super().action_record( key )
|
||||||
|
|
||||||
|
|
||||||
async def test_overlapping_priority_bindings() -> None:
|
async def test_overlapping_priority_bindings() -> None:
|
||||||
"""Test an app stack with overlapping bindings."""
|
"""Test an app stack with overlapping bindings."""
|
||||||
|
|||||||
Reference in New Issue
Block a user