mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Added compose event, more color docs
This commit is contained in:
17
docs/examples/guide/styles/colors.py
Normal file
17
docs/examples/guide/styles/colors.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.widgets import Static
|
||||
|
||||
|
||||
class WidgetApp(App):
|
||||
def compose(self) -> ComposeResult:
|
||||
self.widget = Static("Textual")
|
||||
yield self.widget
|
||||
|
||||
def on_mount(self) -> None:
|
||||
self.widget.styles.background = "darkblue"
|
||||
self.widget.styles.border = ("heavy", "white")
|
||||
|
||||
|
||||
app = WidgetApp()
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
24
docs/examples/guide/styles/colors01.py
Normal file
24
docs/examples/guide/styles/colors01.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.color import Color
|
||||
from textual.widgets import Static
|
||||
|
||||
|
||||
class ColorApp(App):
|
||||
def compose(self) -> ComposeResult:
|
||||
self.widget1 = Static("Textual One")
|
||||
yield self.widget1
|
||||
self.widget2 = Static("Textual Two")
|
||||
yield self.widget2
|
||||
self.widget3 = Static("Textual Three")
|
||||
yield self.widget3
|
||||
|
||||
def on_mount(self) -> None:
|
||||
self.widget1.styles.background = "#9932CC"
|
||||
self.widget2.styles.background = "hsl(150,42.9%,49.4%)"
|
||||
self.widget2.styles.color = "blue"
|
||||
self.widget3.styles.background = Color(191, 78, 96)
|
||||
|
||||
|
||||
app = ColorApp()
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
18
docs/examples/guide/styles/colors02.py
Normal file
18
docs/examples/guide/styles/colors02.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.color import Color
|
||||
from textual.widgets import Static
|
||||
|
||||
|
||||
class ColorApp(App):
|
||||
def compose(self) -> ComposeResult:
|
||||
self.widgets = [Static(f"Textual {n+1}") for n in range(10)]
|
||||
yield from self.widgets
|
||||
|
||||
def on_mount(self) -> None:
|
||||
for index, widget in enumerate(self.widgets, 1):
|
||||
widget.styles.background = Color(191, 78, 96, index * 0.1)
|
||||
|
||||
|
||||
app = ColorApp()
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
17
docs/examples/guide/styles/widget.py
Normal file
17
docs/examples/guide/styles/widget.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.widgets import Static
|
||||
|
||||
|
||||
class WidgetApp(App):
|
||||
def compose(self) -> ComposeResult:
|
||||
self.widget = Static("Textual")
|
||||
yield self.widget
|
||||
|
||||
def on_mount(self) -> None:
|
||||
self.widget.styles.background = "darkblue"
|
||||
self.widget.styles.border = ("heavy", "white")
|
||||
|
||||
|
||||
app = WidgetApp()
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
Reference in New Issue
Block a user