-
Notifications
You must be signed in to change notification settings - Fork 814
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4064 from davep/suspend-redux
Application suspension
- Loading branch information
Showing
14 changed files
with
419 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
::: textual.signal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from os import system | ||
|
||
from textual import on | ||
from textual.app import App, ComposeResult | ||
from textual.widgets import Button | ||
|
||
|
||
class SuspendingApp(App[None]): | ||
|
||
def compose(self) -> ComposeResult: | ||
yield Button("Open the editor", id="edit") | ||
|
||
@on(Button.Pressed, "#edit") | ||
def run_external_editor(self) -> None: | ||
with self.suspend(): # (1)! | ||
system("vim") | ||
|
||
|
||
if __name__ == "__main__": | ||
SuspendingApp().run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.