forked from Textualize/textual
-
Notifications
You must be signed in to change notification settings - Fork 0
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 Textualize#90 from willmcgugan/layout-plus
Layout plus
- Loading branch information
Showing
30 changed files
with
353 additions
and
123 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[run] | ||
omit = | ||
|
||
[report] | ||
exclude_lines = | ||
pragma: no cover | ||
if TYPE_CHECKING: | ||
if __name__ == "__main__": | ||
@overload |
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,22 @@ | ||
name: issues | ||
on: | ||
issues: | ||
types: [closed] | ||
jobs: | ||
add-comment: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
issues: write | ||
steps: | ||
- name: Did I solve your problem? | ||
uses: peter-evans/create-or-update-comment@a35cf36e5301d70b76f316e867e7788a55a31dae | ||
with: | ||
issue-number: ${{ github.event.issue.number }} | ||
body: | | ||
Did I solve your problem? | ||
Consider [sponsoring my work](https://github.com/sponsors/willmcgugan) on Textual with a monthly donation. | ||
Or buy me a [coffee](https://ko-fi.com/willmcgugan) to say thanks. | ||
– [Will McGugan](https://twitter.com/willmcgugan) |
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,33 @@ | ||
from rich.table import Table | ||
|
||
from textual import events | ||
from textual.app import App | ||
from textual.widgets import ScrollView | ||
|
||
|
||
class MyApp(App): | ||
"""An example of a very simple Textual App""" | ||
|
||
async def on_load(self, event: events.Load) -> None: | ||
await self.bind("q", "quit", "Quit") | ||
|
||
async def on_mount(self, event: events.Mount) -> None: | ||
|
||
self.body = body = ScrollView(auto_width=True) | ||
|
||
await self.view.dock(body) | ||
|
||
async def add_content(): | ||
table = Table(title="Demo") | ||
|
||
for i in range(40): | ||
table.add_column(f"Col {i + 1}", style="magenta") | ||
for i in range(200): | ||
table.add_row(*[f"cell {i},{j}" for j in range(40)]) | ||
|
||
await body.update(table) | ||
|
||
await self.call_later(add_content) | ||
|
||
|
||
MyApp.run(title="Simple App", log="textual.log") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Developer notes | ||
|
||
These are notes made by the developer, and _not_ to be considered documentation. |
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,5 @@ | ||
# Layout | ||
|
||
## rich.layout.Layout | ||
|
||
The Layout class is responsible for arranging widget within a defined area. There are several concrete Layout objects with different strategies for positioning widgets. |
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,11 @@ | ||
# Refresh system | ||
|
||
This note describes how Textual updates widgets on-screen. | ||
|
||
if widget has made some changes and wishes to update visuals it can call Widget.refresh. There are two flags on this method; `repaint` which will repaint just the widget, and `layout` which will re-layout the screen. A layout must be done if the widget has changed size / position / visibility. Otherwise repaint will refresh just the widget area. | ||
|
||
A refresh won't happen immediately when `refresh()` is called, rather it sets internal flags. The `on_idle` method of Widget checks these flags. This is so that multiple changes made to the UI while processing events don't cause excessive repainting of the screen (which makes the UI slow and jumpy). | ||
|
||
In the case of a repaint. The Widget.on_idle handler will emit (send to the parent) an UpdateMessage. This message will be handled by the parent view, which will update the widget (a particular part of the screen). | ||
|
||
In the case of a layout. The Widget.on_idle handler will emit a LayoutMessage. This message will be handled by the parent view, which calls refresh_layout on the root view, which will layout and repaint the entire screen. |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "textual" | ||
version = "0.1.10" | ||
version = "0.1.11" | ||
homepage = "https://github.com/willmcgugan/textual" | ||
description = "Text User Interface using Rich" | ||
authors = ["Will McGugan <[email protected]>"] | ||
|
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.