Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions python-textual/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ class EventsApp(App):
double_border = False

def compose(self):
yield Button(
"Click me!",
id="button",
)
yield Button("Click me!", id="button")
digits = Digits("0", id="digits")
digits.border_subtitle = "Button presses"
yield digits
Expand Down
4 changes: 2 additions & 2 deletions python-textual/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from textual.widgets import Static


class GridLayoutExample(App):
class GridLayoutApp(App):
def compose(self):
grid = Grid()
grid.styles.grid_size_rows = rows = 6
Expand All @@ -19,5 +19,5 @@ def compose(self):


if __name__ == "__main__":
app = GridLayoutExample()
app = GridLayoutApp()
app.run()
2 changes: 1 addition & 1 deletion python-textual/grid.tcss
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ Grid {
Static {
height: 1fr;
width: 1fr;
border: solid green;
border: solid green;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from textual.widgets import Static


class GridLayoutWithTCSS(App):
class GridLayoutAppWithTCSS(App):
CSS_PATH = "grid.tcss"

def compose(self):
Expand All @@ -14,5 +14,5 @@ def compose(self):


if __name__ == "__main__":
app = GridLayoutWithTCSS()
app = GridLayoutAppWithTCSS()
app.run()
6 changes: 3 additions & 3 deletions python-textual/horizontal_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
NUM_BOXES = 4


class HorizontalLayoutExample(App):
class HorizontalLayoutApp(App):
def compose(self):
with Horizontal():
for i in range(NUM_BOXES):
static = Static(f"Static {i+1}")
static = Static(f"Static {i + 1}")
static.styles.border = ("solid", "green")
static.styles.width = "10%"
yield static


if __name__ == "__main__":
app = HorizontalLayoutExample()
app = HorizontalLayoutApp()
app.run()
6 changes: 3 additions & 3 deletions python-textual/horizontal_scroll.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
NUM_BOXES = 20


class HorizontalScrollExample(App):
class HorizontalScrollApp(App):
def compose(self):
with HorizontalScroll():
for i in range(NUM_BOXES):
static = Static(f"Static {i+1}")
static = Static(f"Static {i + 1}")
static.styles.border = ("solid", "green")
static.styles.width = "10%"
yield static


if __name__ == "__main__":
app = HorizontalScrollExample()
app = HorizontalScrollApp()
app.run()
14 changes: 5 additions & 9 deletions python-textual/layouts.py.py → python-textual/layouts.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
from textual.app import App
from textual.containers import (
Horizontal,
HorizontalScroll,
VerticalScroll,
)
from textual.containers import Horizontal, HorizontalScroll, VerticalScroll
from textual.widgets import Label, Static

NUM_BOXES = 12


class NestedContainersExample(App):
class NestedContainersApp(App):
CSS_PATH = "layouts.tcss"

def compose(self):
Expand All @@ -18,13 +14,13 @@ def compose(self):
with HorizontalScroll(id="horizontalscroll"):
for i in range(NUM_BOXES):
yield Static(
f"Center.{i+1}",
f"Center.{i + 1}",
classes="box yellowbox",
)
with VerticalScroll(id="verticalscroll"):
for i in range(NUM_BOXES):
yield Static(
f"Right.{i+1}",
f"Right.{i + 1}",
classes="box redbox",
)
yield Label(
Expand All @@ -34,5 +30,5 @@ def compose(self):


if __name__ == "__main__":
app = NestedContainersExample()
app = NestedContainersApp()
app.run()
2 changes: 1 addition & 1 deletion python-textual/layouts.tcss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.box {
height: 1fr;
width: 1fr;
background:$panel;
background: $panel;
border: solid white;
}

Expand Down
8 changes: 4 additions & 4 deletions python-textual/static_and_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ def on_mount(self):
self.static.styles.background = "blue"
self.static.styles.border = ("solid", "white")
self.static.styles.text_align = "center"
self.static.styles.padding = 1, 1
self.static.styles.margin = 4, 4
self.static.styles.padding = (1, 1)
self.static.styles.margin = (4, 4)
# Styling the label
self.label.styles.background = "darkgreen"
self.label.styles.border = ("double", "red")
self.label.styles.padding = 1, 1
self.label.styles.margin = 2, 4
self.label.styles.padding = (1, 1)
self.label.styles.margin = (2, 4)


if __name__ == "__main__":
Expand Down
12 changes: 6 additions & 6 deletions python-textual/static_and_label.tcss
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
Static {
background: blue;
border: solid white;
border: solid white;
padding: 1 1;
margin: 2 2;
text-align: center;
}

#label_id {
color: black;
background: yellow;
border: solid black;
background: red;
border: solid black;
padding: 1 1;
margin: 2 4;
}

.label_class {
color:black;
color: black;
background: green;
border: dashed purple;
border: dashed purple;
padding: 1 1;
margin: 2 6;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
NUM_BOXES = 4


class VerticalLayoutExample(App):
class VerticalLayoutApp(App):
def compose(self):
with Vertical():
for i in range(NUM_BOXES):
static = Static(f"Static {i+1}")
static = Static(f"Static {i + 1}")
static.styles.border = ("solid", "green")
yield static

# for i in range(1, NUM_BOXES):
# static = Static(f"Static {i}")
# for i in range(NUM_BOXES):
# static = Static(f"Static {i + 1}")
# static.styles.border = ("solid", "green")
# yield static


if __name__ == "__main__":
app = VerticalLayoutExample()
app = VerticalLayoutApp()
app.run()
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
NUM_BOXES = 4


class VerticalLayoutExampleWithTCSS(App):
class VerticalLayoutAppWithTCSS(App):
CSS_PATH = "vertical_layout.tcss"

def compose(self):
Expand All @@ -15,5 +15,5 @@ def compose(self):


if __name__ == "__main__":
app = VerticalLayoutExampleWithTCSS()
app = VerticalLayoutAppWithTCSS()
app.run()
4 changes: 2 additions & 2 deletions python-textual/vertical_scroll.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
NUM_BOXES = 20


class VerticalScrollExample(App):
class VerticalScrollApp(App):
CSS_PATH = "vertical_layout.tcss"

def compose(self):
Expand All @@ -15,5 +15,5 @@ def compose(self):


if __name__ == "__main__":
app = VerticalScrollExample()
app = VerticalScrollApp()
app.run()