mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
dimensions
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
27
docs/examples/guide/styles/dimensions01.py
Normal file
27
docs/examples/guide/styles/dimensions01.py
Normal 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()
|
||||
27
docs/examples/guide/styles/dimensions02.py
Normal file
27
docs/examples/guide/styles/dimensions02.py
Normal 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()
|
||||
Reference in New Issue
Block a user