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,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")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user