Pass Rich Style object into Textual render method

This commit is contained in:
Darren Burns
2022-05-06 10:20:05 +01:00
parent 6b1dab5387
commit 43f65d73ae
23 changed files with 74 additions and 86 deletions

View File

@@ -1,11 +1,11 @@
from pathlib import Path
from rich.console import RenderableType
from rich.style import Style
from rich.syntax import Syntax
from rich.text import Text
from textual.app import App
from textual.css.styles import Styles
from textual.widget import Widget
from textual.widgets import Static
@@ -53,12 +53,12 @@ lorem = Text.from_markup(
class TweetHeader(Widget):
def render(self, styles: Styles) -> RenderableType:
def render(self, style: Style) -> RenderableType:
return Text("Lorem Impsum", justify="center")
class TweetBody(Widget):
def render(self, styles: Styles) -> Text:
def render(self, style: Style) -> Text:
return lorem
@@ -67,22 +67,22 @@ class Tweet(Widget):
class OptionItem(Widget):
def render(self, styles: Styles) -> Text:
def render(self, style: Style) -> Text:
return Text("Option")
class Error(Widget):
def render(self, styles: Styles) -> Text:
def render(self, style: Style) -> Text:
return Text("This is an error message", justify="center")
class Warning(Widget):
def render(self, styles: Styles) -> Text:
def render(self, style: Style) -> Text:
return Text("This is a warning message", justify="center")
class Success(Widget):
def render(self, styles: Styles) -> Text:
def render(self, style: Style) -> Text:
return Text("This is a success message", justify="center")