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/how-to/inline01.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;
}
#clock {
width: auto;
}
"""
def compose(self) -> ComposeResult:
yield Digits("", id="clock")... | 32 | 642 |
textual | docs/examples/how-to/center01.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;
}
"""
def compose(self) -> ComposeResult:
yield Static("Hello, World!")
if __name__ == "__main__":
ap... | 21 | 350 |
textual | docs/examples/how-to/containers06.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... | 35 | 655 |
textual | docs/examples/how-to/layout06.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... | 68 | 1,272 |
textual | docs/examples/how-to/layout01.py | .py | from textual.app import App, ComposeResult
from textual.screen import Screen
from textual.widgets import Placeholder
class Header(Placeholder): # (1)!
pass
class Footer(Placeholder): # (2)!
pass
class TweetScreen(Screen):
def compose(self) -> ComposeResult:
yield Header(id="Header") # (3)!
... | 28 | 523 |
textual | docs/examples/how-to/containers07.py | .py | from textual.app import App, ComposeResult
from textual.containers import HorizontalScroll
from textual.widgets import Placeholder
class Box(Placeholder):
"""Example widget."""
DEFAULT_CSS = """
Box {
width: 16;
height: 8;
}
"""
class ContainerApp(App):
"""Simple app... | 35 | 667 |
textual | docs/examples/how-to/layout05.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... | 54 | 1,049 |
textual | docs/examples/how-to/containers08.py | .py | from textual.app import App, ComposeResult
from textual.containers import Center, Right
from textual.widgets import Placeholder
class Box(Placeholder):
"""Example widget."""
DEFAULT_CSS = """
Box {
width: 16;
height: 5;
}
"""
class ContainerApp(App):
"""Simple app to... | 37 | 732 |
textual | docs/examples/how-to/containers05.py | .py | from textual.app import App, ComposeResult
from textual.containers import HorizontalGroup
from textual.widgets import Placeholder
class Box(Placeholder):
"""Example widget."""
DEFAULT_CSS = """
Box {
width: 16;
height: 8;
}
"""
class ContainerApp(App):
"""Simple app ... | 40 | 784 |
textual | docs/examples/how-to/center03.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;
width: auto;
}
"""
def compos... | 27 | 461 |
textual | docs/examples/styles/scrollbar_size2.py | .py | from textual.app import App
from textual.containers import Horizontal, ScrollableContainer
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... | 29 | 816 |
textual | docs/examples/styles/link_color_hover.py | .py | from textual.app import App
from textual.widgets import Label
class LinkHoverColorApp(App):
CSS_PATH = "link_color_hover.tcss"
def compose(self):
yield Label(
"Visit the [link='https://textualize.io']Textualize[/link] website.",
id="lbl1", # (1)!
)
yield Label... | 30 | 763 |
textual | docs/examples/styles/layout.py | .py | from textual.app import App
from textual.containers import Container
from textual.widgets import Label
class LayoutApp(App):
CSS_PATH = "layout.tcss"
def compose(self):
yield Container(
Label("Layout"),
Label("Is"),
Label("Vertical"),
id="vertical-layou... | 27 | 557 |
textual | docs/examples/styles/link_background.py | .py | from textual.app import App
from textual.widgets import Label
class LinkBackgroundApp(App):
CSS_PATH = "link_background.tcss"
def compose(self):
yield Label(
"Visit the [link='https://textualize.io']Textualize[/link] website.",
id="lbl1", # (1)!
)
yield Label(... | 30 | 762 |
textual | docs/examples/styles/scrollbar_size.py | .py | from textual.app import App
from textual.containers import ScrollableContainer
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, ... | 25 | 658 |
textual | docs/examples/styles/visibility_containers.py | .py | from textual.app import App
from textual.containers import Horizontal, VerticalScroll
from textual.widgets import Placeholder
class VisibilityContainersApp(App):
CSS_PATH = "visibility_containers.tcss"
def compose(self):
yield VerticalScroll(
Horizontal(
Placeholder(),
... | 35 | 828 |
textual | docs/examples/styles/color_auto.py | .py | from textual.app import App
from textual.widgets import Label
class ColorApp(App):
CSS_PATH = "color_auto.tcss"
def compose(self):
yield Label("The quick brown fox jumps over the lazy dog!", id="lbl1")
yield Label("The quick brown fox jumps over the lazy dog!", id="lbl2")
yield Label(... | 19 | 601 |
textual | docs/examples/styles/link_color.py | .py | from textual.app import App
from textual.widgets import Label
class LinkColorApp(App):
CSS_PATH = "link_color.tcss"
def compose(self):
yield Label(
"Visit the [link='https://textualize.io']Textualize[/link] website.",
id="lbl1", # (1)!
)
yield Label(
... | 30 | 747 |
textual | docs/examples/styles/height.py | .py | from textual.app import App
from textual.widget import Widget
class HeightApp(App):
CSS_PATH = "height.tcss"
def compose(self):
yield Widget()
if __name__ == "__main__":
app = HeightApp()
app.run()
| 15 | 227 |
textual | docs/examples/styles/scrollbar_gutter.py | .py | from textual.app import App
from textual.widgets import Static
TEXT = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
I will face my fear.
I will permit it to pass over me and through me.
And when it has gone past, I will turn the inner eye to see its path.
Where t... | 23 | 595 |
textual | docs/examples/styles/display.py | .py | from textual.app import App
from textual.widgets import Static
class DisplayApp(App):
CSS_PATH = "display.tcss"
def compose(self):
yield Static("Widget 1")
yield Static("Widget 2", classes="remove")
yield Static("Widget 3")
if __name__ == "__main__":
app = DisplayApp()
app.r... | 17 | 325 |
textual | docs/examples/styles/outline.py | .py | from textual.app import App
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 path.
Where th... | 23 | 553 |
textual | docs/examples/styles/visibility.py | .py | from textual.app import App
from textual.widgets import Label
class VisibilityApp(App):
CSS_PATH = "visibility.tcss"
def compose(self):
yield Label("Widget 1")
yield Label("Widget 2", classes="invisible")
yield Label("Widget 3")
if __name__ == "__main__":
app = VisibilityApp()
... | 17 | 333 |
textual | docs/examples/styles/border_all.py | .py | from textual.app import App
from textual.containers import Grid
from textual.widgets import Label
class AllBordersApp(App):
CSS_PATH = "border_all.tcss"
def compose(self):
yield Grid(
Label("ascii", id="ascii"),
Label("blank", id="blank"),
Label("dashed", id="dashe... | 33 | 925 |
textual | docs/examples/styles/grid.py | .py | from textual.app import App
from textual.widgets import Static
class GridApp(App):
CSS_PATH = "grid.tcss"
def compose(self):
yield Static("Grid cell 1\n\nrow-span: 3;\ncolumn-span: 2;", id="static1")
yield Static("Grid cell 2", id="static2")
yield Static("Grid cell 3", id="static3")
... | 21 | 582 |
textual | docs/examples/styles/content_align_all.py | .py | from textual.app import App
from textual.widgets import Label
class AllContentAlignApp(App):
CSS_PATH = "content_align_all.tcss"
def compose(self):
yield Label("left top", id="left-top")
yield Label("center top", id="center-top")
yield Label("right top", id="right-top")
yield ... | 23 | 710 |
textual | docs/examples/styles/max_width.py | .py | from textual.app import App
from textual.containers import VerticalScroll
from textual.widgets import Placeholder
class MaxWidthApp(App):
CSS_PATH = "max_width.tcss"
def compose(self):
yield VerticalScroll(
Placeholder("max-width: 50h", id="p1"),
Placeholder("max-width: 999", ... | 21 | 510 |
textual | docs/examples/styles/grid_size_columns.py | .py | from textual.app import App
from textual.containers import Grid
from textual.widgets import Label
class MyApp(App):
CSS_PATH = "grid_size_columns.tcss"
def compose(self):
yield Grid(
Label("1"),
Label("2"),
Label("3"),
Label("4"),
Label("5")... | 22 | 393 |
textual | docs/examples/styles/margin_all.py | .py | from textual.app import App
from textual.containers import Container, Grid
from textual.widgets import Placeholder
class MarginAllApp(App):
CSS_PATH = "margin_all.tcss"
def compose(self):
yield Grid(
Container(Placeholder("no margin", id="p1"), classes="bordered"),
Container(P... | 25 | 951 |
textual | docs/examples/styles/scrollbar_visibility.py | .py | from textual.app import App
from textual.containers import Horizontal, VerticalScroll
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... | 28 | 764 |
textual | docs/examples/styles/link_style_hover.py | .py | from textual.app import App
from textual.widgets import Label
class LinkHoverStyleApp(App):
CSS_PATH = "link_style_hover.tcss"
def compose(self):
yield Label(
"Visit the [link='https://textualize.io']Textualize[/link] website.",
id="lbl1", # (1)!
)
yield Label... | 30 | 763 |
textual | docs/examples/styles/column_span.py | .py | from textual.app import App
from textual.containers import Grid
from textual.widgets import Placeholder
class MyApp(App):
CSS_PATH = "column_span.tcss"
def compose(self):
yield Grid(
Placeholder(id="p1"),
Placeholder(id="p2"),
Placeholder(id="p3"),
Plac... | 24 | 511 |
textual | docs/examples/styles/background_tint.py | .py | from textual.app import App, ComposeResult
from textual.containers import Vertical
from textual.widgets import Label
class BackgroundTintApp(App):
CSS_PATH = "background_tint.tcss"
def compose(self) -> ComposeResult:
with Vertical(id="tint1"):
yield Label("0%")
with Vertical(id="t... | 25 | 631 |
textual | docs/examples/styles/color.py | .py | from textual.app import App
from textual.widgets import Label
class ColorApp(App):
CSS_PATH = "color.tcss"
def compose(self):
yield Label("I'm red!", id="label1")
yield Label("I'm rgb(0, 255, 0)!", id="label2")
yield Label("I'm hsl(240, 100%, 50%)!", id="label3")
if __name__ == "__m... | 17 | 363 |
textual | docs/examples/styles/offset.py | .py | from textual.app import App
from textual.widgets import Label
class OffsetApp(App):
CSS_PATH = "offset.tcss"
def compose(self):
yield Label("Paul (offset 8 2)", classes="paul")
yield Label("Duncan (offset 4 10)", classes="duncan")
yield Label("Chani (offset 0 -3)", classes="chani")
... | 17 | 383 |
textual | docs/examples/styles/grid_gutter.py | .py | from textual.app import App
from textual.containers import Grid
from textual.widgets import Label
class MyApp(App):
CSS_PATH = "grid_gutter.tcss"
def compose(self):
yield Grid(
Label("1"),
Label("2"),
Label("3"),
Label("4"),
Label("5"),
... | 25 | 459 |
textual | docs/examples/styles/keyline_horizontal.py | .py | from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import Placeholder
class KeylineApp(App):
CSS_PATH = "keyline_horizontal.tcss"
def compose(self) -> ComposeResult:
with Horizontal():
yield Placeholder()
yield Placeholder... | 19 | 421 |
textual | docs/examples/styles/scrollbars2.py | .py | from textual.app import App
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 path.
Where th... | 24 | 569 |
textual | docs/examples/styles/row_span.py | .py | from textual.app import App
from textual.containers import Grid
from textual.widgets import Placeholder
class MyApp(App):
CSS_PATH = "row_span.tcss"
def compose(self):
yield Grid(
Placeholder(id="p1"),
Placeholder(id="p2"),
Placeholder(id="p3"),
Placeho... | 24 | 508 |
textual | docs/examples/styles/overflow.py | .py | from textual.app import App
from textual.containers import Horizontal, VerticalScroll
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 gon... | 27 | 788 |
textual | docs/examples/styles/text_style_all.py | .py | from textual.app import App
from textual.containers import Grid
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... | 33 | 1,015 |
textual | docs/examples/styles/keyline.py | .py | from textual.app import App, ComposeResult
from textual.containers import Grid
from textual.widgets import Placeholder
class KeylineApp(App):
CSS_PATH = "keyline.tcss"
def compose(self) -> ComposeResult:
with Grid():
yield Placeholder(id="foo")
yield Placeholder(id="bar")
... | 20 | 488 |
textual | docs/examples/styles/border.py | .py | from textual.app import App
from textual.widgets import Label
class BorderApp(App):
CSS_PATH = "border.tcss"
def compose(self):
yield Label("My border is solid red", id="label1")
yield Label("My border is dashed green", id="label2")
yield Label("My border is tall blue", id="label3")
... | 17 | 384 |
textual | docs/examples/styles/width_comparison.py | .py | from textual.app import App
from textual.containers import Horizontal
from textual.widgets import Label, Placeholder, Static
class Ruler(Static):
def compose(self):
ruler_text = "····•" * 100
yield Label(ruler_text)
class WidthComparisonApp(App):
CSS_PATH = "width_comparison.tcss"
def c... | 33 | 796 |
textual | docs/examples/styles/border_subtitle_align.py | .py | from textual.app import App
from textual.widgets import Label
class BorderSubtitleAlignApp(App):
CSS_PATH = "border_subtitle_align.tcss"
def compose(self):
lbl = Label("My subtitle is on the left.", id="label1")
lbl.border_subtitle = "< Left"
yield lbl
lbl = Label("My subtitl... | 25 | 610 |
textual | docs/examples/styles/align.py | .py | from textual.app import App
from textual.widgets import Label
class AlignApp(App):
CSS_PATH = "align.tcss"
def compose(self):
yield Label("Vertical alignment with [b]Textual[/]", classes="box")
yield Label("Take note, browsers.", classes="box")
if __name__ == "__main__":
app = AlignApp(... | 16 | 336 |
textual | docs/examples/styles/height_comparison.py | .py | from textual.app import App
from textual.containers import VerticalScroll
from textual.widgets import Label, Placeholder, Static
class Ruler(Static):
def compose(self):
ruler_text = "·\n·\n·\n·\n•\n" * 100
yield Label(ruler_text)
class HeightComparisonApp(App):
CSS_PATH = "height_comparison.... | 33 | 817 |
textual | docs/examples/styles/outline_vs_border.py | .py | from textual.app import App
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 path.
Where th... | 25 | 690 |
textual | docs/examples/styles/grid_size_both.py | .py | from textual.app import App
from textual.containers import Grid
from textual.widgets import Label
class MyApp(App):
CSS_PATH = "grid_size_both.tcss"
def compose(self):
yield Grid(
Label("1"),
Label("2"),
Label("3"),
Label("4"),
Label("5"),
... | 22 | 390 |
textual | docs/examples/styles/max_height.py | .py | from textual.app import App
from textual.containers import Horizontal
from textual.widgets import Placeholder
class MaxHeightApp(App):
CSS_PATH = "max_height.tcss"
def compose(self):
yield Horizontal(
Placeholder("max-height: 10w", id="p1"),
Placeholder("max-height: 999", id="... | 21 | 509 |
textual | docs/examples/styles/opacity.py | .py | from textual.app import App
from textual.widgets import Label
class OpacityApp(App):
CSS_PATH = "opacity.tcss"
def compose(self):
yield Label("opacity: 0%", id="zero-opacity")
yield Label("opacity: 25%", id="quarter-opacity")
yield Label("opacity: 50%", id="half-opacity")
yiel... | 19 | 494 |
textual | docs/examples/styles/margin.py | .py | from textual.app import App
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 path.
Where th... | 23 | 550 |
textual | docs/examples/styles/text_wrap.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."""
class WrapApp(App):
CSS_PATH = "text_wrap.tcss"
def compose(self) -> ComposeResult:
yield... | 18 | 452 |
textual | docs/examples/styles/content_align.py | .py | from textual.app import App
from textual.widgets import Label
class ContentAlignApp(App):
CSS_PATH = "content_align.tcss"
def compose(self):
yield Label("With [i]content-align[/] you can...", id="box1")
yield Label("...[b]Easily align content[/]...", id="box2")
yield Label("...Horizon... | 17 | 432 |
textual | docs/examples/styles/text_overflow.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."""
class WrapApp(App):
CSS_PATH = "text_overflow.tcss"
def compose(self) -> ComposeResult:
y... | 19 | 497 |
textual | docs/examples/styles/padding_all.py | .py | from textual.app import App
from textual.containers import Grid
from textual.widgets import Placeholder
class PaddingAllApp(App):
CSS_PATH = "padding_all.tcss"
def compose(self):
yield Grid(
Placeholder("no padding", id="p1"),
Placeholder("padding: 1", id="p2"),
Pl... | 25 | 703 |
textual | docs/examples/styles/min_width.py | .py | from textual.app import App
from textual.containers import VerticalScroll
from textual.widgets import Placeholder
class MinWidthApp(App):
CSS_PATH = "min_width.tcss"
def compose(self):
yield VerticalScroll(
Placeholder("min-width: 25%", id="p1"),
Placeholder("min-width: 75%", ... | 21 | 512 |
textual | docs/examples/styles/border_title_align.py | .py | from textual.app import App
from textual.widgets import Label
class BorderTitleAlignApp(App):
CSS_PATH = "border_title_align.tcss"
def compose(self):
lbl = Label("My title is on the left.", id="label1")
lbl.border_title = "< Left"
yield lbl
lbl = Label("My title is centered",... | 25 | 583 |
textual | docs/examples/styles/grid_columns.py | .py | from textual.app import App
from textual.containers import Grid
from textual.widgets import Label
class MyApp(App):
CSS_PATH = "grid_columns.tcss"
def compose(self):
yield Grid(
Label("1fr"),
Label("width = 16"),
Label("2fr"),
Label("1fr"),
... | 27 | 556 |
textual | docs/examples/styles/border_title_colors.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Label
class BorderTitleApp(App):
CSS_PATH = "border_title_colors.tcss"
def compose(self) -> ComposeResult:
yield Label("Hello, World!")
def on_mount(self) -> None:
label = self.query_one(Label)
label.border_ti... | 20 | 460 |
textual | docs/examples/styles/border_sub_title_align_all.py | .py | from textual.app import App
from textual.containers import Container, Grid
from textual.widgets import Label
def make_label_container( # (11)!
text: str, id: str, border_title: str, border_subtitle: str
) -> Container:
lbl = Label(text, id=id)
lbl.border_title = border_title
lbl.border_subtitle = bor... | 76 | 2,444 |
textual | docs/examples/styles/links.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Static
TEXT = """\
Here is a [@click='app.bell']link[/] which you can click!
"""
class LinksApp(App):
CSS_PATH = "links.tcss"
def compose(self) -> ComposeResult:
yield Static(TEXT)
yield Static(TEXT, id="custom")
if __n... | 20 | 376 |
textual | docs/examples/styles/outline_all.py | .py | from textual.app import App
from textual.containers import Grid
from textual.widgets import Label
class AllOutlinesApp(App):
CSS_PATH = "outline_all.tcss"
def compose(self):
yield Grid(
Label("ascii", id="ascii"),
Label("blank", id="blank"),
Label("dashed", id="das... | 32 | 886 |
textual | docs/examples/styles/box_sizing.py | .py | from textual.app import App
from textual.widgets import Static
class BoxSizingApp(App):
CSS_PATH = "box_sizing.tcss"
def compose(self):
yield Static("I'm using border-box!", id="static1")
yield Static("I'm using content-box!", id="static2")
if __name__ == "__main__":
app = BoxSizingApp(... | 16 | 336 |
textual | docs/examples/styles/min_height.py | .py | from textual.app import App
from textual.containers import Horizontal
from textual.widgets import Placeholder
class MinHeightApp(App):
CSS_PATH = "min_height.tcss"
def compose(self):
yield Horizontal(
Placeholder("min-height: 25%", id="p1"),
Placeholder("min-height: 75%", id="... | 21 | 509 |
textual | docs/examples/styles/padding.py | .py | from textual.app import App
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 path.
Where th... | 23 | 553 |
textual | docs/examples/styles/align_all.py | .py | from textual.app import App, ComposeResult
from textual.containers import Container
from textual.widgets import Label
class AlignAllApp(App):
"""App that illustrates all alignments."""
CSS_PATH = "align_all.tcss"
def compose(self) -> ComposeResult:
yield Container(Label("left top"), id="left-top... | 25 | 894 |
textual | docs/examples/styles/hatch.py | .py | from textual.app import App, ComposeResult
from textual.containers import Horizontal, Vertical
from textual.widgets import Static
HATCHES = ("cross", "horizontal", "custom", "left", "right")
class HatchApp(App):
CSS_PATH = "hatch.tcss"
def compose(self) -> ComposeResult:
with Horizontal():
... | 23 | 577 |
textual | docs/examples/styles/scrollbar_corner_color.py | .py | from textual.app import App
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 path.
Where th... | 24 | 633 |
textual | docs/examples/styles/tint.py | .py | from textual.app import App
from textual.color import Color
from textual.widgets import Label
class TintApp(App):
CSS_PATH = "tint.tcss"
def compose(self):
color = Color.parse("green")
for tint_alpha in range(0, 101, 10):
widget = Label(f"tint: green {tint_alpha}%;")
w... | 20 | 471 |
textual | docs/examples/styles/text_opacity.py | .py | from textual.app import App
from textual.widgets import Label
class TextOpacityApp(App):
CSS_PATH = "text_opacity.tcss"
def compose(self):
yield Label("text-opacity: 0%", id="zero-opacity")
yield Label("text-opacity: 25%", id="quarter-opacity")
yield Label("text-opacity: 50%", id="hal... | 19 | 532 |
textual | docs/examples/styles/link_style.py | .py | from textual.app import App
from textual.widgets import Label
class LinkStyleApp(App):
CSS_PATH = "link_style.tcss"
def compose(self):
yield Label(
"Visit the [link='https://textualize.io']Textualize[/link] website.",
id="lbl1", # (1)!
)
yield Label(
... | 30 | 747 |
textual | docs/examples/styles/width.py | .py | from textual.app import App
from textual.widget import Widget
class WidthApp(App):
CSS_PATH = "width.tcss"
def compose(self):
yield Widget()
if __name__ == "__main__":
app = WidthApp()
app.run()
| 15 | 224 |
textual | docs/examples/styles/scrollbars.py | .py | from textual.app import App
from textual.containers import Horizontal, ScrollableContainer
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... | 28 | 753 |
textual | docs/examples/styles/text_style.py | .py | from textual.app import App
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 path.
Where th... | 25 | 645 |
textual | docs/examples/styles/background_transparency.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Static
class BackgroundTransparencyApp(App):
"""Simple app to exemplify different transparency settings."""
CSS_PATH = "background_transparency.tcss"
def compose(self) -> ComposeResult:
yield Static("10%", id="t10")
y... | 26 | 736 |
textual | docs/examples/styles/grid_rows.py | .py | from textual.app import App
from textual.containers import Grid
from textual.widgets import Label
class MyApp(App):
CSS_PATH = "grid_rows.tcss"
def compose(self):
yield Grid(
Label("1fr"),
Label("1fr"),
Label("height = 6"),
Label("height = 6"),
... | 27 | 553 |
textual | docs/examples/styles/position.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Label
class PositionApp(App):
CSS_PATH = "position.tcss"
def compose(self) -> ComposeResult:
yield Label("Absolute", id="label1")
yield Label("Relative", id="label2")
if __name__ == "__main__":
app = PositionApp()
... | 16 | 332 |
textual | docs/examples/styles/text_align.py | .py | from textual.app import App
from textual.containers import Grid
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."
)
class TextAlign(App... | 27 | 718 |
textual | docs/examples/styles/background.py | .py | from textual.app import App
from textual.widgets import Label
class BackgroundApp(App):
CSS_PATH = "background.tcss"
def compose(self):
yield Label("Widget 1", id="static1")
yield Label("Widget 2", id="static2")
yield Label("Widget 3", id="static3")
if __name__ == "__main__":
ap... | 17 | 354 |
textual | docs/examples/styles/dock_all.py | .py | from textual.app import App
from textual.containers import Container
from textual.widgets import Label
class DockAllApp(App):
CSS_PATH = "dock_all.tcss"
def compose(self):
yield Container(
Container(Label("left"), id="left"),
Container(Label("top"), id="top"),
Cont... | 22 | 516 |
textual | docs/examples/styles/link_background_hover.py | .py | from textual.app import App
from textual.widgets import Label
class LinkHoverBackgroundApp(App):
CSS_PATH = "link_background_hover.tcss"
def compose(self):
yield Label(
"Visit the [link='https://textualize.io']Textualize[/link] website.",
id="lbl1", # (1)!
)
y... | 30 | 778 |
textual | docs/examples/app/question02.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Button, Label
class QuestionApp(App[str]):
CSS_PATH = "question02.tcss"
def compose(self) -> ComposeResult:
yield Label("Do you love Textual?", id="question")
yield Button("Yes", id="yes", variant="primary")
yield ... | 21 | 551 |
textual | docs/examples/app/widgets01.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Welcome
class WelcomeApp(App):
def compose(self) -> ComposeResult:
yield Welcome()
def on_button_pressed(self) -> None:
self.exit()
if __name__ == "__main__":
app = WelcomeApp()
app.run()
| 16 | 296 |
textual | docs/examples/app/simple02.py | .py | from textual.app import App
class MyApp(App):
pass
if __name__ == "__main__":
app = MyApp()
app.run()
| 11 | 118 |
textual | docs/examples/app/question_title01.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Button, Header, Label
class MyApp(App[str]):
CSS_PATH = "question02.tcss"
TITLE = "A Question App"
SUB_TITLE = "The most important question"
def compose(self) -> ComposeResult:
yield Header()
yield Label("Do you lo... | 24 | 645 |
textual | docs/examples/app/question03.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Label, Button
class QuestionApp(App[str]):
CSS = """
Screen {
layout: grid;
grid-size: 2;
grid-gutter: 2;
padding: 2;
}
#question {
width: 100%;
height: 100%;
column-span: 2;
... | 39 | 841 |
textual | docs/examples/app/widgets04.py | .py | from textual.app import App
from textual.widgets import Button, Welcome
class WelcomeApp(App):
async def on_key(self) -> None:
await self.mount(Welcome())
self.query_one(Button).label = "YES!"
if __name__ == "__main__":
app = WelcomeApp()
app.run()
| 14 | 281 |
textual | docs/examples/app/widgets02.py | .py | from textual.app import App
from textual.widgets import Welcome
class WelcomeApp(App):
def on_key(self) -> None:
self.mount(Welcome())
def on_button_pressed(self) -> None:
self.exit()
if __name__ == "__main__":
app = WelcomeApp()
app.run()
| 16 | 277 |
textual | docs/examples/app/question01.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Label, Button
class QuestionApp(App[str]):
def compose(self) -> ComposeResult:
yield Label("Do you love Textual?")
yield Button("Yes", id="yes", variant="primary")
yield Button("No", id="no", variant="error")
def o... | 19 | 502 |
textual | docs/examples/app/simple01.py | .py | from textual.app import App
class MyApp(App):
pass
| 6 | 57 |
textual | docs/examples/app/widgets03.py | .py | from textual.app import App
from textual.widgets import Button, Welcome
class WelcomeApp(App):
def on_key(self) -> None:
self.mount(Welcome())
self.query_one(Button).label = "YES!"
if __name__ == "__main__":
app = WelcomeApp()
app.run()
| 14 | 269 |
textual | docs/examples/app/event01.py | .py | from textual.app import App
from textual import events
class EventApp(App):
COLORS = [
"white",
"maroon",
"red",
"purple",
"fuchsia",
"olive",
"yellow",
"navy",
"teal",
"aqua",
]
def on_mount(self) -> None:
self.scre... | 31 | 574 |
textual | docs/examples/app/question_title02.py | .py | from textual.app import App, ComposeResult
from textual.events import Key
from textual.widgets import Button, Header, Label
class MyApp(App[str]):
CSS_PATH = "question02.tcss"
TITLE = "A Question App"
SUB_TITLE = "The most important question"
def compose(self) -> ComposeResult:
yield Header()... | 29 | 800 |
textual | docs/examples/app/suspend.py | .py | from os import system
from textual import on
from textual.app import App, ComposeResult
from textual.widgets import Button
class SuspendingApp(App[None]):
def compose(self) -> ComposeResult:
yield Button("Open the editor", id="edit")
@on(Button.Pressed, "#edit")
def run_external_editor(self) ->... | 21 | 445 |
textual | docs/examples/app/suspend_process.py | .py | from textual.app import App, ComposeResult
from textual.binding import Binding
from textual.widgets import Label
class SuspendKeysApp(App[None]):
BINDINGS = [Binding("ctrl+z", "suspend_process")]
def compose(self) -> ComposeResult:
yield Label("Press Ctrl+Z to suspend!")
if __name__ == "__main__":... | 16 | 348 |
textual | tests/test_partition.py | .py | from textual._partition import partition
def test_partition():
def is_odd(value: int) -> bool:
return bool(value % 2)
def is_greater_than_five(value: int) -> bool:
return value > 5
assert partition(is_odd, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == (
[2, 4, 6, 8, 10],
[1, 3, 5, ... | 28 | 778 |
textual | tests/test_concurrency.py | .py | from threading import Thread
import pytest
from textual.app import App, ComposeResult
from textual.widgets import RichLog
def test_call_from_thread_app_not_running():
app = App()
# Should fail if app is not running
with pytest.raises(RuntimeError):
app.call_from_thread(print)
def test_call_fr... | 55 | 1,634 |
textual | tests/test_node_list.py | .py | import pytest
from textual._node_list import NodeList
from textual.widget import Widget
def test_empty_list():
"""Does an empty node list report as being empty?"""
assert len(NodeList()) == 0
async def test_add_one():
"""Does adding a node to the node list report as having one item?"""
nodes = Node... | 114 | 2,824 |
textual | tests/test_markdownviewer.py | .py | from pathlib import Path
import pytest
from rich.text import Text
import textual.widgets._markdown as MD
from textual.app import App, ComposeResult
from textual.content import Content
from textual.geometry import Offset
from textual.widgets import Markdown, MarkdownViewer, Tree
TEST_MARKDOWN = """\
* [First]({{file}... | 92 | 3,272 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.