mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
@@ -1,9 +1,9 @@
|
|||||||
from textual.app import App, ComposeResult
|
from textual.app import App, ComposeResult
|
||||||
from textual.widgets import Label, Button
|
from textual.widgets import Button, Label
|
||||||
|
|
||||||
|
|
||||||
class QuestionApp(App[str]):
|
class QuestionApp(App[str]):
|
||||||
CSS_PATH = "question02.css"
|
CSS_PATH = "question02.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Label("Do you love Textual?", id="question")
|
yield Label("Do you love Textual?", id="question")
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
Screen {
|
Screen {
|
||||||
layout: grid;
|
layout: grid;
|
||||||
grid-size: 2;
|
grid-size: 2;
|
||||||
grid-gutter: 2;
|
grid-gutter: 2;
|
||||||
padding: 2;
|
padding: 2;
|
||||||
}
|
}
|
||||||
#question {
|
#question {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -10,7 +10,7 @@ Screen {
|
|||||||
column-span: 2;
|
column-span: 2;
|
||||||
content-align: center bottom;
|
content-align: center bottom;
|
||||||
text-style: bold;
|
text-style: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -3,7 +3,7 @@ from textual.widgets import Button, Header, Label
|
|||||||
|
|
||||||
|
|
||||||
class MyApp(App[str]):
|
class MyApp(App[str]):
|
||||||
CSS_PATH = "question02.css"
|
CSS_PATH = "question02.tcss"
|
||||||
TITLE = "A Question App"
|
TITLE = "A Question App"
|
||||||
SUB_TITLE = "The most important question"
|
SUB_TITLE = "The most important question"
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from textual.widgets import Button, Header, Label
|
|||||||
|
|
||||||
|
|
||||||
class MyApp(App[str]):
|
class MyApp(App[str]):
|
||||||
CSS_PATH = "question02.css"
|
CSS_PATH = "question02.tcss"
|
||||||
TITLE = "A Question App"
|
TITLE = "A Question App"
|
||||||
SUB_TITLE = "The most important question"
|
SUB_TITLE = "The most important question"
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ from textual.widgets import Input, Static
|
|||||||
class DictionaryApp(App):
|
class DictionaryApp(App):
|
||||||
"""Searches a dictionary API as-you-type."""
|
"""Searches a dictionary API as-you-type."""
|
||||||
|
|
||||||
CSS_PATH = "dictionary.css"
|
CSS_PATH = "dictionary.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Input(placeholder="Search for a word")
|
yield Input(placeholder="Search for a word")
|
||||||
|
|||||||
@@ -3,21 +3,21 @@ Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Input {
|
Input {
|
||||||
dock: top;
|
dock: top;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 1;
|
height: 1;
|
||||||
padding: 0 1;
|
padding: 0 1;
|
||||||
margin: 1 1 0 1;
|
margin: 1 1 0 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#results {
|
#results {
|
||||||
width: auto;
|
width: auto;
|
||||||
min-height: 100%;
|
min-height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#results-container {
|
#results-container {
|
||||||
background: $background 50%;
|
background: $background 50%;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
margin: 1 2;
|
margin: 1 2;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ from textual.widgets import Button
|
|||||||
|
|
||||||
|
|
||||||
class OnDecoratorApp(App):
|
class OnDecoratorApp(App):
|
||||||
CSS_PATH = "on_decorator.css"
|
CSS_PATH = "on_decorator.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
"""Three buttons."""
|
"""Three buttons."""
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from textual.widgets import Button
|
|||||||
|
|
||||||
|
|
||||||
class OnDecoratorApp(App):
|
class OnDecoratorApp(App):
|
||||||
CSS_PATH = "on_decorator.css"
|
CSS_PATH = "on_decorator.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
"""Three buttons."""
|
"""Three buttons."""
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class ColorSwitcher(Static):
|
|||||||
|
|
||||||
|
|
||||||
class ActionsApp(App):
|
class ActionsApp(App):
|
||||||
CSS_PATH = "actions05.css"
|
CSS_PATH = "actions05.tcss"
|
||||||
BINDINGS = [
|
BINDINGS = [
|
||||||
("r", "set_background('red')", "Red"),
|
("r", "set_background('red')", "Red"),
|
||||||
("g", "set_background('green')", "Green"),
|
("g", "set_background('green')", "Green"),
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
from textual.app import App, ComposeResult
|
from textual.app import App, ComposeResult
|
||||||
from textual.containers import Container, Horizontal
|
from textual.containers import Container, Horizontal
|
||||||
from textual.widgets import Header, Footer, Static, Button
|
from textual.widgets import Button, Footer, Header, Static
|
||||||
|
|
||||||
QUESTION = "Do you want to learn about Textual CSS?"
|
QUESTION = "Do you want to learn about Textual CSS?"
|
||||||
|
|
||||||
|
|
||||||
class ExampleApp(App):
|
class ExampleApp(App):
|
||||||
CSS_PATH = "dom4.css"
|
CSS_PATH = "dom4.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Header()
|
yield Header()
|
||||||
|
|||||||
@@ -27,5 +27,3 @@ Button {
|
|||||||
height: auto;
|
height: auto;
|
||||||
dock: bottom;
|
dock: bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@ class Bar(Static):
|
|||||||
|
|
||||||
|
|
||||||
class BindingApp(App):
|
class BindingApp(App):
|
||||||
CSS_PATH = "binding01.css"
|
CSS_PATH = "binding01.tcss"
|
||||||
BINDINGS = [
|
BINDINGS = [
|
||||||
("r", "add_bar('red')", "Add Red"),
|
("r", "add_bar('red')", "Add Red"),
|
||||||
("g", "add_bar('green')", "Add Green"),
|
("g", "add_bar('green')", "Add Green"),
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
Bar {
|
Bar {
|
||||||
height: 5;
|
height: 5;
|
||||||
content-align: center middle;
|
content-align: center middle;
|
||||||
text-style: bold;
|
text-style: bold;
|
||||||
margin: 1 2;
|
margin: 1 2;
|
||||||
@@ -11,7 +11,7 @@ class KeyLogger(RichLog):
|
|||||||
class InputApp(App):
|
class InputApp(App):
|
||||||
"""App to display key events."""
|
"""App to display key events."""
|
||||||
|
|
||||||
CSS_PATH = "key03.css"
|
CSS_PATH = "key03.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield KeyLogger()
|
yield KeyLogger()
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Screen {
|
|||||||
grid-columns: 1fr;
|
grid-columns: 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyLogger {
|
KeyLogger {
|
||||||
border: blank;
|
border: blank;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ class Ball(Static):
|
|||||||
|
|
||||||
|
|
||||||
class MouseApp(App):
|
class MouseApp(App):
|
||||||
CSS_PATH = "mouse01.css"
|
CSS_PATH = "mouse01.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield RichLog()
|
yield RichLog()
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from textual.widgets import Header, Static
|
|||||||
|
|
||||||
|
|
||||||
class CombiningLayoutsExample(App):
|
class CombiningLayoutsExample(App):
|
||||||
CSS_PATH = "combining_layouts.css"
|
CSS_PATH = "combining_layouts.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Header()
|
yield Header()
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ Docked widgets will not scroll out of view, making them ideal for sticky headers
|
|||||||
|
|
||||||
|
|
||||||
class DockLayoutExample(App):
|
class DockLayoutExample(App):
|
||||||
CSS_PATH = "dock_layout1_sidebar.css"
|
CSS_PATH = "dock_layout1_sidebar.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Static("Sidebar", id="sidebar")
|
yield Static("Sidebar", id="sidebar")
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ Docked widgets will not scroll out of view, making them ideal for sticky headers
|
|||||||
|
|
||||||
|
|
||||||
class DockLayoutExample(App):
|
class DockLayoutExample(App):
|
||||||
CSS_PATH = "dock_layout2_sidebar.css"
|
CSS_PATH = "dock_layout2_sidebar.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Static("Sidebar2", id="another-sidebar")
|
yield Static("Sidebar2", id="another-sidebar")
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ Docked widgets will not scroll out of view, making them ideal for sticky headers
|
|||||||
|
|
||||||
|
|
||||||
class DockLayoutExample(App):
|
class DockLayoutExample(App):
|
||||||
CSS_PATH = "dock_layout3_sidebar_header.css"
|
CSS_PATH = "dock_layout3_sidebar_header.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Header(id="header")
|
yield Header(id="header")
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from textual.widgets import Static
|
|||||||
|
|
||||||
|
|
||||||
class GridLayoutExample(App):
|
class GridLayoutExample(App):
|
||||||
CSS_PATH = "grid_layout1.css"
|
CSS_PATH = "grid_layout1.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Static("One", classes="box")
|
yield Static("One", classes="box")
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from textual.widgets import Static
|
|||||||
|
|
||||||
|
|
||||||
class GridLayoutExample(App):
|
class GridLayoutExample(App):
|
||||||
CSS_PATH = "grid_layout2.css"
|
CSS_PATH = "grid_layout2.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Static("One", classes="box")
|
yield Static("One", classes="box")
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from textual.widgets import Static
|
|||||||
|
|
||||||
|
|
||||||
class GridLayoutExample(App):
|
class GridLayoutExample(App):
|
||||||
CSS_PATH = "grid_layout3_row_col_adjust.css"
|
CSS_PATH = "grid_layout3_row_col_adjust.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Static("One", classes="box")
|
yield Static("One", classes="box")
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from textual.widgets import Static
|
|||||||
|
|
||||||
|
|
||||||
class GridLayoutExample(App):
|
class GridLayoutExample(App):
|
||||||
CSS_PATH = "grid_layout4_row_col_adjust.css"
|
CSS_PATH = "grid_layout4_row_col_adjust.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Static("One", classes="box")
|
yield Static("One", classes="box")
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from textual.widgets import Static
|
|||||||
|
|
||||||
|
|
||||||
class GridLayoutExample(App):
|
class GridLayoutExample(App):
|
||||||
CSS_PATH = "grid_layout5_col_span.css"
|
CSS_PATH = "grid_layout5_col_span.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Static("One", classes="box")
|
yield Static("One", classes="box")
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from textual.widgets import Static
|
|||||||
|
|
||||||
|
|
||||||
class GridLayoutExample(App):
|
class GridLayoutExample(App):
|
||||||
CSS_PATH = "grid_layout6_row_span.css"
|
CSS_PATH = "grid_layout6_row_span.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Static("One", classes="box")
|
yield Static("One", classes="box")
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from textual.widgets import Static
|
|||||||
|
|
||||||
|
|
||||||
class GridLayoutExample(App):
|
class GridLayoutExample(App):
|
||||||
CSS_PATH = "grid_layout7_gutter.css"
|
CSS_PATH = "grid_layout7_gutter.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Static("One", classes="box")
|
yield Static("One", classes="box")
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from textual.widgets import Static
|
|||||||
|
|
||||||
|
|
||||||
class GridLayoutExample(App):
|
class GridLayoutExample(App):
|
||||||
CSS_PATH = "grid_layout_auto.css"
|
CSS_PATH = "grid_layout_auto.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Static("First column", classes="box")
|
yield Static("First column", classes="box")
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from textual.widgets import Static
|
|||||||
|
|
||||||
|
|
||||||
class HorizontalLayoutExample(App):
|
class HorizontalLayoutExample(App):
|
||||||
CSS_PATH = "horizontal_layout.css"
|
CSS_PATH = "horizontal_layout.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Static("One", classes="box")
|
yield Static("One", classes="box")
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from textual.widgets import Static
|
|||||||
|
|
||||||
|
|
||||||
class HorizontalLayoutExample(App):
|
class HorizontalLayoutExample(App):
|
||||||
CSS_PATH = "horizontal_layout_overflow.css"
|
CSS_PATH = "horizontal_layout_overflow.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Static("One", classes="box")
|
yield Static("One", classes="box")
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from textual.widgets import Static
|
|||||||
|
|
||||||
|
|
||||||
class LayersExample(App):
|
class LayersExample(App):
|
||||||
CSS_PATH = "layers.css"
|
CSS_PATH = "layers.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Static("box1 (layer = above)", id="box1")
|
yield Static("box1 (layer = above)", id="box1")
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from textual.widgets import Static
|
|||||||
|
|
||||||
|
|
||||||
class UtilityContainersExample(App):
|
class UtilityContainersExample(App):
|
||||||
CSS_PATH = "utility_containers.css"
|
CSS_PATH = "utility_containers.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Horizontal(
|
yield Horizontal(
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from textual.widgets import Static
|
|||||||
|
|
||||||
|
|
||||||
class UtilityContainersExample(App):
|
class UtilityContainersExample(App):
|
||||||
CSS_PATH = "utility_containers.css"
|
CSS_PATH = "utility_containers.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
with Horizontal():
|
with Horizontal():
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from textual.widgets import Static
|
|||||||
|
|
||||||
|
|
||||||
class VerticalLayoutExample(App):
|
class VerticalLayoutExample(App):
|
||||||
CSS_PATH = "vertical_layout.css"
|
CSS_PATH = "vertical_layout.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Static("One", classes="box")
|
yield Static("One", classes="box")
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from textual.widgets import Static
|
|||||||
|
|
||||||
|
|
||||||
class VerticalLayoutScrolledExample(App):
|
class VerticalLayoutScrolledExample(App):
|
||||||
CSS_PATH = "vertical_layout_scrolled.css"
|
CSS_PATH = "vertical_layout_scrolled.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Static("One", classes="box")
|
yield Static("One", classes="box")
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from textual.widgets import Input, Static
|
|||||||
|
|
||||||
|
|
||||||
class ComputedApp(App):
|
class ComputedApp(App):
|
||||||
CSS_PATH = "computed01.css"
|
CSS_PATH = "computed01.tcss"
|
||||||
|
|
||||||
red = reactive(0)
|
red = reactive(0)
|
||||||
green = reactive(0)
|
green = reactive(0)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class Name(Widget):
|
|||||||
|
|
||||||
|
|
||||||
class WatchApp(App):
|
class WatchApp(App):
|
||||||
CSS_PATH = "refresh01.css"
|
CSS_PATH = "refresh01.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Input(placeholder="Enter your name")
|
yield Input(placeholder="Enter your name")
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class Name(Widget):
|
|||||||
|
|
||||||
|
|
||||||
class WatchApp(App):
|
class WatchApp(App):
|
||||||
CSS_PATH = "refresh02.css"
|
CSS_PATH = "refresh02.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Input(placeholder="Enter your name")
|
yield Input(placeholder="Enter your name")
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from textual.widgets import Button, RichLog
|
|||||||
|
|
||||||
|
|
||||||
class ValidateApp(App):
|
class ValidateApp(App):
|
||||||
CSS_PATH = "validate01.css"
|
CSS_PATH = "validate01.tcss"
|
||||||
|
|
||||||
count = reactive(0)
|
count = reactive(0)
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from textual.widgets import Input, Static
|
|||||||
|
|
||||||
|
|
||||||
class WatchApp(App):
|
class WatchApp(App):
|
||||||
CSS_PATH = "watch01.css"
|
CSS_PATH = "watch01.tcss"
|
||||||
|
|
||||||
color = reactive(Color.parse("transparent")) # (1)!
|
color = reactive(Color.parse("transparent")) # (1)!
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ Input {
|
|||||||
border: wide $secondary;
|
border: wide $secondary;
|
||||||
}
|
}
|
||||||
|
|
||||||
#new {
|
#new {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
border: wide $secondary;
|
border: wide $secondary;
|
||||||
}
|
}
|
||||||
@@ -33,7 +33,7 @@ class QuitScreen(Screen):
|
|||||||
class ModalApp(App):
|
class ModalApp(App):
|
||||||
"""An app with a modal dialog."""
|
"""An app with a modal dialog."""
|
||||||
|
|
||||||
CSS_PATH = "modal01.css"
|
CSS_PATH = "modal01.tcss"
|
||||||
BINDINGS = [("q", "request_quit", "Quit")]
|
BINDINGS = [("q", "request_quit", "Quit")]
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class QuitScreen(ModalScreen):
|
|||||||
class ModalApp(App):
|
class ModalApp(App):
|
||||||
"""An app with a modal dialog."""
|
"""An app with a modal dialog."""
|
||||||
|
|
||||||
CSS_PATH = "modal01.css"
|
CSS_PATH = "modal01.tcss"
|
||||||
BINDINGS = [("q", "request_quit", "Quit")]
|
BINDINGS = [("q", "request_quit", "Quit")]
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class QuitScreen(ModalScreen[bool]): # (1)!
|
|||||||
class ModalApp(App):
|
class ModalApp(App):
|
||||||
"""An app with a modal dialog."""
|
"""An app with a modal dialog."""
|
||||||
|
|
||||||
CSS_PATH = "modal01.css"
|
CSS_PATH = "modal01.tcss"
|
||||||
BINDINGS = [("q", "request_quit", "Quit")]
|
BINDINGS = [("q", "request_quit", "Quit")]
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ from textual.app import App, ComposeResult
|
|||||||
from textual.screen import Screen
|
from textual.screen import Screen
|
||||||
from textual.widgets import Static
|
from textual.widgets import Static
|
||||||
|
|
||||||
|
|
||||||
ERROR_TEXT = """
|
ERROR_TEXT = """
|
||||||
An error has occurred. To continue:
|
An error has occurred. To continue:
|
||||||
|
|
||||||
@@ -25,7 +24,7 @@ class BSOD(Screen):
|
|||||||
|
|
||||||
|
|
||||||
class BSODApp(App):
|
class BSODApp(App):
|
||||||
CSS_PATH = "screen01.css"
|
CSS_PATH = "screen01.tcss"
|
||||||
SCREENS = {"bsod": BSOD()}
|
SCREENS = {"bsod": BSOD()}
|
||||||
BINDINGS = [("b", "push_screen('bsod')", "BSOD")]
|
BINDINGS = [("b", "push_screen('bsod')", "BSOD")]
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ BSOD {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BSOD>Static {
|
BSOD>Static {
|
||||||
width: 70;
|
width: 70;
|
||||||
}
|
}
|
||||||
|
|
||||||
#title {
|
#title {
|
||||||
@@ -2,7 +2,6 @@ from textual.app import App, ComposeResult
|
|||||||
from textual.screen import Screen
|
from textual.screen import Screen
|
||||||
from textual.widgets import Static
|
from textual.widgets import Static
|
||||||
|
|
||||||
|
|
||||||
ERROR_TEXT = """
|
ERROR_TEXT = """
|
||||||
An error has occurred. To continue:
|
An error has occurred. To continue:
|
||||||
|
|
||||||
@@ -25,7 +24,7 @@ class BSOD(Screen):
|
|||||||
|
|
||||||
|
|
||||||
class BSODApp(App):
|
class BSODApp(App):
|
||||||
CSS_PATH = "screen02.css"
|
CSS_PATH = "screen02.tcss"
|
||||||
BINDINGS = [("b", "push_screen('bsod')", "BSOD")]
|
BINDINGS = [("b", "push_screen('bsod')", "BSOD")]
|
||||||
|
|
||||||
def on_mount(self) -> None:
|
def on_mount(self) -> None:
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ BSOD {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BSOD>Static {
|
BSOD>Static {
|
||||||
width: 70;
|
width: 70;
|
||||||
}
|
}
|
||||||
|
|
||||||
#title {
|
#title {
|
||||||
@@ -19,7 +19,7 @@ class FizzBuzz(Static):
|
|||||||
|
|
||||||
|
|
||||||
class FizzBuzzApp(App):
|
class FizzBuzzApp(App):
|
||||||
CSS_PATH = "fizzbuzz01.css"
|
CSS_PATH = "fizzbuzz01.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield FizzBuzz()
|
yield FizzBuzz()
|
||||||
|
|||||||
@@ -6,5 +6,5 @@ FizzBuzz {
|
|||||||
width: auto;
|
width: auto;
|
||||||
height: auto;
|
height: auto;
|
||||||
background: $primary;
|
background: $primary;
|
||||||
color: $text;
|
color: $text;
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ class FizzBuzz(Static):
|
|||||||
|
|
||||||
|
|
||||||
class FizzBuzzApp(App):
|
class FizzBuzzApp(App):
|
||||||
CSS_PATH = "fizzbuzz02.css"
|
CSS_PATH = "fizzbuzz02.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield FizzBuzz()
|
yield FizzBuzz()
|
||||||
|
|||||||
@@ -5,6 +5,6 @@ Screen {
|
|||||||
FizzBuzz {
|
FizzBuzz {
|
||||||
width: auto;
|
width: auto;
|
||||||
height: auto;
|
height: auto;
|
||||||
background: $primary;
|
background: $primary;
|
||||||
color: $text;
|
color: $text;
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ class Hello(Widget):
|
|||||||
|
|
||||||
|
|
||||||
class CustomApp(App):
|
class CustomApp(App):
|
||||||
CSS_PATH = "hello02.css"
|
CSS_PATH = "hello02.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Hello()
|
yield Hello()
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ from itertools import cycle
|
|||||||
from textual.app import App, ComposeResult
|
from textual.app import App, ComposeResult
|
||||||
from textual.widgets import Static
|
from textual.widgets import Static
|
||||||
|
|
||||||
|
|
||||||
hellos = cycle(
|
hellos = cycle(
|
||||||
[
|
[
|
||||||
"Hola",
|
"Hola",
|
||||||
@@ -37,7 +36,7 @@ class Hello(Static):
|
|||||||
|
|
||||||
|
|
||||||
class CustomApp(App):
|
class CustomApp(App):
|
||||||
CSS_PATH = "hello03.css"
|
CSS_PATH = "hello03.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Hello()
|
yield Hello()
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ from itertools import cycle
|
|||||||
from textual.app import App, ComposeResult
|
from textual.app import App, ComposeResult
|
||||||
from textual.widgets import Static
|
from textual.widgets import Static
|
||||||
|
|
||||||
|
|
||||||
hellos = cycle(
|
hellos = cycle(
|
||||||
[
|
[
|
||||||
"Hola",
|
"Hola",
|
||||||
@@ -48,7 +47,7 @@ class Hello(Static):
|
|||||||
|
|
||||||
|
|
||||||
class CustomApp(App):
|
class CustomApp(App):
|
||||||
CSS_PATH = "hello04.css"
|
CSS_PATH = "hello04.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Hello()
|
yield Hello()
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ from itertools import cycle
|
|||||||
from textual.app import App, ComposeResult
|
from textual.app import App, ComposeResult
|
||||||
from textual.widgets import Static
|
from textual.widgets import Static
|
||||||
|
|
||||||
|
|
||||||
hellos = cycle(
|
hellos = cycle(
|
||||||
[
|
[
|
||||||
"Hola",
|
"Hola",
|
||||||
@@ -34,7 +33,7 @@ class Hello(Static):
|
|||||||
|
|
||||||
|
|
||||||
class CustomApp(App):
|
class CustomApp(App):
|
||||||
CSS_PATH = "hello05.css"
|
CSS_PATH = "hello05.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Hello()
|
yield Hello()
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class Hello(Static):
|
|||||||
|
|
||||||
|
|
||||||
class CustomApp(App):
|
class CustomApp(App):
|
||||||
CSS_PATH = "hello05.css"
|
CSS_PATH = "hello05.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Hello()
|
yield Hello()
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from textual.widgets import Input, Static
|
|||||||
class WeatherApp(App):
|
class WeatherApp(App):
|
||||||
"""App to display the current weather."""
|
"""App to display the current weather."""
|
||||||
|
|
||||||
CSS_PATH = "weather.css"
|
CSS_PATH = "weather.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Input(placeholder="Enter a City")
|
yield Input(placeholder="Enter a City")
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from textual.widgets import Input, Static
|
|||||||
class WeatherApp(App):
|
class WeatherApp(App):
|
||||||
"""App to display the current weather."""
|
"""App to display the current weather."""
|
||||||
|
|
||||||
CSS_PATH = "weather.css"
|
CSS_PATH = "weather.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Input(placeholder="Enter a City")
|
yield Input(placeholder="Enter a City")
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from textual.widgets import Input, Static
|
|||||||
class WeatherApp(App):
|
class WeatherApp(App):
|
||||||
"""App to display the current weather."""
|
"""App to display the current weather."""
|
||||||
|
|
||||||
CSS_PATH = "weather.css"
|
CSS_PATH = "weather.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Input(placeholder="Enter a City")
|
yield Input(placeholder="Enter a City")
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from textual.worker import Worker
|
|||||||
class WeatherApp(App):
|
class WeatherApp(App):
|
||||||
"""App to display the current weather."""
|
"""App to display the current weather."""
|
||||||
|
|
||||||
CSS_PATH = "weather.css"
|
CSS_PATH = "weather.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Input(placeholder="Enter a City")
|
yield Input(placeholder="Enter a City")
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ from textual.worker import Worker, get_current_worker
|
|||||||
class WeatherApp(App):
|
class WeatherApp(App):
|
||||||
"""App to display the current weather."""
|
"""App to display the current weather."""
|
||||||
|
|
||||||
CSS_PATH = "weather.css"
|
CSS_PATH = "weather.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Input(placeholder="Enter a City")
|
yield Input(placeholder="Enter a City")
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class TweetScreen(Screen):
|
|||||||
|
|
||||||
|
|
||||||
class LayoutApp(App):
|
class LayoutApp(App):
|
||||||
CSS_PATH = "layout.css"
|
CSS_PATH = "layout.tcss"
|
||||||
|
|
||||||
def on_ready(self) -> None:
|
def on_ready(self) -> None:
|
||||||
self.push_screen(TweetScreen())
|
self.push_screen(TweetScreen())
|
||||||
|
|||||||
@@ -8,4 +8,4 @@ class AlignApp(App):
|
|||||||
yield Label("Take note, browsers.", classes="box")
|
yield Label("Take note, browsers.", classes="box")
|
||||||
|
|
||||||
|
|
||||||
app = AlignApp(css_path="align.css")
|
app = AlignApp(css_path="align.tcss")
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from textual.widgets import Label
|
|||||||
class AlignAllApp(App):
|
class AlignAllApp(App):
|
||||||
"""App that illustrates all alignments."""
|
"""App that illustrates all alignments."""
|
||||||
|
|
||||||
CSS_PATH = "align_all.css"
|
CSS_PATH = "align_all.tcss"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Container(Label("left top"), id="left-top")
|
yield Container(Label("left top"), id="left-top")
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user