From ae54db4f2a3a6ce28683067c50d10e4fa3e78931 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Wed, 19 Oct 2022 14:03:11 +0100 Subject: [PATCH 01/14] Remove the bell from the calculator Don't ping the terminal bell on every key-press. This might be okay on some systems, on others (we're looking at you Windows) it's a wee bit distracting. See #955. --- examples/calculator.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/calculator.py b/examples/calculator.py index 9477b6cdd..de8e8b12c 100644 --- a/examples/calculator.py +++ b/examples/calculator.py @@ -93,8 +93,6 @@ class CalculatorApp(App): button_id = event.button.id assert button_id is not None - self.bell() # Terminal bell - def do_math() -> None: """Does the math: LEFT OPERATOR RIGHT""" try: From f5ce603d4338434cbb04733c9bbc2a5bec07d5ce Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Wed, 19 Oct 2022 14:41:13 +0100 Subject: [PATCH 02/14] Remove the bell from the actions01 documentation example --- docs/examples/guide/actions/actions01.py | 1 - docs/guide/actions.md | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/examples/guide/actions/actions01.py b/docs/examples/guide/actions/actions01.py index 03d83530e..54b366f95 100644 --- a/docs/examples/guide/actions/actions01.py +++ b/docs/examples/guide/actions/actions01.py @@ -5,7 +5,6 @@ from textual import events class ActionsApp(App): def action_set_background(self, color: str) -> None: self.screen.styles.background = color - self.bell() def on_key(self, event: events.Key) -> None: if event.key == "r": diff --git a/docs/guide/actions.md b/docs/guide/actions.md index 7a33a424e..7b5db7057 100644 --- a/docs/guide/actions.md +++ b/docs/guide/actions.md @@ -12,7 +12,7 @@ Action methods are methods on your app or widgets prefixed with `action_`. Aside Let's write an app with a simple action. -```python title="actions01.py" hl_lines="6-8 12" +```python title="actions01.py" hl_lines="6-7 11" --8<-- "docs/examples/guide/actions/actions01.py" ``` From 5c5ca3316fa9bb7b89660ba8361490c30997c28e Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Wed, 19 Oct 2022 14:43:37 +0100 Subject: [PATCH 03/14] Remove the bell from the actions02 documentation example --- docs/examples/guide/actions/actions02.py | 1 - docs/guide/actions.md | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/examples/guide/actions/actions02.py b/docs/examples/guide/actions/actions02.py index b322b6aa8..e59d04182 100644 --- a/docs/examples/guide/actions/actions02.py +++ b/docs/examples/guide/actions/actions02.py @@ -5,7 +5,6 @@ from textual import events class ActionsApp(App): def action_set_background(self, color: str) -> None: self.screen.styles.background = color - self.bell() async def on_key(self, event: events.Key) -> None: if event.key == "r": diff --git a/docs/guide/actions.md b/docs/guide/actions.md index 7b5db7057..a443bd589 100644 --- a/docs/guide/actions.md +++ b/docs/guide/actions.md @@ -22,7 +22,7 @@ Although it is possible (and occasionally useful) to call action methods in this The following example replaces the immediate call with a call to [action()][textual.widgets.Widget.action] which parses an action string and dispatches it to the appropriate method. -```python title="actions02.py" hl_lines="10-12" +```python title="actions02.py" hl_lines="9-11" --8<-- "docs/examples/guide/actions/actions02.py" ``` From aa8580bee74af79bc14391598f8f6d8ffa8fa427 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Wed, 19 Oct 2022 14:54:57 +0100 Subject: [PATCH 04/14] Remove the bell from the actions03 documentation example --- docs/examples/guide/actions/actions03.py | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/examples/guide/actions/actions03.py b/docs/examples/guide/actions/actions03.py index 22ccf57aa..ff68a58e9 100644 --- a/docs/examples/guide/actions/actions03.py +++ b/docs/examples/guide/actions/actions03.py @@ -15,7 +15,6 @@ class ActionsApp(App): def action_set_background(self, color: str) -> None: self.screen.styles.background = color - self.bell() if __name__ == "__main__": From f76e472096ebbc27aea7bec69e50f4d5712d3942 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Wed, 19 Oct 2022 14:57:50 +0100 Subject: [PATCH 05/14] Remove the bell from the actions04 documentation example --- docs/examples/guide/actions/actions04.py | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/examples/guide/actions/actions04.py b/docs/examples/guide/actions/actions04.py index 6a1ac9d46..c233400e7 100644 --- a/docs/examples/guide/actions/actions04.py +++ b/docs/examples/guide/actions/actions04.py @@ -21,7 +21,6 @@ class ActionsApp(App): def action_set_background(self, color: str) -> None: self.screen.styles.background = color - self.bell() if __name__ == "__main__": From ce0c6c49a205734df556f2904cf9d131bebec015 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Wed, 19 Oct 2022 14:59:59 +0100 Subject: [PATCH 06/14] Remove the bell from the actions05 documentation example --- docs/examples/guide/actions/actions05.py | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/examples/guide/actions/actions05.py b/docs/examples/guide/actions/actions05.py index a73ccfd21..05a7d6406 100644 --- a/docs/examples/guide/actions/actions05.py +++ b/docs/examples/guide/actions/actions05.py @@ -28,7 +28,6 @@ class ActionsApp(App): def action_set_background(self, color: str) -> None: self.screen.styles.background = color - self.bell() if __name__ == "__main__": From f8bda04d90a06cf67ac9d9b8c56abb3edc3dfa6b Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Wed, 19 Oct 2022 15:05:18 +0100 Subject: [PATCH 07/14] Remove the on_space from key01 in the docs While in this part of the docs we do want to keep the bell (see key02), it was an error in the code that it included this event in key01. Removing it from here because adding this bit of code for key02 is a key (no pun) part of the docs. --- docs/examples/guide/input/key01.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/examples/guide/input/key01.py b/docs/examples/guide/input/key01.py index c04a7cd26..44d88d558 100644 --- a/docs/examples/guide/input/key01.py +++ b/docs/examples/guide/input/key01.py @@ -12,9 +12,6 @@ class InputApp(App): def on_key(self, event: events.Key) -> None: self.query_one(TextLog).write(event) - def key_space(self) -> None: - self.bell() - if __name__ == "__main__": app = InputApp() From bd0e1c01b1d91860f5faf5cc61fd76f77f2af7eb Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Wed, 19 Oct 2022 15:12:11 +0100 Subject: [PATCH 08/14] Remove intro01.py It doesn't appear to be referenced anywhere in the docs. --- docs/examples/tutorial/intro01.py | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 docs/examples/tutorial/intro01.py diff --git a/docs/examples/tutorial/intro01.py b/docs/examples/tutorial/intro01.py deleted file mode 100644 index 6a2e2d4a1..000000000 --- a/docs/examples/tutorial/intro01.py +++ /dev/null @@ -1,9 +0,0 @@ -from textual.app import App - - -class ExampleApp(App): - pass - - -app = ExampleApp() -app.run() From e8bb08453842307aa9c90ac368bd5a8ae91c64b7 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Wed, 19 Oct 2022 15:12:54 +0100 Subject: [PATCH 09/14] Remove intro02.py It doesn't appear to be referenced anywhere in the docs. --- docs/examples/tutorial/intro02.py | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 docs/examples/tutorial/intro02.py diff --git a/docs/examples/tutorial/intro02.py b/docs/examples/tutorial/intro02.py deleted file mode 100644 index 2f5d3ed64..000000000 --- a/docs/examples/tutorial/intro02.py +++ /dev/null @@ -1,29 +0,0 @@ -from textual.app import App - - -class ExampleApp(App): - - COLORS = [ - "white", - "maroon", - "red", - "purple", - "fuchsia", - "olive", - "yellow", - "navy", - "teal", - "aqua", - ] - - def on_mount(self): - self.styles.background = "darkblue" - - def on_key(self, event): - if event.key.isdigit(): - self.styles.background = self.COLORS[int(event.key)] - self.bell() - - -app = ExampleApp() -app.run() From c4f920be67a47576d43027444d14b4bf6237a647 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Wed, 19 Oct 2022 15:15:53 +0100 Subject: [PATCH 10/14] Remove the bell from the Button documentation example --- docs/examples/widgets/button.py | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/examples/widgets/button.py b/docs/examples/widgets/button.py index b7958e18b..4c3509c32 100644 --- a/docs/examples/widgets/button.py +++ b/docs/examples/widgets/button.py @@ -27,7 +27,6 @@ class ButtonsApp(App[str]): ) def on_button_pressed(self, event: Button.Pressed) -> None: - self.app.bell() self.exit(str(event.button)) From 6f93568f7734a33e7795fa941e974efb78cb45bb Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Wed, 19 Oct 2022 15:19:41 +0100 Subject: [PATCH 11/14] Remove the bell from the borders Textual CLI command --- src/textual/cli/previews/borders.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/textual/cli/previews/borders.py b/src/textual/cli/previews/borders.py index 613343443..55b3cedf6 100644 --- a/src/textual/cli/previews/borders.py +++ b/src/textual/cli/previews/borders.py @@ -56,7 +56,6 @@ class BorderApp(App): event.button.id, self.stylesheet._variables["secondary"], ) - self.bell() app = BorderApp() From f648457c1e1f673c5749196572644f5c81d710e2 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Wed, 19 Oct 2022 15:21:22 +0100 Subject: [PATCH 12/14] action03 doesn't ring the bell on button press any more --- docs/guide/actions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/actions.md b/docs/guide/actions.md index a443bd589..80644b206 100644 --- a/docs/guide/actions.md +++ b/docs/guide/actions.md @@ -71,7 +71,7 @@ The following example mounts simple static text with embedded action links. ```{.textual path="docs/examples/guide/actions/actions03.py"} ``` -When you click any of the links, Textual runs the `"set_background"` action to change the background to the given color and plays the terminal's bell. +When you click any of the links, Textual runs the `"set_background"` action to change the background to the given color. ## Bindings From 836a4e52913b0c9258ba6957d8c1b20b4246d5bd Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Wed, 19 Oct 2022 15:24:44 +0100 Subject: [PATCH 13/14] Correct the file included for the second key example Not an issue with removing the bell, actually a pre-existing mistake in the docs. The wrong file was being included. --- docs/guide/input.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/input.md b/docs/guide/input.md index f03f4e756..968e19c7e 100644 --- a/docs/guide/input.md +++ b/docs/guide/input.md @@ -46,7 +46,7 @@ Textual offers a convenient way of handling specific keys. If you create a metho Let's add a key method to the example code. ```python title="key02.py" hl_lines="15-16" ---8<-- "docs/examples/guide/input/key01.py" +--8<-- "docs/examples/guide/input/key02.py" ``` Note the addition of a `key_space` method which is called in response to the space key, and plays the terminal bell noise. From d22353d2ec8e6bacc1acc87e163a071dc3622d8a Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Wed, 19 Oct 2022 15:28:15 +0100 Subject: [PATCH 14/14] Correct the description of what the button example does Originally it was partially correct in that it did sound the bell, but it also then exited the application and printed the details of the button -- the text didn't mention the latter aspect. This corrects that and removes mention of the bell sound because we've now removed that. --- docs/widgets/button.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/widgets/button.md b/docs/widgets/button.md index 1387ffdf2..f8aad75de 100644 --- a/docs/widgets/button.md +++ b/docs/widgets/button.md @@ -10,7 +10,7 @@ when it has focus. ## Example The example below shows each button variant, and its disabled equivalent. -Clicking any of the non-disabled buttons in the example app below will result in a ring of the terminal bell. +Clicking any of the non-disabled buttons in the example app below will result the app exiting and the details of the selected button being printed to the console. === "Output"