Skip to content

Commit 2be8bf9

Browse files
committed
reactive stuff
1 parent b8bcdd3 commit 2be8bf9

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/textual/scrollbar.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
log = logging.getLogger("rich")
1414

15+
from . import events
1516
from .widget import Reactive, Widget
1617

1718

src/textual/widget.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ def __set__(self, obj: "Widget", value: ReactiveType) -> None:
9696
if callable(update_function):
9797
update_function(current_value, value)
9898

99-
obj.post_message_no_wait(events.Repaint(obj))
99+
obj.require_repaint()
100+
# obj.post_message_no_wait(events.Null(obj))
100101

101102

102103
@rich.repr.auto
@@ -145,6 +146,7 @@ def require_repaint(self) -> None:
145146
Actual repaint is done by parent on idle.
146147
"""
147148
self._repaint_required = True
149+
self.post_message_no_wait(events.Null(self))
148150

149151
def check_repaint(self) -> bool:
150152
return True
@@ -214,9 +216,6 @@ async def on_idle(self, event: events.Idle) -> None:
214216
log.debug("REPAINTING")
215217
await self.repaint()
216218

217-
async def on_repaint(self, event: events.Repaint) -> None:
218-
self.require_repaint()
219-
220219

221220
class Widget(WidgetBase):
222221
def __init__(self, name: str | None = None) -> None:

src/textual/widgets/placeholder.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@
33
from rich.console import Console, ConsoleOptions, RenderableType
44
from rich.panel import Panel
55
from rich.pretty import Pretty
6-
import rich.repr
6+
from rich.repr import RichReprResult
77

88
from .. import events
99
from ..widget import Reactive, Widget
1010

1111

12-
@rich.repr.auto
1312
class Placeholder(Widget, can_focus=True):
1413

1514
has_focus: Reactive[bool] = Reactive(False)
1615
mouse_over: Reactive[bool] = Reactive(False)
1716

18-
def __rich_repr__(self) -> rich.repr.RichReprResult:
17+
def __rich_repr__(self) -> RichReprResult:
1918
yield "name", self.name
2019
yield "has_focus", self.has_focus
2120
yield "mouse_over", self.mouse_over

0 commit comments

Comments
 (0)