implement inline styles

This commit is contained in:
Will McGugan
2022-02-02 15:44:43 +00:00
parent 19b835b8a1
commit c90cdd4ec8
22 changed files with 392 additions and 115 deletions

33
sandbox/local_styles.py Normal file
View File

@@ -0,0 +1,33 @@
from textual.app import App
from textual.widgets import Placeholder
from textual.widget import Widget
from textual import events
class BasicApp(App):
"""Sandbox application used for testing/development by Textual developers"""
def on_mount(self):
"""Build layout here."""
self.mount(
header=Widget(),
content=Placeholder(),
footer=Widget(),
sidebar=Widget(),
)
async def on_key(self, event: events.Key) -> None:
await self.dispatch_key(event)
def key_a(self) -> bool | None:
self.query("#footer").set_styles(text="on magenta").refresh()
self.log(self["#footer"].styles.css)
self.bell()
self.refresh()
def key_b(self) -> bool | None:
self["#content"].set_styles("text: on magenta")
BasicApp.run(css_file="local_styles.css", log="textual.log")