repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
textual
docs/examples/guide/reactivity/refresh03.py
.py
from textual.app import App, ComposeResult from textual.reactive import reactive from textual.widget import Widget from textual.widgets import Input, Label class Name(Widget): """Generates a greeting.""" who = reactive("name", recompose=True) # (1)! def compose(self) -> ComposeResult: # (2)! y...
30
696
textual
docs/examples/guide/reactivity/recompose02.py
.py
from datetime import datetime from textual.app import App, ComposeResult from textual.reactive import reactive from textual.widgets import Digits class Clock(App): CSS = """ Screen {align: center middle} Digits {width: auto} """ time: reactive[datetime] = reactive(datetime.now, recompose=True) ...
30
613
textual
docs/examples/guide/reactivity/refresh02.py
.py
from textual.app import App, ComposeResult from textual.reactive import reactive from textual.widget import Widget from textual.widgets import Input class Name(Widget): """Generates a greeting.""" who = reactive("name", layout=True) # (1)! def render(self) -> str: return f"Hello, {self.who}!" ...
30
661
textual
docs/examples/guide/reactivity/recompose01.py
.py
from datetime import datetime from textual.app import App, ComposeResult from textual.reactive import reactive from textual.widgets import Digits class Clock(App): CSS = """ Screen {align: center middle} Digits {width: auto} """ time: reactive[datetime] = reactive(datetime.now, init=False) ...
33
717
textual
docs/examples/guide/reactivity/dynamic_watch.py
.py
from textual.app import App, ComposeResult from textual.reactive import reactive from textual.widget import Widget from textual.widgets import Button, Label, ProgressBar class Counter(Widget): DEFAULT_CSS = "Counter { height: auto; }" counter = reactive(0) # (1)! def compose(self) -> ComposeResult: ...
36
972
textual
docs/examples/guide/reactivity/validate01.py
.py
from textual.app import App, ComposeResult from textual.containers import Horizontal from textual.reactive import reactive from textual.widgets import Button, RichLog class ValidateApp(App): CSS_PATH = "validate01.tcss" count = reactive(0) def validate_count(self, count: int) -> int: """Validate...
39
999
textual
docs/examples/guide/reactivity/world_clock02.py
.py
from datetime import datetime from pytz import timezone from textual.app import App, ComposeResult from textual.reactive import reactive from textual.widget import Widget from textual.widgets import Digits, Label class WorldClock(Widget): time: reactive[datetime] = reactive(datetime.now) def __init__(self...
48
1,310
textual
docs/examples/guide/reactivity/set_reactive03.py
.py
from textual.app import App, ComposeResult from textual.reactive import reactive from textual.widgets import Input, Label class MultiGreet(App): names: reactive[list[str]] = reactive(list, recompose=True) # (1)! def compose(self) -> ComposeResult: yield Input(placeholder="Give me a name") fo...
22
609
textual
docs/examples/guide/reactivity/refresh01.py
.py
from textual.app import App, ComposeResult from textual.reactive import reactive from textual.widget import Widget from textual.widgets import Input class Name(Widget): """Generates a greeting.""" who = reactive("name") def render(self) -> str: return f"Hello, {self.who}!" class WatchApp(App):...
30
640
textual
docs/examples/guide/reactivity/set_reactive01.py
.py
from textual.app import App, ComposeResult from textual.containers import Horizontal from textual.reactive import reactive, var from textual.widgets import Label GREETINGS = [ "Bonjour", "Hola", "こんにちは", "你好", "안녕하세요", "Hello", ] class Greeter(Horizontal): """Display a greeting and a name...
68
1,579
textual
docs/examples/guide/actions/actions06.py
.py
from textual.app import App, ComposeResult from textual.containers import HorizontalScroll from textual.reactive import reactive from textual.widgets import Footer, Placeholder PAGES_COUNT = 5 class PagesApp(App): BINDINGS = [ ("n", "next", "Next"), ("p", "previous", "Previous"), ] CSS_P...
49
1,353
textual
docs/examples/guide/actions/actions04.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static TEXT = """ [b]Set your background[/b] [@click=app.set_background('red')]Red[/] [@click=app.set_background('green')]Green[/] [@click=app.set_background('blue')]Blue[/] """ class ActionsApp(App): BINDINGS = [ ("r", "set_backgroun...
29
683
textual
docs/examples/guide/actions/actions03.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static TEXT = """ [b]Set your background[/b] [@click=app.set_background('red')]Red[/] [@click=app.set_background('green')]Green[/] [@click=app.set_background('blue')]Blue[/] """ class ActionsApp(App): def compose(self) -> ComposeResult: ...
23
512
textual
docs/examples/guide/actions/actions05.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static TEXT = """ [b]Set your background[/b] [@click=set_background('cyan')]Cyan[/] [@click=set_background('magenta')]Magenta[/] [@click=set_background('yellow')]Yellow[/] """ class ColorSwitcher(Static): def action_set_background(self, color...
36
881
textual
docs/examples/guide/actions/actions07.py
.py
from textual.app import App, ComposeResult from textual.containers import HorizontalScroll from textual.reactive import reactive from textual.widgets import Footer, Placeholder PAGES_COUNT = 5 class PagesApp(App): BINDINGS = [ ("n", "next", "Next"), ("p", "previous", "Previous"), ] CSS_P...
45
1,288
textual
docs/examples/guide/actions/actions02.py
.py
from textual import events from textual.app import App class ActionsApp(App): def action_set_background(self, color: str) -> None: self.screen.styles.background = color async def on_key(self, event: events.Key) -> None: if event.key == "r": await self.run_action("set_background('r...
17
393
textual
docs/examples/guide/actions/actions01.py
.py
from textual.app import App from textual import events class ActionsApp(App): def action_set_background(self, color: str) -> None: self.screen.styles.background = color def on_key(self, event: events.Key) -> None: if event.key == "r": self.action_set_background("red") if __name_...
17
374
textual
docs/examples/guide/animator/animation01.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class AnimationApp(App): def compose(self) -> ComposeResult: self.box = Static("Hello, World!") self.box.styles.background = "red" self.box.styles.color = "black" self.box.styles.padding = (1, 2) ...
20
496
textual
docs/examples/guide/animator/animation01_static.py
.py
from textual._easing import DEFAULT_EASING, EASING from textual.app import App, ComposeResult from textual.widgets import Static ease = EASING[DEFAULT_EASING] class AnimationApp(App): def compose(self) -> ComposeResult: self.box = Static("Hello, World!") self.box.styles.background = "red" ...
29
697
textual
docs/examples/guide/input/binding01.py
.py
from textual.app import App, ComposeResult from textual.color import Color from textual.widgets import Footer, Static class Bar(Static): pass class BindingApp(App): CSS_PATH = "binding01.tcss" BINDINGS = [ ("r", "add_bar('red')", "Add Red"), ("g", "add_bar('green')", "Add Green"), ...
31
734
textual
docs/examples/guide/input/key01.py
.py
from textual import events from textual.app import App, ComposeResult from textual.widgets import RichLog class InputApp(App): """App to display key events.""" def compose(self) -> ComposeResult: yield RichLog() def on_key(self, event: events.Key) -> None: self.query_one(RichLog).write(e...
19
390
textual
docs/examples/guide/input/mouse01.py
.py
from textual import events from textual.app import App, ComposeResult from textual.widgets import RichLog, Static class Ball(Static): pass class MouseApp(App): CSS_PATH = "mouse01.tcss" def compose(self) -> ComposeResult: yield RichLog() yield Ball("Textual") def on_mouse_move(self...
25
539
textual
docs/examples/guide/input/key02.py
.py
from textual import events from textual.app import App, ComposeResult from textual.widgets import RichLog class InputApp(App): """App to display key events.""" def compose(self) -> ComposeResult: yield RichLog() def on_key(self, event: events.Key) -> None: self.query_one(RichLog).write(e...
22
444
textual
docs/examples/guide/input/key03.py
.py
from textual import events from textual.app import App, ComposeResult from textual.widgets import RichLog class KeyLogger(RichLog): def on_key(self, event: events.Key) -> None: self.write(event) class InputApp(App): """App to display key events.""" CSS_PATH = "key03.tcss" def compose(self)...
26
507
textual
docs/examples/guide/screens/screen02.py
.py
from textual.app import App, ComposeResult from textual.screen import Screen from textual.widgets import Static ERROR_TEXT = """ An error has occurred. To continue: Press Enter to return to Windows, or Press CTRL+ALT+DEL to restart your computer. If you do this, you will lose any unsaved information in all open appl...
37
893
textual
docs/examples/guide/screens/modal01.py
.py
from textual.app import App, ComposeResult from textual.containers import Grid from textual.screen import Screen from textual.widgets import Button, Footer, Header, Label 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 t...
51
1,423
textual
docs/examples/guide/screens/modal02.py
.py
from textual.app import App, ComposeResult from textual.containers import Grid from textual.screen import ModalScreen from textual.widgets import Button, Footer, Header, Label 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...
52
1,482
textual
docs/examples/guide/screens/modal03.py
.py
from textual.app import App, ComposeResult from textual.containers import Grid from textual.screen import ModalScreen from textual.widgets import Button, Footer, Header, Label 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...
58
1,666
textual
docs/examples/guide/screens/questions01.py
.py
from textual import on, work from textual.app import App, ComposeResult from textual.screen import Screen from textual.widgets import Button, Label class QuestionScreen(Screen[bool]): """Screen with a parameter.""" def __init__(self, question: str) -> None: self.question = question super().__...
46
1,142
textual
docs/examples/guide/screens/modes01.py
.py
from textual.app import App, ComposeResult from textual.screen import Screen from textual.widgets import Footer, Placeholder class DashboardScreen(Screen): def compose(self) -> ComposeResult: yield Placeholder("Dashboard Screen") yield Footer() class SettingsScreen(Screen): def compose(self)...
43
1,022
textual
docs/examples/guide/screens/screen01.py
.py
from textual.app import App, ComposeResult from textual.screen import Screen from textual.widgets import Static ERROR_TEXT = """ An error has occurred. To continue: Press Enter to return to Windows, or Press CTRL+ALT+DEL to restart your computer. If you do this, you will lose any unsaved information in all open appl...
35
840
textual
docs/examples/guide/styles/box_sizing01.py
.py
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 i...
38
1,193
textual
docs/examples/guide/styles/outline01.py
.py
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 i...
28
773
textual
docs/examples/guide/styles/margin01.py
.py
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 i...
33
980
textual
docs/examples/guide/styles/dimensions04.py
.py
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 i...
31
884
textual
docs/examples/guide/styles/screen.py
.py
from textual.app import App class ScreenApp(App): def on_mount(self) -> None: self.screen.styles.background = "darkblue" self.screen.styles.border = ("heavy", "white") if __name__ == "__main__": app = ScreenApp() app.run()
13
255
textual
docs/examples/guide/styles/colors01.py
.py
from textual.app import App, ComposeResult from textual.color import Color from textual.widgets import Static class ColorApp(App): def compose(self) -> ComposeResult: self.widget1 = Static("Textual One") yield self.widget1 self.widget2 = Static("Textual Two") yield self.widget2 ...
25
706
textual
docs/examples/guide/styles/border_title.py
.py
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 it...
30
971
textual
docs/examples/guide/styles/border01.py
.py
from textual.app import App, ComposeResult from textual.widgets import Label 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...
27
767
textual
docs/examples/guide/styles/colors02.py
.py
from textual.app import App, ComposeResult from textual.color import Color from textual.widgets import Static class ColorApp(App): def compose(self) -> ComposeResult: self.widgets = [Static("") for n in range(10)] yield from self.widgets def on_mount(self) -> None: for index, widget i...
21
561
textual
docs/examples/guide/styles/dimensions01.py
.py
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 i...
28
756
textual
docs/examples/guide/styles/widget.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class WidgetApp(App): def compose(self) -> ComposeResult: self.widget = Static("Textual") yield self.widget def on_mount(self) -> None: self.widget.styles.background = "darkblue" self.widget.styles.b...
18
412
textual
docs/examples/guide/styles/padding01.py
.py
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 i...
28
750
textual
docs/examples/guide/styles/dimensions03.py
.py
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 i...
28
762
textual
docs/examples/guide/styles/dimensions02.py
.py
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 i...
28
760
textual
docs/examples/guide/styles/padding02.py
.py
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 i...
28
755
textual
docs/examples/guide/css/nesting01.py
.py
from textual.app import App, ComposeResult from textual.containers import Horizontal from textual.widgets import Static class NestingDemo(App): """App that doesn't have nested CSS.""" CSS_PATH = "nesting01.tcss" def compose(self) -> ComposeResult: with Horizontal(id="questions"): yie...
20
492
textual
docs/examples/guide/css/nesting02.py
.py
from textual.app import App, ComposeResult from textual.containers import Horizontal from textual.widgets import Static class NestingDemo(App): """App with nested CSS.""" CSS_PATH = "nesting02.tcss" def compose(self) -> ComposeResult: with Horizontal(id="questions"): yield Static("Ye...
20
479
textual
docs/examples/guide/command_palette/command01.py
.py
from typing import Iterable from textual.app import App, SystemCommand from textual.screen import Screen class BellCommandApp(App): """An app with a 'bell' command.""" def get_system_commands(self, screen: Screen) -> Iterable[SystemCommand]: yield from super().get_system_commands(screen) # (1)! ...
18
459
textual
docs/examples/guide/command_palette/command02.py
.py
from __future__ import annotations from functools import partial from pathlib import Path from textual.app import App, ComposeResult from textual.command import Hit, Hits, Provider from textual.containers import VerticalScroll from textual.widgets import Static class PythonFileCommands(Provider): """A command p...
69
2,101
textual
docs/examples/guide/layout/grid_layout7_gutter.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class GridLayoutExample(App): CSS_PATH = "grid_layout7_gutter.tcss" def compose(self) -> ComposeResult: yield Static("One", classes="box") yield Static("Two", classes="box") yield Static("Three", classes="bo...
20
528
textual
docs/examples/guide/layout/horizontal_layout.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class HorizontalLayoutExample(App): CSS_PATH = "horizontal_layout.tcss" def compose(self) -> ComposeResult: yield Static("One", classes="box") yield Static("Two", classes="box") yield Static("Three", classes...
17
407
textual
docs/examples/guide/layout/combining_layouts.py
.py
from textual.app import App, ComposeResult from textual.containers import Container, Horizontal, VerticalScroll from textual.widgets import Header, Static class CombiningLayoutsExample(App): CSS_PATH = "combining_layouts.tcss" def compose(self) -> ComposeResult: yield Header() with Container(...
31
1,050
textual
docs/examples/guide/layout/dock_layout3_sidebar_header.py
.py
from textual.app import App, ComposeResult from textual.widgets import Header, Static TEXT = """\ Docking a widget removes it from the layout and fixes its position, aligned to either the top, right, bottom, or left edges of a container. Docked widgets will not scroll out of view, making them ideal for sticky headers...
24
670
textual
docs/examples/guide/layout/grid_layout2.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class GridLayoutExample(App): CSS_PATH = "grid_layout2.tcss" def compose(self) -> ComposeResult: yield Static("One", classes="box") yield Static("Two", classes="box") yield Static("Three", classes="box") ...
21
566
textual
docs/examples/guide/layout/utility_containers_using_with.py
.py
from textual.app import App, ComposeResult from textual.containers import Horizontal, Vertical from textual.widgets import Static class UtilityContainersExample(App): CSS_PATH = "utility_containers.tcss" def compose(self) -> ComposeResult: with Horizontal(): with Vertical(classes="column"...
22
595
textual
docs/examples/guide/layout/grid_layout_auto.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class GridLayoutExample(App): CSS_PATH = "grid_layout_auto.tcss" def compose(self) -> ComposeResult: yield Static("First column", classes="box") yield Static("Two", classes="box") yield Static("Three", class...
20
534
textual
docs/examples/guide/layout/grid_layout1.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class GridLayoutExample(App): CSS_PATH = "grid_layout1.tcss" def compose(self) -> ComposeResult: yield Static("One", classes="box") yield Static("Two", classes="box") yield Static("Three", classes="box") ...
20
521
textual
docs/examples/guide/layout/grid_layout5_col_span.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class GridLayoutExample(App): CSS_PATH = "grid_layout5_col_span.tcss" def compose(self) -> ComposeResult: yield Static("One", classes="box") yield Static("Two [b](column-span: 2)", classes="box", id="two") y...
20
560
textual
docs/examples/guide/layout/dock_layout2_sidebar.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static TEXT = """\ Docking a widget removes it from the layout and fixes its position, aligned to either the top, right, bottom, or left edges of a container. Docked widgets will not scroll out of view, making them ideal for sticky headers, footer...
24
672
textual
docs/examples/guide/layout/vertical_layout_scrolled.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class VerticalLayoutScrolledExample(App): CSS_PATH = "vertical_layout_scrolled.tcss" def compose(self) -> ComposeResult: yield Static("One", classes="box") yield Static("Two", classes="box") yield Static("Th...
17
426
textual
docs/examples/guide/layout/dock_layout1_sidebar.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static TEXT = """\ Docking a widget removes it from the layout and fixes its position, aligned to either the top, right, bottom, or left edges of a container. Docked widgets will not scroll out of view, making them ideal for sticky headers, footer...
23
620
textual
docs/examples/guide/layout/horizontal_layout_overflow.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class HorizontalLayoutExample(App): CSS_PATH = "horizontal_layout_overflow.tcss" def compose(self) -> ComposeResult: yield Static("One", classes="box") yield Static("Two", classes="box") yield Static("Three"...
17
416
textual
docs/examples/guide/layout/vertical_layout.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class VerticalLayoutExample(App): CSS_PATH = "vertical_layout.tcss" def compose(self) -> ComposeResult: yield Static("One", classes="box") yield Static("Two", classes="box") yield Static("Three", classes="bo...
17
401
textual
docs/examples/guide/layout/grid_layout6_row_span.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class GridLayoutExample(App): CSS_PATH = "grid_layout6_row_span.tcss" def compose(self) -> ComposeResult: yield Static("One", classes="box") yield Static("Two [b](column-span: 2 and row-span: 2)", classes="box", id=...
20
572
textual
docs/examples/guide/layout/layers.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class LayersExample(App): CSS_PATH = "layers.tcss" def compose(self) -> ComposeResult: yield Static("box1 (layer = above)", id="box1") yield Static("box2 (layer = below)", id="box2") if __name__ == "__main__": ...
16
357
textual
docs/examples/guide/layout/utility_containers.py
.py
from textual.app import App, ComposeResult from textual.containers import Horizontal, Vertical from textual.widgets import Static class UtilityContainersExample(App): CSS_PATH = "utility_containers.tcss" def compose(self) -> ComposeResult: yield Horizontal( Vertical( Stati...
27
636
textual
docs/examples/guide/layout/grid_layout3_row_col_adjust.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class GridLayoutExample(App): CSS_PATH = "grid_layout3_row_col_adjust.tcss" def compose(self) -> ComposeResult: yield Static("One", classes="box") yield Static("Two", classes="box") yield Static("Three", cla...
20
536
textual
docs/examples/guide/layout/grid_layout4_row_col_adjust.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class GridLayoutExample(App): CSS_PATH = "grid_layout4_row_col_adjust.tcss" def compose(self) -> ComposeResult: yield Static("One", classes="box") yield Static("Two", classes="box") yield Static("Three", cla...
20
536
textual
docs/examples/guide/workers/weather02.py
.py
import httpx from rich.text import Text from textual.app import App, ComposeResult from textual.containers import VerticalScroll from textual.widgets import Input, Static class WeatherApp(App): """App to display the current weather.""" CSS_PATH = "weather.tcss" def compose(self) -> ComposeResult: ...
41
1,289
textual
docs/examples/guide/workers/weather05.py
.py
from urllib.parse import quote from urllib.request import Request, urlopen from rich.text import Text from textual import work from textual.app import App, ComposeResult from textual.containers import VerticalScroll from textual.widgets import Input, Static from textual.worker import Worker, get_current_worker clas...
54
1,807
textual
docs/examples/guide/workers/weather03.py
.py
import httpx from rich.text import Text from textual import work from textual.app import App, ComposeResult from textual.containers import VerticalScroll from textual.widgets import Input, Static class WeatherApp(App): """App to display the current weather.""" CSS_PATH = "weather.tcss" def compose(self...
43
1,307
textual
docs/examples/guide/workers/weather01.py
.py
import httpx from rich.text import Text from textual.app import App, ComposeResult from textual.containers import VerticalScroll from textual.widgets import Input, Static class WeatherApp(App): """App to display the current weather.""" CSS_PATH = "weather.tcss" def compose(self) -> ComposeResult: ...
41
1,262
textual
docs/examples/guide/workers/weather04.py
.py
import httpx from rich.text import Text from textual import work from textual.app import App, ComposeResult from textual.containers import VerticalScroll from textual.widgets import Input, Static from textual.worker import Worker class WeatherApp(App): """App to display the current weather.""" CSS_PATH = "w...
48
1,493
textual
docs/examples/guide/content/playground.py
.py
from textual._markup_playground import MarkupPlayground if __name__ == "__main__": app = MarkupPlayground() app.run()
6
127
textual
docs/examples/guide/content/renderables.py
.py
from rich.syntax import Syntax from textual.app import App, ComposeResult, RenderResult from textual.reactive import reactive from textual.widget import Widget class CodeView(Widget): """Widget to display Python code.""" DEFAULT_CSS = """ CodeView { height: auto; } """ code = reactive("") ...
37
883
textual
docs/examples/guide/content/content01.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static TEXT1 = """\ Hello, [bold $text on $primary]World[/]! [@click=app.notify('Hello, World!')]Click me[/] """ TEXT2 = """\ Markup will [bold]not[/bold] be displayed. Tags will be left in the output. """ class ContentApp(App): CSS = """...
37
701
textual
docs/examples/guide/compound/byte02.py
.py
from __future__ import annotations from textual.app import App, ComposeResult from textual.containers import Container from textual.message import Message from textual.reactive import reactive from textual.widget import Widget from textual.widgets import Input, Label, Switch class BitSwitch(Widget): """A Switch ...
107
2,581
textual
docs/examples/guide/compound/compound01.py
.py
from textual.app import App, ComposeResult from textual.widget import Widget from textual.widgets import Input, Label class InputWithLabel(Widget): """An input with a label.""" DEFAULT_CSS = """ InputWithLabel { layout: horizontal; height: auto; } InputWithLabel Label { pa...
53
1,063
textual
docs/examples/guide/compound/byte01.py
.py
from __future__ import annotations from textual.app import App, ComposeResult from textual.containers import Container from textual.widget import Widget from textual.widgets import Input, Label, Switch class BitSwitch(Widget): """A Switch with a numeric label above it.""" DEFAULT_CSS = """ BitSwitch { ...
82
1,675
textual
docs/examples/guide/compound/byte03.py
.py
from __future__ import annotations from textual.app import App, ComposeResult from textual.containers import Container from textual.geometry import clamp from textual.message import Message from textual.reactive import reactive from textual.widget import Widget from textual.widgets import Input, Label, Switch class ...
131
3,462
textual
docs/examples/how-to/layout.py
.py
from textual.app import App, ComposeResult from textual.containers import HorizontalScroll, VerticalScroll from textual.screen import Screen from textual.widgets import Placeholder class Header(Placeholder): DEFAULT_CSS = """ Header { height: 3; dock: top; } """ class Footer(Placehol...
70
1,302
textual
docs/examples/how-to/layout03.py
.py
from textual.app import App, ComposeResult from textual.screen import Screen from textual.widgets import Placeholder class Header(Placeholder): DEFAULT_CSS = """ Header { height: 3; dock: top; } """ class Footer(Placeholder): DEFAULT_CSS = """ Footer { height: 3; ...
49
871
textual
docs/examples/how-to/render_compose.py
.py
from time import time from textual.app import App, ComposeResult, RenderResult from textual.containers import Container from textual.renderables.gradient import LinearGradient from textual.widgets import Static COLORS = [ "#881177", "#aa3355", "#cc6666", "#ee9944", "#eedd00", "#99dd55", "#...
58
1,173
textual
docs/examples/how-to/center06.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static QUOTE = "Could not find you in Seattle and no terminal is in operation at your classified address." class CenterApp(App): """How to center things.""" CSS = """ Screen { align: center middle; } #hello { ...
31
597
textual
docs/examples/how-to/center02.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class CenterApp(App): """How to center things.""" CSS = """ Screen { align: center middle; } #hello { background: blue 50%; border: wide white; } """ def compose(self) -> ComposeRes...
26
440
textual
docs/examples/how-to/containers01.py
.py
from textual.app import App, ComposeResult from textual.containers import Horizontal from textual.widgets import Placeholder class Box(Placeholder): """Example widget.""" DEFAULT_CSS = """ Box { width: 16; height: 8; } """ class ContainerApp(App): """Simple app to pl...
30
567
textual
docs/examples/how-to/center08.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class CenterApp(App): """How to center things.""" CSS = """ .words { background: blue 50%; border: wide white; width: auto; } """ def compose(self) -> ComposeResult: yield Static("Ho...
24
475
textual
docs/examples/how-to/containers02.py
.py
from textual.app import App, ComposeResult from textual.containers import Vertical from textual.widgets import Placeholder class Box(Placeholder): """Example widget.""" DEFAULT_CSS = """ Box { width: 16; height: 8; } """ class ContainerApp(App): """Simple app to play...
30
555
textual
docs/examples/how-to/center04.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static QUOTE = "Could not find you in Seattle and no terminal is in operation at your classified address." class CenterApp(App): """How to center things.""" CSS = """ Screen { align: center middle; } #hello { ...
29
550
textual
docs/examples/how-to/containers04.py
.py
from textual.app import App, ComposeResult from textual.containers import Horizontal from textual.widgets import Placeholder class Box(Placeholder): """Example widget.""" DEFAULT_CSS = """ Box { width: 16; height: 8; } """ class ContainerApp(App): """Simple app to pl...
40
769
textual
docs/examples/how-to/center07.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static QUOTE = "Could not find you in Seattle and no terminal is in operation at your classified address." class CenterApp(App): """How to center things.""" CSS = """ Screen { align: center middle; } #hello { ...
32
635
textual
docs/examples/how-to/center09.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class CenterApp(App): """How to center things.""" CSS = """ Screen { align: center middle; } .words { background: blue 50%; border: wide white; width: auto; } """ def compos...
28
525
textual
docs/examples/how-to/layout02.py
.py
from textual.app import App, ComposeResult from textual.screen import Screen from textual.widgets import Placeholder class Header(Placeholder): DEFAULT_CSS = """ Header { height: 3; dock: top; } """ class Footer(Placeholder): DEFAULT_CSS = """ Footer { height: 3; ...
38
650
textual
docs/examples/how-to/containers03.py
.py
from textual.app import App, ComposeResult from textual.containers import Horizontal from textual.widgets import Placeholder class Box(Placeholder): """Example widget.""" DEFAULT_CSS = """ Box { width: 16; height: 8; } """ class ContainerApp(App): """Simple app to pl...
36
657
textual
docs/examples/how-to/inline02.py
.py
from datetime import datetime from textual.app import App, ComposeResult from textual.widgets import Digits class ClockApp(App): CSS = """ Screen { align: center middle; &:inline { border: none; height: 50vh; Digits { color: $success; ...
39
782
textual
docs/examples/how-to/center10.py
.py
from textual.app import App, ComposeResult from textual.containers import Center from textual.widgets import Static class CenterApp(App): """How to center things.""" CSS = """ Screen { align: center middle; } .words { background: blue 50%; border: wide white; widt...
31
617
textual
docs/examples/how-to/containers09.py
.py
from textual.app import App, ComposeResult from textual.containers import Middle from textual.widgets import Placeholder class Box(Placeholder): """Example widget.""" DEFAULT_CSS = """ Box { width: 16; height: 5; } """ class ContainerApp(App): """Simple app to play w...
36
673
textual
docs/examples/how-to/center05.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static QUOTE = "Could not find you in Seattle and no terminal is in operation at your classified address." class CenterApp(App): """How to center things.""" CSS = """ Screen { align: center middle; } #hello { ...
30
578
textual
docs/examples/how-to/layout04.py
.py
from textual.app import App, ComposeResult from textual.containers import HorizontalScroll from textual.screen import Screen from textual.widgets import Placeholder class Header(Placeholder): DEFAULT_CSS = """ Header { height: 3; dock: top; } """ class Footer(Placeholder): DEFAUL...
40
739