Merge branch 'main' into proofread

This commit is contained in:
Will McGugan
2021-08-08 07:49:51 +01:00
committed by GitHub

View File

@@ -4,7 +4,7 @@
Textual is a TUI (Text User Interface) framework for Python inspired by modern web development. Currently a work in progress, but usable by brave souls who don't mind some API instability between updates.
Textual will be eventually be cross platform, but for now it is MacOS / Linux only. Windows support is in the pipeline.
Textual will eventually be cross platform, but for now it is MacOS / Linux only. Windows support is in the pipeline.
Follow [@willmcgugan](https://twitter.com/willmcgugan) for progress updates, or post in Discussions if you have any requests / suggestions.
@@ -24,7 +24,7 @@ poetry install
## Examples
Until I've written the documentation, the [examples](https://github.com/willmcgugan/textual/tree/main/examples/) may the best way to learn Textual.
Until I've written the documentation, the [examples](https://github.com/willmcgugan/textual/tree/main/examples/) may be the best way to learn Textual.
- [animation.py](https://github.com/willmcgugan/textual/tree/main/examples/animation.py) Demonstration of 60fps animation easing function
- [calculator.py](https://github.com/willmcgugan/textual/tree/main/examples/calculator.py) A "clone" of the MacOS calculator using Grid layout
@@ -51,11 +51,11 @@ class Beeper(App):
Beeper.run()
```
Here we can see a textual app with a single `on_key` method which will receive key events. Any key event will result in playing a beep noise. Hit ctrl+C to exit.
Here we can see a textual app with a single `on_key` method which will receive key events. Any key event will result in playing a beep noise. Hit Ctrl+C to exit.
Event handlers in Textual are defined by convention, not by inheritance (so you won't find an `on_key` method in the base class). Each event has a `name` attribute which for the key event is simply `"key"`. Textual will call the method named `on_<event.name>` if it exists.
Lets look at a _slightly_ more interesting example:
Let's look at a _slightly_ more interesting example:
```python
from textual.app import App
@@ -112,7 +112,7 @@ The following line is similar:
await self.view.dock(Placeholder(), Placeholder(), edge="top")
```
You will notice that this time we are docking _two_ Placeholder objects on _the_ top edge. We haven't set an explicit size this time so Textual will divide the remaining size amongst the two new widgets.
You will notice that this time we are docking _two_ Placeholder objects onto the `"top"` edge. We haven't set an explicit size this time so Textual will divide the remaining size amongst the two new widgets.
The last line calls the `run` class method in the usual way, but with an argument we haven't seen before: `log="textual.log"` tells Textual to write log information to the given file. You can tail textual.log to see the events being processed and other debug information.
@@ -128,7 +128,7 @@ The dock layout feature is good enough for most purposes. For more sophisticated
You can create your own widgets by subclassing the `textual.widget.Widget` class and implementing a `render()` method which should return anything that can be rendered with [Rich](https://rich.readthedocs.io/en/latest/introduction.html), including a plain string which will be interpreted as [console markup](https://rich.readthedocs.io/en/latest/markup.html).
Lets look at an example with a custom widget:
Let's look at an example with a custom widget:
```python
from rich.panel import Panel
@@ -321,6 +321,6 @@ Added a new layout system modelled on CSS grid. The example demonstrates how onc
**6 Aug 2021**
Added a tree control and refactored the renderer to allow for widgets within a scrollable veiew
Added a tree control and refactored the renderer to allow for widgets within a scrollable view
[![Textual update 8](https://yt-embed.herokuapp.com/embed?v=J-dzzD6NQJ4&img=0)](http://www.youtube.com/watch?v=J-dzzD6NQJ4)