mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
end of file
This commit is contained in:
22
.github/workflows/comment.yml
vendored
Normal file
22
.github/workflows/comment.yml
vendored
Normal file
@@ -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)
|
||||||
36
examples/big_table.py
Normal file
36
examples/big_table.py
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
from rich.table import Table
|
||||||
|
from rich.measure import Measurement
|
||||||
|
|
||||||
|
from textual import events
|
||||||
|
from textual.app import App
|
||||||
|
from textual.widgets import Header, Footer, 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()
|
||||||
|
#body.virtual_size.width = 300
|
||||||
|
|
||||||
|
await self.view.dock(body)
|
||||||
|
|
||||||
|
async def add_content():
|
||||||
|
table = Table(title="Demo", width=1000)
|
||||||
|
|
||||||
|
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")
|
||||||
@@ -74,7 +74,7 @@ class Size(NamedTuple):
|
|||||||
height: int
|
height: int
|
||||||
|
|
||||||
def __bool__(self) -> bool:
|
def __bool__(self) -> bool:
|
||||||
"""A Size is Falsey if it has area 0"""
|
"""A Size is Falsey if it has area 0."""
|
||||||
return self.width * self.height != 0
|
return self.width * self.height != 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ class VerticalLayout(Layout):
|
|||||||
gutter_height, gutter_width = self.gutter
|
gutter_height, gutter_width = self.gutter
|
||||||
render_width = width - gutter_width * 2
|
render_width = width - gutter_width * 2
|
||||||
|
|
||||||
render_width = 1000 + gutter_width * 2
|
|
||||||
|
|
||||||
x = gutter_width
|
x = gutter_width
|
||||||
y = gutter_height
|
y = gutter_height
|
||||||
map: LayoutMap = LayoutMap(size)
|
map: LayoutMap = LayoutMap(size)
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ from rich.style import Style
|
|||||||
|
|
||||||
from . import events
|
from . import events
|
||||||
from . import log
|
from . import log
|
||||||
|
from . import messages
|
||||||
from .layout import Layout, NoWidget
|
from .layout import Layout, NoWidget
|
||||||
from .geometry import Size, Offset, Region
|
from .geometry import Size, Offset, Region
|
||||||
from .messages import Update, Layout
|
|
||||||
from .reactive import Reactive, watch
|
from .reactive import Reactive, watch
|
||||||
|
|
||||||
from .widget import Widget, Widget
|
from .widget import Widget, Widget
|
||||||
@@ -86,10 +86,7 @@ class View(Widget):
|
|||||||
def get_offset(self, widget: Widget) -> Offset:
|
def get_offset(self, widget: Widget) -> Offset:
|
||||||
return self.layout.get_offset(widget)
|
return self.layout.get_offset(widget)
|
||||||
|
|
||||||
# def check_layout(self) -> bool:
|
async def handle_update(self, message: messages.Update) -> None:
|
||||||
# return super().check_layout() or self.layout.check_update()
|
|
||||||
|
|
||||||
async def handle_update(self, message: Update) -> None:
|
|
||||||
if self.is_root_view:
|
if self.is_root_view:
|
||||||
message.stop()
|
message.stop()
|
||||||
widget = message.widget
|
widget = message.widget
|
||||||
@@ -99,7 +96,7 @@ class View(Widget):
|
|||||||
if display_update is not None:
|
if display_update is not None:
|
||||||
self.app.display(display_update)
|
self.app.display(display_update)
|
||||||
|
|
||||||
async def handle_layout(self, message: Layout) -> None:
|
async def handle_layout(self, message: messages.Layout) -> None:
|
||||||
if self.is_root_view:
|
if self.is_root_view:
|
||||||
message.stop()
|
message.stop()
|
||||||
await self.refresh_layout()
|
await self.refresh_layout()
|
||||||
@@ -245,4 +242,4 @@ class View(Widget):
|
|||||||
async def action_toggle(self, name: str) -> None:
|
async def action_toggle(self, name: str) -> None:
|
||||||
widget = self.named_widgets[name]
|
widget = self.named_widgets[name]
|
||||||
widget.visible = not widget.visible
|
widget.visible = not widget.visible
|
||||||
await self.post_message(Layout(self))
|
await self.post_message(messages.Layout(self))
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ def test_clamp():
|
|||||||
assert clamp(11, 0, 10) == 10
|
assert clamp(11, 0, 10) == 10
|
||||||
assert clamp(0, 0, 10) == 0
|
assert clamp(0, 0, 10) == 0
|
||||||
assert clamp(10, 0, 10) == 10
|
assert clamp(10, 0, 10) == 10
|
||||||
|
assert clamp(5, 10, 0) == 5
|
||||||
|
|
||||||
|
|
||||||
def test_point_is_origin():
|
def test_point_is_origin():
|
||||||
@@ -185,3 +186,35 @@ def test_region_intersection():
|
|||||||
|
|
||||||
def test_region_union():
|
def test_region_union():
|
||||||
assert Region(5, 5, 10, 10).union(Region(20, 30, 10, 5)) == Region(5, 5, 25, 30)
|
assert Region(5, 5, 10, 10).union(Region(20, 30, 10, 5)) == Region(5, 5, 25, 30)
|
||||||
|
|
||||||
|
|
||||||
|
def test_size_add():
|
||||||
|
assert Size(5, 10) + Size(2, 3) == Size(7, 13)
|
||||||
|
|
||||||
|
|
||||||
|
def test_size_sub():
|
||||||
|
assert Size(5, 10) - Size(2, 3) == Size(3, 7)
|
||||||
|
|
||||||
|
|
||||||
|
def test_region_x_extents():
|
||||||
|
assert Region(5, 10, 20, 30).x_extents == (5, 25)
|
||||||
|
|
||||||
|
|
||||||
|
def test_region_y_extents():
|
||||||
|
assert Region(5, 10, 20, 30).y_extents == (10, 40)
|
||||||
|
|
||||||
|
|
||||||
|
def test_region_x_max():
|
||||||
|
assert Region(5, 10, 20, 30).x_max == 25
|
||||||
|
|
||||||
|
|
||||||
|
def test_region_y_max():
|
||||||
|
assert Region(5, 10, 20, 30).y_max == 40
|
||||||
|
|
||||||
|
|
||||||
|
def test_region_x_range():
|
||||||
|
assert Region(5, 10, 20, 30).x_range == range(5, 25)
|
||||||
|
|
||||||
|
|
||||||
|
def test_region_y_range():
|
||||||
|
assert Region(5, 10, 20, 30).y_range == range(10, 40)
|
||||||
|
|||||||
Reference in New Issue
Block a user