mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Add a full app to show off action_suspend_process binding
This commit is contained in:
15
docs/examples/app/suspend_process.py
Normal file
15
docs/examples/app/suspend_process.py
Normal 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()
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user