mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Add style param to Widget render method
This commit is contained in:
@@ -6,7 +6,7 @@ from textual.widgets import Static
|
||||
|
||||
|
||||
class Thing(Widget):
|
||||
def render(self):
|
||||
def render(self, styles: Styles):
|
||||
return "Hello, 3434 World.\n[b]Lorem impsum."
|
||||
|
||||
|
||||
|
||||
@@ -50,12 +50,12 @@ lorem = Text.from_markup(
|
||||
|
||||
|
||||
class TweetHeader(Widget):
|
||||
def render(self) -> RenderableType:
|
||||
def render(self, styles: Styles) -> RenderableType:
|
||||
return Text("Lorem Impsum", justify="center")
|
||||
|
||||
|
||||
class TweetBody(Widget):
|
||||
def render(self) -> Text:
|
||||
def render(self, styles: Styles) -> Text:
|
||||
return lorem
|
||||
|
||||
|
||||
@@ -64,22 +64,22 @@ class Tweet(Widget):
|
||||
|
||||
|
||||
class OptionItem(Widget):
|
||||
def render(self) -> Text:
|
||||
def render(self, styles: Styles) -> Text:
|
||||
return Text("Option")
|
||||
|
||||
|
||||
class Error(Widget):
|
||||
def render(self) -> Text:
|
||||
def render(self, styles: Styles) -> Text:
|
||||
return Text("This is an error message", justify="center")
|
||||
|
||||
|
||||
class Warning(Widget):
|
||||
def render(self) -> Text:
|
||||
def render(self, styles: Styles) -> Text:
|
||||
return Text("This is a warning message", justify="center")
|
||||
|
||||
|
||||
class Success(Widget):
|
||||
def render(self) -> Text:
|
||||
def render(self, styles: Styles) -> Text:
|
||||
return Text("This is a success message", justify="center")
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from textual.widget import Widget
|
||||
|
||||
|
||||
class PanelWidget(Widget):
|
||||
def render(self) -> RenderableType:
|
||||
def render(self, styles: Styles) -> RenderableType:
|
||||
return Panel("hello world!", title="Title")
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ from textual.widgets.tabs import Tabs, Tab
|
||||
|
||||
|
||||
class Hr(Widget):
|
||||
def render(self) -> RenderableType:
|
||||
def render(self, styles: Styles) -> RenderableType:
|
||||
return Rule()
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class Info(Widget):
|
||||
super().__init__()
|
||||
self.text = text
|
||||
|
||||
def render(self) -> RenderableType:
|
||||
def render(self, styles: Styles) -> RenderableType:
|
||||
return Padding(f"{self.text}", pad=(0, 1))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user