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
tests/tree/test_tree_node_label.py
.py
from rich.text import Text from textual.widgets import Tree from textual.widgets.tree import TreeNode async def test_tree_node_label() -> None: """It should be possible to modify a TreeNode's label.""" node = TreeNode(Tree[None]("Xenomorph Lifecycle"), None, 0, "Facehugger") assert node.label == Text("Fa...
22
750
textual
tests/tree/test_tree_node_parent.py
.py
from textual.widgets import Tree async def test_tree_node_parent() -> None: """It should be possible to access a TreeNode's parent.""" tree = Tree[None]("Anakin") child = tree.root.add("Leia") grandchild = child.add("Ben") assert tree.root.parent is None assert grandchild.parent == child a...
12
352
textual
tests/tree/test_tree_node_add.py
.py
import pytest from textual.widgets import Tree from textual.widgets.tree import AddNodeError async def test_tree_node_add_before_and_after_raises_exception(): tree = Tree[None]("root") with pytest.raises(AddNodeError): tree.root.add("error", before=99, after=0) async def test_tree_node_add_before_o...
121
4,724
textual
tests/tree/test_tree_get_node_by_id.py
.py
from typing import cast import pytest from textual.widgets import Tree from textual.widgets.tree import NodeID, UnknownNodeID async def test_get_tree_node_by_id() -> None: """It should be possible to get a TreeNode by its ID.""" tree = Tree[None]("Anakin") child = tree.root.add("Leia") grandchild = ...
19
626
textual
tests/tree/test_tree_cursor.py
.py
from __future__ import annotations from typing import Any from textual import on from textual.app import App, ComposeResult from textual.widgets import Tree from textual.widgets.tree import NodeID, TreeNode class TreeApp(App[None]): def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__...
103
3,614
textual
tests/tree/test_tree_clearing.py
.py
from __future__ import annotations import pytest from textual.app import App, ComposeResult from textual.widgets import Tree from textual.widgets.tree import RemoveRootError class VerseBody: pass class VerseStar(VerseBody): pass class VersePlanet(VerseBody): pass class VerseMoon(VerseBody): pa...
111
3,558
textual
tests/tree/test_tree_availability.py
.py
from __future__ import annotations from typing import Any from textual import on from textual.app import App, ComposeResult from textual.widgets import Tree class TreeApp(App[None]): """Test tree app.""" def __init__(self, disabled: bool, *args: Any, **kwargs: Any) -> None: super().__init__(*args, ...
129
4,240
textual
tests/listview/test_inherit_listview.py
.py
from textual.app import App, ComposeResult from textual.binding import Binding from textual.widgets import Label, ListItem, ListView class MyListView(ListView): """Test child class of a ListView.""" BINDINGS = [Binding(key="s", action="set", description="Set")] def __init__(self, items: int = 0) -> None...
61
1,993
textual
tests/listview/test_listview_navigation.py
.py
from textual.app import App, ComposeResult from textual.widgets import Label, ListItem, ListView class ListViewDisabledItemsApp(App[None]): def compose(self) -> ComposeResult: self.highlighted = [] yield ListView( ListItem(Label("0"), disabled=True), ListItem(Label("1")), ...
46
1,357
textual
tests/listview/test_listview_remove_items.py
.py
from __future__ import annotations import pytest from textual.app import App, ComposeResult from textual.widgets import Label, ListItem, ListView class EmptyListViewApp(App[None]): def compose(self) -> ComposeResult: yield ListView() async def test_listview_pop_empty_raises_index_error(): app = Em...
117
4,121
textual
tests/listview/test_listview_initial_index.py
.py
import pytest from textual.app import App, ComposeResult from textual.widgets import Label, ListItem, ListView @pytest.mark.parametrize( "initial_index,expected_index", [ (0, 1), (1, 1), (2, 4), (3, 4), (4, 4), (5, 5), (6, 7), (7, 7), (8...
43
1,266
textual
tests/utilities/render.py
.py
import io import re from rich.console import Console, RenderableType re_link_ids = re.compile(r"id=[\d\.\-]*?;.*?\x1b") def replace_link_ids(render: str) -> str: """Link IDs have a random ID and system path which is a problem for reproducible tests. """ return re_link_ids.sub("id=0;foo\x1b", render)...
24
669
textual
tests/css/test_styles.py
.py
from decimal import Decimal import pytest from rich.style import Style from textual.color import Color from textual.css.errors import StyleValueError from textual.css.scalar import Scalar, Unit from textual.css.styles import RenderStyles, Styles from textual.dom import DOMNode from textual.widget import Widget def ...
206
6,201
textual
tests/css/test_stylesheet.py
.py
from contextlib import nullcontext as does_not_raise import pytest from textual.color import Color from textual.css.stylesheet import CssSource, Stylesheet, StylesheetParseError from textual.css.tokenizer import TokenError from textual.dom import DOMNode from textual.geometry import Spacing from textual.widget import...
296
10,099
textual
tests/css/test_screen_css.py
.py
from textual.app import App from textual.color import Color from textual.screen import Screen from textual.widgets import Label RED = Color(255, 0, 0) GREEN = Color(0, 255, 0) BLUE = Color(0, 0, 255) class BaseScreen(Screen): def compose(self): yield Label("Hello, world!", id="app-css") yield Lab...
309
8,637
textual
tests/css/test_css_reloading.py
.py
import os from pathlib import Path from textual.app import App, ComposeResult from textual.screen import Screen from textual.widgets import Label CSS_PATH = (Path(__file__) / "../css_reloading.tcss").resolve() class BaseScreen(Screen[None]): def compose(self) -> ComposeResult: yield Label("I am the base...
87
2,368
textual
tests/css/test_grid_rows_columns_relative_units.py
.py
""" Regression tests for #1406 https://github.com/Textualize/textual/issues/1406 The scalars in grid-rows and grid-columns were not aware of the dimension they should be relative to. """ from textual.css.parse import parse_declarations from textual.css.scalar import Unit from textual.css.styles import Styles def te...
43
1,285
textual
tests/css/test_mega_stylesheet.py
.py
from pathlib import Path from textual.css.stylesheet import Stylesheet def test_mega_stylesheet() -> None: """It should be possible to load a known-good stylesheet.""" mega_stylesheet = Stylesheet() mega_stylesheet.read(Path(__file__).parent / "test_mega_stylesheet.tcss") mega_stylesheet.parse() ...
12
381
textual
tests/css/test_scalar.py
.py
from textual.css.scalar import Scalar, Unit def test_copy_with_value(): old = Scalar(1, Unit.HEIGHT, Unit.CELLS) new = old.copy_with(value=2) assert new == Scalar(2, Unit.HEIGHT, Unit.CELLS) def test_copy_with_unit(): old = Scalar(1, Unit.HEIGHT, Unit.CELLS) new = old.copy_with(unit=Unit.WIDTH) ...
20
562
textual
tests/css/test_parse.py
.py
from __future__ import annotations import pytest from textual.color import Color from textual.css.errors import UnresolvedVariableError from textual.css.parse import is_id_selector, substitute_references from textual.css.scalar import Scalar, Unit from textual.css.stylesheet import Stylesheet, StylesheetParseError fr...
1,299
38,905
textual
tests/css/test_tokenize.py
.py
from __future__ import annotations import pytest from textual.css.tokenize import tokenize from textual.css.tokenizer import Token, TokenError VALID_VARIABLE_NAMES = [ "warning-text", "warning_text", "warningtext1", "1warningtext", "WarningText1", "warningtext_", "warningtext-", "_war...
981
24,422
textual
tests/css/test_help_text.py
.py
import pytest from tests.utilities.render import render from textual.css._help_text import ( align_help_text, border_property_help_text, color_property_help_text, fractional_property_help_text, layout_property_help_text, offset_property_help_text, offset_single_axis_help_text, scalar_he...
128
4,015
textual
tests/css/test_programmatic_style_changes.py
.py
import pytest from textual.app import App from textual.containers import Grid from textual.widgets import Label @pytest.mark.parametrize( "style, value", [ ("grid_size_rows", 3), ("grid_size_columns", 3), ("grid_gutter_vertical", 4), ("grid_gutter_horizontal", 4), ("gr...
95
2,610
textual
tests/css/test_inheritance.py
.py
import pytest from textual.app import App, ComposeResult from textual.color import Color from textual.widget import Widget class Widget1(Widget): DEFAULT_CSS = """ Widget1 { background: red; } """ class Widget2(Widget1): DEFAULT_CSS = """ Widget1 { background: green; } ...
40
892
textual
tests/css/test_initial.py
.py
from textual.app import App, ComposeResult from textual.color import Color from textual.widget import Widget class Base(Widget): DEFAULT_CSS = """ Base { color: magenta; } """ class CustomWidget1(Base): DEFAULT_CSS = """ CustomWidget1 { background: red } """ class C...
96
2,380
textual
tests/css/test_nested_css.py
.py
from __future__ import annotations import pytest from textual.app import App, ComposeResult from textual.color import Color from textual.containers import Vertical from textual.css.parse import parse from textual.css.tokenizer import TokenError, UnexpectedEnd from textual.widgets import Button, Label class NestedAp...
186
5,622
textual
tests/directory_tree/test_early_show_root.py
.py
from textual.app import App, ComposeResult from textual.widgets import DirectoryTree class DirectoryTreeApp(App[None]): def compose(self) -> ComposeResult: tree = DirectoryTree(".") tree.show_root = True yield tree async def test_managed_to_set_show_root_before_mounted() -> None: """...
17
573
textual
tests/directory_tree/test_change_path.py
.py
from pathlib import Path from textual.app import App, ComposeResult from textual.widgets import DirectoryTree class DirectoryTreeApp(App[None]): def compose(self) -> ComposeResult: yield DirectoryTree(".") async def test_change_directory_tree_path(tmpdir: Path) -> None: """The DirectoryTree should...
21
646
textual
tests/command_palette/test_worker_interference.py
.py
"""Tests for https://github.com/Textualize/textual/issues/3615""" from asyncio import sleep from textual import work from textual.app import App from textual.command import Hit, Hits, Provider class SimpleSource(Provider): async def search(self, query: str) -> Hits: def goes_nowhere_does_nothing() -> No...
51
1,480
textual
tests/command_palette/test_run_on_select.py
.py
from functools import partial from textual.app import App from textual.command import CommandPalette, Hit, Hits, Provider from textual.widgets import Input class SimpleSource(Provider): async def search(self, _: str) -> Hits: def goes_nowhere_does_nothing(selection: int) -> None: assert isins...
68
2,390
textual
tests/command_palette/test_no_results.py
.py
from textual.app import App from textual.command import CommandPalette from textual.widgets import OptionList class CommandPaletteApp(App[None]): COMMANDS = set() def on_mount(self) -> None: self.action_command_palette() async def test_no_results() -> None: """Receiving no results from a search...
28
1,066
textual
tests/command_palette/test_declare_sources.py
.py
from textual.app import App from textual.command import CommandPalette, Hit, Hits, Provider from textual.screen import Screen from textual.system_commands import SystemCommandsProvider async def test_sources_with_no_known_screen() -> None: """A command palette with no known screen should have an empty source set....
101
3,288
textual
tests/command_palette/test_click_away.py
.py
from textual.app import App from textual.command import CommandPalette, Hit, Hits, Provider class SimpleSource(Provider): async def search(self, query: str) -> Hits: def goes_nowhere_does_nothing() -> None: pass yield Hit(1, query, goes_nowhere_does_nothing, query) class CommandPale...
26
792
textual
tests/command_palette/test_events.py
.py
from typing import Union from unittest import mock from textual import on from textual.app import App from textual.command import CommandPalette, Hit, Hits, Provider CommandPaletteEvent = Union[ CommandPalette.Opened, CommandPalette.Closed, CommandPalette.OptionHighlighted ] class SimpleSource(Provider): as...
76
2,153
textual
tests/command_palette/test_discover.py
.py
from textual.app import App from textual.command import CommandPalette, DiscoveryHit, Hit, Hits, Provider from textual.widgets import OptionList class SimpleSource(Provider): async def discover(self) -> Hits: def goes_nowhere_does_nothing() -> None: pass yield DiscoveryHit("XD-1", go...
35
1,052
textual
tests/command_palette/test_escaping.py
.py
from textual.app import App from textual.command import CommandPalette, Hit, Hits, Provider class SimpleSource(Provider): async def search(self, query: str) -> Hits: def goes_nowhere_does_nothing() -> None: pass yield Hit(1, query, goes_nowhere_does_nothing, query) class CommandPale...
26
781
textual
tests/command_palette/test_command_source_environment.py
.py
from __future__ import annotations from textual.app import App, ComposeResult from textual.command import Hit, Hits, Provider from textual.screen import Screen from textual.widget import Widget from textual.widgets import Input class SimpleSource(Provider): environment: set[tuple[App, Screen, Widget | None]] = s...
41
1,247
textual
tests/command_palette/test_interaction.py
.py
from textual.app import App from textual.command import CommandList, CommandPalette, Hit, Hits, Provider class SimpleSource(Provider): async def search(self, query: str) -> Hits: def goes_nowhere_does_nothing() -> None: pass for _ in range(100): yield Hit(1, query, goes_no...
54
2,190
textual
tests/workers/test_worker_manager.py
.py
import asyncio import time from textual.app import App, ComposeResult from textual.widget import Widget from textual.worker import Worker, WorkerState def test_worker_manager_init(): app = App() assert isinstance(repr(app.workers), str) assert not bool(app.workers) assert len(app.workers) == 0 as...
134
3,619
textual
tests/workers/test_work_decorator.py
.py
import asyncio from time import sleep from typing import Callable, List, Tuple import pytest from textual import work from textual._work_decorator import WorkerDeclarationError from textual.app import App from textual.worker import Worker, WorkerState, WorkType class WorkApp(App): worker: Worker def __init...
187
6,140
textual
tests/workers/test_worker.py
.py
import asyncio import pytest from textual.app import App from textual.worker import ( DeadlockError, NoActiveWorker, Worker, WorkerCancelled, WorkerError, WorkerFailed, WorkerState, get_current_worker, ) async def test_initialize(): """Test initial values.""" def foo() -> st...
238
6,227
textual
tests/footer/test_footer.py
.py
from textual.app import App, ComposeResult from textual.binding import Binding from textual.widget import Widget from textual.widgets import Button, Footer async def test_footer_bindings() -> None: app_binding_count = 0 class TestWidget(Widget, can_focus=True): BINDINGS = [ Binding("b", "...
67
1,908
textual
tests/select/test_remove.py
.py
from textual.app import App, ComposeResult from textual.widgets import Header, Select LINES = """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.""".splitlines() async def test_select_remove(): ...
26
824
textual
tests/select/test_value.py
.py
import pytest from textual.app import App from textual.widgets import Select from textual.widgets.select import InvalidSelectValueError SELECT_OPTIONS = [(str(n), n) for n in range(3)] MORE_OPTIONS = [(str(n), n) for n in range(5, 8)] class SelectApp(App[None]): def __init__(self, initial_value=Select.NULL): ...
128
3,893
textual
tests/select/test_changed_message.py
.py
from textual import on from textual.app import App from textual.widgets import Select from textual.widgets._select import SelectOverlay class SelectApp(App[None]): def __init__(self): self.changed_messages = [] super().__init__() def compose(self): yield Select[int]([(str(n), n) for n...
68
2,082
textual
tests/select/test_prompt.py
.py
from rich.text import Text from textual.app import App from textual.widgets import Select, Static from textual.widgets._select import SelectCurrent, SelectOverlay async def test_reactive_prompt_change(): """Regression test for https://github.com/Textualize/textual/issues/2983""" class SelectApp(App): ...
55
1,962
textual
tests/select/test_blank_and_clear.py
.py
import pytest from textual.app import App from textual.widgets import Select from textual.widgets.select import InvalidSelectValueError SELECT_OPTIONS = [(str(n), n) for n in range(3)] async def test_value_is_blank_by_default(): class SelectApp(App[None]): def compose(self): yield Select(SEL...
77
2,055
textual
tests/select/test_empty_select.py
.py
import pytest from textual.app import App from textual.widgets import Select from textual.widgets.select import EmptySelectError async def test_empty_select_is_ok_with_blanks(): class SelectApp(App[None]): def compose(self): yield Select([]) app = SelectApp() async with app.run_test(...
54
1,546
textual
tests/snapshot_tests/language_snippets.py
.py
PYTHON = """\ import math from os import path # I'm a comment :) string_var = "Hello, world!" int_var = 42 float_var = 3.14 complex_var = 1 + 2j list_var = [1, 2, 3, 4, 5] tuple_var = (1, 2, 3, 4, 5) set_var = {1, 2, 3, 4, 5} dict_var = {"a": 1, "b": 2, "c": 3} def function_no_args(): return "No arguments" def...
958
19,198
textual
tests/snapshot_tests/test_snapshots.py
.py
from __future__ import annotations import asyncio from pathlib import Path import pytest from rich.panel import Panel from rich.text import Text from tests.snapshot_tests.language_snippets import SNIPPETS from textual import events from textual._on import on from textual import work from textual.app import App, Comp...
4,997
148,164
textual
tests/snapshot_tests/snapshot_apps/scroll_to.py
.py
from textual.app import App, ComposeResult from textual.widgets import Checkbox, Footer class ScrollOffByOne(App): """Scroll to item 50.""" AUTO_FOCUS = None def compose(self) -> ComposeResult: for number in range(1, 100): yield Checkbox(str(number), id=f"number-{number}") yi...
22
486
textual
tests/snapshot_tests/snapshot_apps/programmatic_disable_button.py
.py
from textual.app import App, ComposeResult from textual.containers import Center from textual.widgets import Button, Footer, Label class ExampleApp(App): CSS = """ Screen { align: center middle; } """ BINDINGS = [("space", "toggle_button", "Toggle Button")] def compose(self) -> Compo...
36
900
textual
tests/snapshot_tests/snapshot_apps/nested_specificity.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class BaseTester(Static, can_focus=True): DEFAULT_CSS = """ BaseTester:focus { background: yellow; border: thick magenta; } """ class NonNestedCSS(BaseTester): DEFAULT_CSS = """ NonNestedCSS { ...
63
1,151
textual
tests/snapshot_tests/snapshot_apps/auto-table.py
.py
from textual.app import App from textual.containers import Container, Horizontal, ScrollableContainer, Vertical from textual.screen import Screen from textual.widgets import DataTable, Header, Label class LabeledBox(Container): DEFAULT_CSS = """ LabeledBox { layers: base_ top_; width: 100%; ...
188
3,818
textual
tests/snapshot_tests/snapshot_apps/footer_toggle_compact.py
.py
from textual.app import App, ComposeResult from textual.widgets import Footer, Label class ToggleCompactFooterApp(App): CSS = """ Screen { align: center middle; } """ BINDINGS = [ ("ctrl+t", "toggle_compact_footer", "Toggle Compact Footer"), ] def compose(self) -> Compose...
34
835
textual
tests/snapshot_tests/snapshot_apps/auto_grid_default_height.py
.py
from __future__ import annotations from typing import Type from textual.app import App, ComposeResult from textual.containers import Container, Horizontal, Vertical, Grid from textual.widgets import Header, Footer, Label from textual.binding import Binding class GridHeightAuto(App[None]): CSS = """ #test-are...
59
1,522
textual
tests/snapshot_tests/snapshot_apps/datatable_hot_reloading.py
.py
from pathlib import Path from textual.app import App, ComposeResult from textual.widgets import DataTable CSS_PATH = (Path(__file__) / "../datatable_hot_reloading.tcss").resolve() # Write some CSS to the file before the app loads. # Then, the test will clear all the CSS to see if the # hot reloading applies the chan...
59
1,260
textual
tests/snapshot_tests/snapshot_apps/split.py
.py
from textual.app import App, ComposeResult from textual.widgets import Placeholder class SplitApp(App): CSS = """ #split1 { split: right; width: 20; } #split2 { split: bottom; height: 10; } #split3 { split: top; height: 6; } #split4 {...
49
946
textual
tests/snapshot_tests/snapshot_apps/command_palette_dismiss.py
.py
from textual.app import App, ComposeResult from textual.widgets import Label class CPApp(App): def compose(self) -> ComposeResult: yield Label("Command palette test app") if __name__ == "__main__": app = CPApp() app.run()
13
246
textual
tests/snapshot_tests/snapshot_apps/data_table_auto_height.py
.py
from textual.app import App, ComposeResult from textual.widgets import DataTable, Label LORUM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." class ExampleApp(App): CSS = """ Screen { DataTable { ...
39
1,014
textual
tests/snapshot_tests/snapshot_apps/command_palette_discovery.py
.py
from textual.app import App from textual.command import DiscoveryHit, Hit, Hits, Provider class TestSource(Provider): def goes_nowhere_does_nothing(self) -> None: pass async def discover(self) -> Hits: for n in range(10): command = f"This is a test of this code {n}" yi...
39
991
textual
tests/snapshot_tests/snapshot_apps/dock_scroll_off_by_one.py
.py
from textual.app import App, ComposeResult from textual.widgets import Checkbox, Footer class ScrollOffByOne(App): AUTO_FOCUS = None def compose(self) -> ComposeResult: for number in range(1, 100): yield Checkbox(str(number)) yield Footer() def on_mount(self) -> None: ...
20
412
textual
tests/snapshot_tests/snapshot_apps/visibility.py
.py
from textual.app import App from textual.containers import VerticalScroll from textual.widgets import Static class Visibility(App): """Check that visibility: hidden also makes children invisible;""" CSS = """ Screen { layout: horizontal; } VerticalScroll { width: 1fr; ...
48
961
textual
tests/snapshot_tests/snapshot_apps/listview_index.py
.py
from textual.app import App, ComposeResult from textual.reactive import reactive from textual.widgets import Label, ListItem, ListView class ListViewIndexApp(App): CSS = """ ListView { height: 10; } """ data = reactive(list(range(6))) def __init__(self) -> None: super().__ini...
36
831
textual
tests/snapshot_tests/snapshot_apps/tree_clearing.py
.py
from textual.app import App, ComposeResult from textual.widgets import Tree class TreeClearingSnapshotApp(App[None]): CSS = """ Screen { layout: horizontal; } """ @staticmethod def _populate(tree: Tree) -> Tree: for n in range(5): branch = tree.root.add(str(n)) ...
31
805
textual
tests/snapshot_tests/snapshot_apps/markdown_theme_switcher.py
.py
from textual.app import App, ComposeResult from textual.widgets import Markdown TEST_CODE_MARKDOWN = """ # This is a H1 ```python def main(): print("Hello world!") ``` """ class MarkdownThemeSwitcherApp(App[None]): BINDINGS = [ ("t", "toggle_theme"), ("d", "switch_dark"), ("l", "switc...
37
877
textual
tests/snapshot_tests/snapshot_apps/zero_scrollbar_size.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class TestApp(App): DEFAULT_CSS = """ Screen { scrollbar-size: 0 0; } """ def compose(self) -> ComposeResult: yield Static("Hello, world!\n" * 100) if __name__ == "__main__": TestApp().run()
18
314
textual
tests/snapshot_tests/snapshot_apps/table_markup.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static from rich.table import Table class TableStaticApp(App): def compose(self) -> ComposeResult: table = Table("[i green]Foo", "Bar", "baz") table.add_row("Hello [bold magenta]World!", "[i]Italic", "[u]Underline") yi...
17
408
textual
tests/snapshot_tests/snapshot_apps/horizontal_auto_width.py
.py
from textual.app import App, ComposeResult from textual.containers import Horizontal from textual.widgets import Static class HorizontalAutoWidth(App): """ Checks that the auto width of the parent Horizontal is correct. """ def compose(self) -> ComposeResult: yield Horizontal( Sta...
24
652
textual
tests/snapshot_tests/snapshot_apps/enter_or_leave.py
.py
from textual import on from textual.app import App, ComposeResult from textual.widgets import Label from textual.widget import Widget from textual import events class MyWidget(Widget): def compose(self) -> ComposeResult: yield Label("Foo", id="foo") yield Label("Bar") @on(events.Enter) @o...
45
849
textual
tests/snapshot_tests/snapshot_apps/richlog_width.py
.py
from textual.app import App, ComposeResult from textual.events import Resize from textual.widgets import RichLog from rich.text import Text class RichLogWidth(App[None]): def compose(self) -> ComposeResult: rich_log = RichLog(min_width=20) rich_log.display = False rich_log.write( ...
34
1,120
textual
tests/snapshot_tests/snapshot_apps/dev_previews_easing.py
.py
from textual_dev.previews import EasingApp app = EasingApp() if __name__ == "__main__": app.run()
6
103
textual
tests/snapshot_tests/snapshot_apps/mount_style_fix.py
.py
from textual import __version__ from textual.app import App, ComposeResult from textual.widgets import Static # Regression test for https://github.com/Textualize/textual/issues/3858 class BrokenClassesApp(App[None]): CSS = """ Screen { align: center middle; } Static { width: 50%; ...
33
669
textual
tests/snapshot_tests/snapshot_apps/loading.py
.py
from rich.console import RenderableType from textual.app import App, ComposeResult from textual.containers import Horizontal from textual.widget import Widget from textual.widgets import OptionList class SimpleLoadingIndicator(Widget): """A loading indicator that doesn't animate.""" DEFAULT_CSS = """ Si...
57
1,402
textual
tests/snapshot_tests/snapshot_apps/border_alpha.py
.py
from textual.app import App, ComposeResult from textual.containers import Vertical from textual.widgets import Label class BorderAlphaApp(App[None]): CSS = """ .boxes { height: 3; width: 100%; } #box0 { border: heavy green 0%; } #box1 { border: heavy gre...
41
771
textual
tests/snapshot_tests/snapshot_apps/layer_fix.py
.py
from textual.app import App, ComposeResult from textual.containers import Vertical from textual.widgets import Header, Footer, Label from textual.binding import Binding class Dialog(Vertical): def compose(self) -> ComposeResult: """Compose the child widgets.""" yield Label("This should not cause a...
49
1,034
textual
tests/snapshot_tests/snapshot_apps/viewport_units.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class ViewportUnits(App): CSS = """Static {width: 100vw; height: 100vh; border: solid cyan;} """ def compose(self) -> ComposeResult: yield Static("Hello, world!") app = ViewportUnits() if __name__ == '__main__': app.r...
15
325
textual
tests/snapshot_tests/snapshot_apps/button_multiline_label.py
.py
from textual.app import App, ComposeResult from textual.widgets import Button class ButtonWithMultilineLabelApp(App): def compose(self) -> ComposeResult: yield Button("Button\nwith\nmulti-line\nlabel") if __name__ == "__main__": app = ButtonWithMultilineLabelApp() app.run()
13
299
textual
tests/snapshot_tests/snapshot_apps/auto_width_input.py
.py
from textual.app import App, ComposeResult from textual.widgets import Header, Footer, Input class InputWidthAutoApp(App[None]): CSS = """ Input.auto { width: auto; max-width: 100%; } """ def compose(self) -> ComposeResult: yield Header() yield Input(placeholder="T...
21
439
textual
tests/snapshot_tests/snapshot_apps/data_table_cell_padding.py
.py
from textual.app import App, ComposeResult from textual.widgets import DataTable class TableApp(App): CSS = """ DataTable { margin: 1; } """ def compose(self) -> ComposeResult: for cell_padding in range(5): dt = DataTable(cell_padding=cell_padding) dt.add_c...
29
633
textual
tests/snapshot_tests/snapshot_apps/alignment_containers.py
.py
""" App to test alignment containers. """ from textual.app import App, ComposeResult from textual.containers import Center, Middle from textual.widgets import Button class AlignContainersApp(App[None]): CSS = """ Center { tint: $primary 10%; } Middle { tint: $accent 10%; } """...
30
562
textual
tests/snapshot_tests/snapshot_apps/recompose.py
.py
from __future__ import annotations from textual.app import App, ComposeResult from textual.containers import Horizontal, Vertical from textual.reactive import reactive from textual.widgets import Digits, ProgressBar class Numbers(Vertical): DEFAULT_CSS = """ Digits { border: red; } """ d...
57
1,447
textual
tests/snapshot_tests/snapshot_apps/rules.py
.py
from textual.app import App, ComposeResult from textual.containers import Horizontal, Vertical from textual.widgets import Rule RULE_STYLES = [ "ascii", "blank", "dashed", "double", "heavy", "hidden", "none", "solid", "thick", ] class RuleApp(App): def compose(self) -> Compose...
31
628
textual
tests/snapshot_tests/snapshot_apps/button_widths.py
.py
from textual.app import App, ComposeResult from textual.containers import Horizontal from textual.widgets import Button class HorizontalWidthAutoApp(App[None]): CSS = """ Horizontal { border: solid red; height: auto; width: auto; } """ def compose(self) -> ComposeResult: ...
26
631
textual
tests/snapshot_tests/snapshot_apps/layout_containers.py
.py
""" App to test layout containers. """ from typing import Iterable from textual.app import App, ComposeResult from textual.containers import ( Grid, Horizontal, HorizontalScroll, Vertical, VerticalScroll, ) from textual.widget import Widget from textual.widgets import Button, Input, Label def su...
57
1,171
textual
tests/snapshot_tests/snapshot_apps/masked_input.py
.py
from textual.app import App, ComposeResult from textual.widgets import MaskedInput class TemplateApp(App[None]): def compose(self) -> ComposeResult: yield MaskedInput(">NNNNN-NNNNN-NNNNN-NNNNN;_") yield MaskedInput("9999-99-99", placeholder="YYYY-MM-DD") if __name__ == "__main__": app = Temp...
13
343
textual
tests/snapshot_tests/snapshot_apps/vertical_max_height.py
.py
from textual.app import App, ComposeResult from textual.containers import Vertical from textual.widgets import Placeholder class VerticalApp(App): CSS = """ #top { height: 1fr; border: white; } #bottom { height:3fr; border: white; max-height: 10; } ...
27
529
textual
tests/snapshot_tests/snapshot_apps/toggle_style_order.py
.py
from textual.app import App from textual.widgets import Checkbox, Label class CheckboxApp(App): CSS = """ Checkbox > .toggle--label, Label { color: white; text-opacity: 50%; } """ def compose(self): yield Checkbox("[red bold]This is just[/] some text.") yield Label...
20
414
textual
tests/snapshot_tests/snapshot_apps/data_table_add_column.py
.py
from textual.app import App, ComposeResult from textual.binding import Binding from textual.widgets import DataTable, Footer MOVIES = [ "Severance", "Foundation", "Dark", "The Boys", "The Last of Us", "Lost in Space", "Altered Carbon", ] class AddColumn(App): BINDINGS = [ Bind...
39
921
textual
tests/snapshot_tests/snapshot_apps/data_table_row_cursor.py
.py
import csv import io from textual.app import App, ComposeResult from textual.widgets import DataTable CSV = """lane,swimmer,country,time 4,Joseph Schooling,Singapore,50.39 2,Michael Phelps,United States,51.14 5,Chad le Clos,South Africa,51.14 6,László Cseh,Hungary,51.14 3,Li Zhuhao,China,51.26 8,Mehdy Metella,France,...
37
880
textual
tests/snapshot_tests/snapshot_apps/text_area_line_number_start.py
.py
from textual.app import App, ComposeResult from textual.widgets import TextArea TEXT = """\ Foo Bar Baz """ class LineNumbersReactive(App[None]): START_LINE_NUMBER = 9999 def compose(self) -> ComposeResult: yield TextArea( TEXT, soft_wrap=True, show_line_numbers=T...
26
460
textual
tests/snapshot_tests/snapshot_apps/data_table_remove_row.py
.py
from textual.app import App, ComposeResult from textual.binding import Binding from textual.widgets import DataTable ROWS = [ ("lane", "swimmer", "country", "time"), (5, "Chad le Clos", "South Africa", 51.14), (4, "Joseph Schooling", "Singapore", 50.39), (2, "Michael Phelps", "United States", 51.14), ...
52
1,451
textual
tests/snapshot_tests/snapshot_apps/vertical_min_height.py
.py
from textual.app import App, ComposeResult from textual.containers import Vertical from textual.widgets import Placeholder class VerticalApp(App): CSS = """ #top { min-height: 10; height: 1fr; border: white; } #bottom { height:3fr; border: white; } ...
27
529
textual
tests/snapshot_tests/snapshot_apps/unscoped_css.py
.py
from textual.app import App, ComposeResult from textual.widget import Widget from textual.widgets import Label class MyWidget(Widget): SCOPED_CSS = False DEFAULT_CSS = """ MyWidget { height: auto; border: magenta; } Label { border: solid green; } """ def compos...
36
689
textual
tests/snapshot_tests/snapshot_apps/command_palette_key.py
.py
from textual.app import App, ComposeResult from textual.widgets import Footer class NewPaletteBindingApp(App): COMMAND_PALETTE_BINDING = "ctrl+backslash" COMMAND_PALETTE_DISPLAY = "ctrl+\\" def compose(self) -> ComposeResult: yield Footer() if __name__ == "__main__": app = NewPaletteBinding...
16
340
textual
tests/snapshot_tests/snapshot_apps/remove_tab.py
.py
from textual.app import App from textual.binding import Binding from textual.widgets import Label, TabbedContent, TabPane class ReproApp(App[None]): BINDINGS = [ Binding("space", "close_pane"), ] def __init__(self): super().__init__() self.animation_level = "none" def compose...
31
793
textual
tests/snapshot_tests/snapshot_apps/text_log_blank_write.py
.py
from textual.app import App, ComposeResult from textual.widgets import RichLog class RichLogApp(App): def compose(self) -> ComposeResult: yield RichLog() def on_mount(self) -> None: tl = self.query_one(RichLog) tl.write("Hello") tl.write("") tl.write("World") if __na...
19
377
textual
tests/snapshot_tests/snapshot_apps/dev_previews_color.py
.py
from textual_dev.previews import ColorsApp app = ColorsApp() if __name__ == "__main__": app.run()
6
103
textual
tests/snapshot_tests/snapshot_apps/pretty_grid_gutter_interaction.py
.py
"""App used as regression test for https://github.com/Textualize/textual/pull/4219.""" from __future__ import annotations from textual.app import App, ComposeResult from textual.containers import Grid from textual.widgets import Pretty, Label class MyGrid(Grid): """A simple grid with 2 columns and 2 rows.""" ...
42
864
textual
tests/snapshot_tests/snapshot_apps/grid_gutter.py
.py
from rich.markdown import Markdown from textual.app import App, ComposeResult from textual.containers import Grid, Vertical from textual.widgets import Label, TabbedContent, TabPane class FooApp(App): TITLE = "Demonstrator" CSS = """ Screen { align: center middle; } ...
43
1,322