dimensions

This commit is contained in:
Will McGugan
2022-09-14 13:19:45 +01:00
parent 8020101c73
commit e85f9dc045
5 changed files with 119 additions and 19 deletions

View File

@@ -3,8 +3,8 @@
#dialog {
margin: 4 8;
background: $primary;
color: $text-primary;
border: tall $text-primary;
color: $text;
border: tall $background;
padding: 1 2;
}

View File

@@ -5,12 +5,14 @@ from textual.widgets import Static
class ColorApp(App):
def compose(self) -> ComposeResult:
self.widgets = [Static(f"Textual {n+1}") for n in range(10)]
self.widgets = [Static("") 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)
alpha = index * 0.1
widget.update(f"alpha={alpha:.1f}")
widget.styles.background = Color(191, 78, 96, a=alpha)
app = ColorApp()

View File

@@ -0,0 +1,27 @@
from textual.app import App, ComposeResult
from textual.widgets import Static
TEXT = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
I will face my fear.
I will permit it to pass over me and through me.
And when it has gone past, I will turn the inner eye to see its path.
Where the fear has gone there will be nothing. Only I will remain."""
class DimensionsApp(App):
def compose(self) -> ComposeResult:
self.widget = Static(TEXT)
yield self.widget
def on_mount(self) -> None:
self.widget.styles.background = "purple"
self.widget.styles.width = 30
self.widget.styles.height = 10
app = DimensionsApp()
if __name__ == "__main__":
app.run()

View File

@@ -0,0 +1,27 @@
from textual.app import App, ComposeResult
from textual.widgets import Static
TEXT = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
I will face my fear.
I will permit it to pass over me and through me.
And when it has gone past, I will turn the inner eye to see its path.
Where the fear has gone there will be nothing. Only I will remain."""
class DimensionsApp(App):
def compose(self) -> ComposeResult:
self.widget = Static(TEXT)
yield self.widget
def on_mount(self) -> None:
self.widget.styles.background = "purple"
self.widget.styles.width = 30
self.widget.styles.height = "auto"
app = DimensionsApp()
if __name__ == "__main__":
app.run()