Merge pull request #958 from davep/toll-free

Review the use of the bell in various examples and documentation files
This commit is contained in:
Dave Pearson
2022-10-19 15:56:21 +01:00
committed by GitHub
14 changed files with 5 additions and 55 deletions

View File

@@ -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":

View File

@@ -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":

View File

@@ -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__":

View File

@@ -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__":

View File

@@ -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__":

View File

@@ -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()

View File

@@ -1,9 +0,0 @@
from textual.app import App
class ExampleApp(App):
pass
app = ExampleApp()
app.run()

View File

@@ -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()

View File

@@ -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))

View File

@@ -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"
```
@@ -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"
```
@@ -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

View File

@@ -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.

View File

@@ -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"

View File

@@ -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:

View File

@@ -56,7 +56,6 @@ class BorderApp(App):
event.button.id,
self.stylesheet._variables["secondary"],
)
self.bell()
app = BorderApp()