mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Pass Rich Style object into Textual render method
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
from datetime import datetime
|
||||
|
||||
from rich.align import Align
|
||||
from rich.style import Style
|
||||
|
||||
from textual.app import App
|
||||
from textual.css.styles import Styles
|
||||
from textual.widget import Widget
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ class Clock(Widget):
|
||||
def on_mount(self):
|
||||
self.set_interval(1, self.refresh)
|
||||
|
||||
def render(self, styles: Styles):
|
||||
def render(self, style: Style):
|
||||
time = datetime.now().strftime("%c")
|
||||
return Align.center(time, vertical="middle")
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from rich.panel import Panel
|
||||
from rich.style import Style
|
||||
|
||||
from textual.app import App
|
||||
from textual.css.styles import Styles
|
||||
from textual.reactive import Reactive
|
||||
from textual.widget import Widget
|
||||
|
||||
@@ -10,7 +10,7 @@ class Hover(Widget):
|
||||
|
||||
mouse_over = Reactive(False)
|
||||
|
||||
def render(self, styles: Styles) -> Panel:
|
||||
def render(self, style: Style) -> Panel:
|
||||
return Panel("Hello [b]World[/b]", style=("on red" if self.mouse_over else ""))
|
||||
|
||||
def on_enter(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user