This commit is contained in:
Will McGugan
2023-04-07 11:35:59 +01:00
parent c4774155ab
commit 94279ae1f9
3 changed files with 3 additions and 4 deletions

View File

@@ -5,7 +5,7 @@ from textual.widgets import Button, Welcome
class WelcomeApp(App): class WelcomeApp(App):
def on_key(self) -> None: def on_key(self) -> None:
self.mount(Welcome()) self.mount(Welcome())
self.query_one(Button).label = "YES" self.query_one(Button).label = "YES!"
if __name__ == "__main__": if __name__ == "__main__":

View File

@@ -5,7 +5,7 @@ from textual.widgets import Button, Welcome
class WelcomeApp(App): class WelcomeApp(App):
async def on_key(self) -> None: async def on_key(self) -> None:
await self.mount(Welcome()) await self.mount(Welcome())
self.query_one(Button).label = "YES" self.query_one(Button).label = "YES!"
if __name__ == "__main__": if __name__ == "__main__":

View File

@@ -125,7 +125,7 @@ This may be a problem if you want to make any changes to the widget in the same
Let's first illustrate the problem with an example. Let's first illustrate the problem with an example.
The following code will mount the Welcome widget in response to a key press. The following code will mount the Welcome widget in response to a key press.
It will also attempt to modify the Button in the Welcome widget by changing its label from "OK" to "YES". It will also attempt to modify the Button in the Welcome widget by changing its label from "OK" to "YES!".
```python hl_lines="2 8" ```python hl_lines="2 8"
from textual.app import App from textual.app import App
@@ -173,7 +173,6 @@ Here's the output. Note the changed button text:
```{.textual path="docs/examples/app/widgets04.py" press=["a"]} ```{.textual path="docs/examples/app/widgets04.py" press=["a"]}
``` ```
## Exiting ## Exiting
An app will run until you call [App.exit()][textual.app.App.exit] which will exit application mode and the [run][textual.app.App.run] method will return. If this is the last line in your code you will return to the command prompt. An app will run until you call [App.exit()][textual.app.App.exit] which will exit application mode and the [run][textual.app.App.run] method will return. If this is the last line in your code you will return to the command prompt.