textual/docs/examples/styles/tint.py
Dave Pearson 414096233b
Make all styles reference examples capable of being run standalone
Also move the declarations of the stylesheets into the app classes.

See #3650
2023-11-08 14:37:01 +00:00

19 lines
471 B
Python

from textual.app import App
from textual.color import Color
from textual.widgets import Label
class TintApp(App):
CSS_PATH = "tint.tcss"
def compose(self):
color = Color.parse("green")
for tint_alpha in range(0, 101, 10):
widget = Label(f"tint: green {tint_alpha}%;")
widget.styles.tint = color.with_alpha(tint_alpha / 100) # (1)!
yield widget
if __name__ == "__main__":
app = TintApp()
app.run()