Add a full app to show off action_suspend_process binding

This commit is contained in:
Dave Pearson
2024-01-31 12:47:10 +00:00
parent c916a82934
commit 1cd64f974f
2 changed files with 25 additions and 5 deletions

View File

@@ -0,0 +1,15 @@
from textual.app import App, ComposeResult
from textual.binding import Binding
from textual.widgets import Label
class SuspendKeysApp(App[None]):
BINDINGS = [Binding("ctrl+z", "suspend_process")]
def compose(self) -> ComposeResult:
yield Label("Press Ctrl+Z to suspend!")
if __name__ == "__main__":
SuspendKeysApp().run()

View File

@@ -276,11 +276,16 @@ Ordinarily this key combination is <kbd>Ctrl</kbd>+<kbd>Z</kbd>;
in a Textual application this is disabled by default, but an action is provided ([`action_suspend_process`](/api/app/#textual.app.App.action_suspend_process)) that you can bind in the usual way.
For example:
```python
BINDINGS = [
Binding("ctrl+z", "suspend_process")
]
```
=== "suspend_process.py"
```python hl_lines="8"
--8<-- "docs/examples/app/suspend_process.py"
```
=== "Output"
```{.textual path="docs/examples/app/suspend_process.py"}
```
!!! note