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/structure.py
.py
from datetime import datetime from textual.app import App from textual.widget import Widget class Clock(Widget): """A clock app.""" DEFAULT_CSS = """ Clock { content-align: center middle; } """ def on_mount(self): self.set_interval(1, self.refresh) def render(self): ...
31
494
textual
docs/examples/guide/dom4.py
.py
from textual.app import App, ComposeResult from textual.containers import Container, Horizontal from textual.widgets import Button, Footer, Header, Static QUESTION = "Do you want to learn about Textual CSS?" class ExampleApp(App): CSS_PATH = "dom4.tcss" def compose(self) -> ComposeResult: yield Head...
28
695
textual
docs/examples/guide/dom1.py
.py
from textual.app import App class ExampleApp(App): pass if __name__ == "__main__": app = ExampleApp() app.run()
11
128
textual
docs/examples/guide/dom3.py
.py
from textual.app import App, ComposeResult from textual.containers import Container, Horizontal from textual.widgets import Button, Footer, Header, Static QUESTION = "Do you want to learn about Textual CSS?" class ExampleApp(App): def compose(self) -> ComposeResult: yield Header() yield Footer() ...
26
667
textual
docs/examples/guide/dom2.py
.py
from textual.app import App, ComposeResult from textual.widgets import Header, Footer class ExampleApp(App): def compose(self) -> ComposeResult: yield Header() yield Footer() if __name__ == "__main__": app = ExampleApp() app.run()
14
263
textual
docs/examples/guide/testing/rgb.py
.py
from textual import on from textual.app import App, ComposeResult from textual.containers import Horizontal from textual.widgets import Button, Footer class RGBApp(App): CSS = """ Screen { align: center middle; } Horizontal { width: auto; height: auto; } """ BINDIN...
43
1,049
textual
docs/examples/guide/testing/test_rgb.py
.py
from rgb import RGBApp from textual.color import Color async def test_keys(): # (1)! """Test pressing keys has the desired result.""" app = RGBApp() async with app.run_test() as pilot: # (2)! # Test pressing the R key await pilot.press("r") # (3)! assert app.screen.styles.backg...
43
1,387
textual
docs/examples/guide/widgets/hello04.py
.py
from itertools import cycle from textual.app import App, ComposeResult from textual.widgets import Static hellos = cycle( [ "Hola", "Bonjour", "Guten tag", "Salve", "Nǐn hǎo", "Olá", "Asalaam alaikum", "Konnichiwa", "Anyoung haseyo", ...
59
1,092
textual
docs/examples/guide/widgets/loading01.py
.py
from asyncio import sleep from random import randint from textual import work from textual.app import App, ComposeResult from textual.widgets import DataTable ROWS = [ ("lane", "swimmer", "country", "time"), (4, "Joseph Schooling", "Singapore", 50.39), (2, "Michael Phelps", "United States", 51.14), (5...
55
1,396
textual
docs/examples/guide/widgets/hello03.py
.py
from itertools import cycle from textual.app import App, ComposeResult from textual.widgets import Static hellos = cycle( [ "Hola", "Bonjour", "Guten tag", "Salve", "Nǐn hǎo", "Olá", "Asalaam alaikum", "Konnichiwa", "Anyoung haseyo", ...
48
884
textual
docs/examples/guide/widgets/tooltip02.py
.py
from textual.app import App, ComposeResult from textual.widgets import Button TEXT = """I must not fear. Fear is the mind-killer. Fear is the little-death that brings total obliteration. I will face my fear.""" class TooltipApp(App): CSS = """ Screen { align: center middle; } Tooltip { ...
32
643
textual
docs/examples/guide/widgets/hello01.py
.py
from textual.app import App, ComposeResult, RenderResult from textual.widget import Widget class Hello(Widget): """Display a greeting.""" def render(self) -> RenderResult: return "Hello, [b]World[/b]!" class CustomApp(App): def compose(self) -> ComposeResult: yield Hello() if __name__...
20
372
textual
docs/examples/guide/widgets/checker02.py
.py
from rich.segment import Segment from textual.app import App, ComposeResult from textual.strip import Strip from textual.widget import Widget class CheckerBoard(Widget): """Render an 8x8 checkerboard.""" COMPONENT_CLASSES = { "checkerboard--white-square", "checkerboard--black-square", } ...
56
1,353
textual
docs/examples/guide/widgets/counter01.py
.py
from textual.app import App, ComposeResult, RenderResult from textual.reactive import reactive from textual.widgets import Footer, Static class Counter(Static, can_focus=True): # (1)! """A counter that can be incremented and decremented by pressing keys.""" count = reactive(0) def render(self) -> Rende...
28
630
textual
docs/examples/guide/widgets/fizzbuzz02.py
.py
from rich.table import Table from textual.app import App, ComposeResult from textual.geometry import Size from textual.widgets import Static class FizzBuzz(Static): def on_mount(self) -> None: table = Table("Number", "Fizz?", "Buzz?", expand=True) for n in range(1, 16): fizz = not n %...
36
848
textual
docs/examples/guide/widgets/checker01.py
.py
from rich.segment import Segment from rich.style import Style from textual.app import App, ComposeResult from textual.strip import Strip from textual.widget import Widget class CheckerBoard(Widget): """Render an 8x8 checkerboard.""" def render_line(self, y: int) -> Strip: """Render a line of the wid...
44
1,305
textual
docs/examples/guide/widgets/hello02.py
.py
from textual.app import App, ComposeResult, RenderResult from textual.widget import Widget class Hello(Widget): """Display a greeting.""" def render(self) -> RenderResult: return "Hello, [b]World[/b]!" class CustomApp(App): CSS_PATH = "hello02.tcss" def compose(self) -> ComposeResult: ...
22
403
textual
docs/examples/guide/widgets/hello06.py
.py
from itertools import cycle from textual.app import App, ComposeResult from textual.widgets import Static hellos = cycle( [ "Hola", "Bonjour", "Guten tag", "Salve", "Nǐn hǎo", "Olá", "Asalaam alaikum", "Konnichiwa", "Anyoung haseyo", ...
48
968
textual
docs/examples/guide/widgets/tooltip01.py
.py
from textual.app import App, ComposeResult from textual.widgets import Button TEXT = """I must not fear. Fear is the mind-killer. Fear is the little-death that brings total obliteration. I will face my fear.""" class TooltipApp(App): CSS = """ Screen { align: center middle; } """ def com...
27
546
textual
docs/examples/guide/widgets/checker03.py
.py
from __future__ import annotations from textual.app import App, ComposeResult from textual.geometry import Size from textual.strip import Strip from textual.scroll_view import ScrollView from rich.segment import Segment class CheckerBoard(ScrollView): COMPONENT_CLASSES = { "checkerboard--white-square", ...
65
1,915
textual
docs/examples/guide/widgets/checker04.py
.py
from __future__ import annotations from textual import events from textual.app import App, ComposeResult from textual.geometry import Offset, Region, Size from textual.reactive import var from textual.strip import Strip from textual.scroll_view import ScrollView from rich.segment import Segment from rich.style import...
107
3,622
textual
docs/examples/guide/widgets/fizzbuzz01.py
.py
from rich.table import Table from textual.app import App, ComposeResult from textual.widgets import Static class FizzBuzz(Static): def on_mount(self) -> None: table = Table("Number", "Fizz?", "Buzz?") for n in range(1, 16): fizz = not n % 3 buzz = not n % 5 tab...
31
669
textual
docs/examples/guide/widgets/hello05.py
.py
from itertools import cycle from textual.app import App, ComposeResult from textual.widgets import Static hellos = cycle( [ "Hola", "Bonjour", "Guten tag", "Salve", "Nǐn hǎo", "Olá", "Asalaam alaikum", "Konnichiwa", "Anyoung haseyo", ...
45
863
textual
docs/examples/guide/widgets/counter02.py
.py
from textual.app import App, ComposeResult, RenderResult from textual.reactive import reactive from textual.widgets import Footer, Static class Counter(Static, can_focus=True): """A counter that can be incremented and decremented by pressing keys.""" BINDINGS = [ ("up,k", "change_count(1)", "Incremen...
36
851
textual
docs/examples/guide/reactivity/computed01.py
.py
from textual.app import App, ComposeResult from textual.color import Color from textual.containers import Horizontal from textual.reactive import reactive from textual.widgets import Input, Static class ComputedApp(App): CSS_PATH = "computed01.tcss" red = reactive(0) green = reactive(0) blue = reacti...
48
1,407
textual
docs/examples/guide/reactivity/world_clock01.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...
53
1,372
textual
docs/examples/guide/reactivity/world_clock03.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): clock_time: reactive[datetime] = reactive(datetime.now) def __init_...
50
1,377
textual
docs/examples/guide/reactivity/watch01.py
.py
from textual.app import App, ComposeResult from textual.color import Color, ColorParseError from textual.containers import Grid from textual.reactive import reactive from textual.widgets import Input, Static class WatchApp(App): CSS_PATH = "watch01.tcss" color = reactive(Color.parse("transparent")) # (1)! ...
34
1,027
textual
docs/examples/guide/reactivity/set_reactive02.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,613
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