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 | src/textual/message.py | .py | """
The base class for all messages (including events).
"""
from __future__ import annotations
from typing import TYPE_CHECKING, ClassVar
import rich.repr
from typing_extensions import Self
from textual import _time
from textual._context import active_message_pump
from textual.case import camel_to_snake
if TYPE_C... | 159 | 4,893 |
textual | src/textual/_log.py | .py | from enum import Enum
class LogGroup(Enum):
"""A log group is a classification of the log message (*not* a level)."""
UNDEFINED = 0 # Mainly for testing
EVENT = 1
DEBUG = 2
INFO = 3
WARNING = 4
ERROR = 5
PRINT = 6
SYSTEM = 7
LOGGING = 8
WORKER = 9
class LogVerbosity(Enu... | 24 | 436 |
textual | src/textual/suggestions.py | .py | from __future__ import annotations
from difflib import get_close_matches
from typing import Sequence
def get_suggestion(word: str, possible_words: Sequence[str]) -> str | None:
"""
Returns a close match of `word` amongst `possible_words`.
Args:
word: The word we want to find a close match for
... | 39 | 1,415 |
textual | src/textual/style.py | .py | """
The Style class contains all the information needed to generate styled terminal output.
You won't often need to create Style objects directly, if you are using [Content][textual.content.Content] for output.
But you might want to use styles for more customized widgets.
"""
from __future__ import annotations
from ... | 538 | 15,973 |
textual | src/textual/case.py | .py | import re
from typing import Match, Pattern
def camel_to_snake(
name: str, _re_snake: Pattern[str] = re.compile("[a-z][A-Z]")
) -> str:
"""Convert name from CamelCase to snake_case.
Args:
name: A symbol name, such as a class name.
Returns:
Name in snake case.
"""
def repl(ma... | 24 | 524 |
textual | src/textual/_profile.py | .py | """
Timer context manager, only used in debug.
"""
import contextlib
from time import perf_counter
from typing import Generator
from textual import log
@contextlib.contextmanager
def timer(subject: str = "time", threshold: float = 0) -> Generator[None, None, None]:
"""print the elapsed time. (only used in debug... | 27 | 641 |
textual | src/textual/pilot.py | .py | """
This module contains the `Pilot` class used by [App.run_test][textual.app.App.run_test] to programmatically operate an app.
See the guide on how to [test Textual apps](/guide/testing).
"""
from __future__ import annotations
import asyncio
from typing import Any, Generic
import rich.repr
from textual._wait im... | 571 | 22,848 |
textual | src/textual/worker.py | .py | """
This module contains the `Worker` class and related objects.
See the guide for how to use [workers](/guide/workers).
"""
from __future__ import annotations
import asyncio
import enum
import inspect
from contextvars import ContextVar
from threading import Event
from time import monotonic
from typing import (
... | 456 | 13,799 |
textual | src/textual/_segment_tools.py | .py | """
Tools for processing Segments, or lists of Segments.
"""
from __future__ import annotations
import re
from functools import lru_cache
from typing import Iterable
from rich.segment import Segment
from rich.style import Style
from textual._cells import cell_len
from textual.css.types import AlignHorizontal, Align... | 308 | 8,708 |
textual | src/textual/lazy.py | .py | """
Tools for lazy loading widgets.
"""
from __future__ import annotations
from textual.widget import Widget
class Lazy(Widget):
"""Wraps a widget so that it is mounted *lazily*.
Lazy widgets are mounted after the first refresh. This can be used to display some parts of
the UI very quickly, followed by... | 142 | 4,329 |
textual | src/textual/messages.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
import rich.repr
from textual._types import CallbackType
from textual.geometry import Region
from textual.message import Message
if TYPE_CHECKING:
from textual.widget import Widget
@rich.repr.auto
class CloseMessages(Message, verbose=True):
... | 141 | 3,834 |
textual | src/textual/_doc.py | .py | from __future__ import annotations
import hashlib
import inspect
import os
import shlex
from pathlib import Path
from typing import Awaitable, Callable, Iterable, cast
from textual._import_app import import_app
from textual.app import App
from textual.pilot import Pilot
SCREENSHOT_CACHE = ".screenshot_cache"
# Thi... | 192 | 5,708 |
textual | src/textual/_text_area_theme.py | .py | from __future__ import annotations
from dataclasses import dataclass, field, fields
from typing import TYPE_CHECKING
from rich.style import Style
from textual.color import Color
if TYPE_CHECKING:
from textual.widgets import TextArea
@dataclass
class TextAreaTheme:
"""A theme for the `TextArea` widget.
... | 435 | 18,067 |
textual | src/textual/design.py | .py | from __future__ import annotations
from typing import Iterable
import rich.repr
from rich.console import group
from rich.padding import Padding
from rich.table import Table
from rich.text import Text
from textual.color import TRANSPARENT, WHITE, Color
NUMBER_OF_SHADES = 3
# Where no content exists
DEFAULT_DARK_BAC... | 560 | 22,000 |
textual | src/textual/scroll_view.py | .py | """
`ScrollView` is a base class for [Line API](/guide/widgets#line-api) widgets.
"""
from __future__ import annotations
from rich.console import RenderableType
from textual._animator import EasingFunction
from textual._types import AnimationLevel, CallbackType
from textual.containers import ScrollableContainer
from... | 197 | 6,447 |
textual | src/textual/coordinate.py | .py | """
A class to store a coordinate, used by the [DataTable][textual.widgets.DataTable].
"""
from __future__ import annotations
from typing import NamedTuple
class Coordinate(NamedTuple):
"""An object representing a row/column coordinate within a grid."""
row: int
"""The row of the coordinate within a gr... | 54 | 1,247 |
textual | src/textual/_time.py | .py | import asyncio
import sys
from asyncio import sleep as asyncio_sleep
from time import monotonic, perf_counter
WINDOWS = sys.platform == "win32"
if WINDOWS:
time = perf_counter
else:
time = monotonic
if WINDOWS:
# sleep on windows as a resolution of 15ms
# Python3.11 is somewhat better, but this hom... | 53 | 1,410 |
textual | src/textual/_animator.py | .py | from __future__ import annotations
import asyncio
from abc import ABC, abstractmethod
from dataclasses import dataclass
from functools import partial
from typing import TYPE_CHECKING, Any, Callable, TypeVar
from typing_extensions import Protocol, runtime_checkable
from textual import _time
from textual._callback imp... | 591 | 20,673 |
textual | src/textual/_markup_playground.py | .py | import json
from textual import containers, events, on
from textual.app import App, ComposeResult
from textual.content import Content
from textual.reactive import reactive
from textual.widgets import Footer, Pretty, Static, TextArea
class MarkupPlayground(App):
TITLE = "Markup Playground"
CSS = """
Scre... | 151 | 4,957 |
textual | src/textual/binding.py | .py | """
This module contains the `Binding` class and related objects.
See [bindings](/guide/input#bindings) in the guide for details.
"""
from __future__ import annotations
import dataclasses
from dataclasses import dataclass
from typing import TYPE_CHECKING, Iterable, Iterator, Mapping, NamedTuple
import rich.repr
f... | 401 | 13,746 |
textual | src/textual/pad.py | .py | from typing import cast
from rich.align import Align, AlignMethod
from rich.console import (
Console,
ConsoleOptions,
JustifyMethod,
RenderableType,
RenderResult,
)
from rich.measure import Measurement
from rich.segment import Segment, Segments
from rich.style import Style
class HorizontalPad:
... | 80 | 2,306 |
textual | src/textual/_xterm_parser.py | .py | from __future__ import annotations
import os
import re
from functools import lru_cache
from typing import Any, Generator, Iterable
from typing_extensions import Final
from textual import constants, events, messages
from textual._ansi_sequences import ANSI_SEQUENCES_KEYS, IGNORE_SEQUENCE
from textual._keyboard_protoc... | 469 | 18,334 |
textual | src/textual/_cells.py | .py | from typing import Callable
from textual.expand_tabs import get_tab_widths
__all__ = ["cell_len", "cell_width_to_column_index"]
cell_len: Callable[[str], int]
try:
from rich.cells import cached_cell_len as cell_len
except ImportError:
from rich.cells import cell_len
def cell_width_to_column_index(line: st... | 45 | 1,416 |
textual | src/textual/walk.py | .py | """
Functions for *walking* the DOM.
!!! note
For most purposes you would be better off using [query][textual.dom.DOMNode.query], which uses these functions internally.
"""
from __future__ import annotations
from collections import deque
from operator import attrgetter
from typing import TYPE_CHECKING, Iterable... | 224 | 6,206 |
textual | src/textual/box_model.py | .py | from __future__ import annotations
from fractions import Fraction
from typing import NamedTuple
from textual.geometry import Spacing
class BoxModel(NamedTuple):
"""The result of `get_box_model`."""
# Content + padding + border
width: Fraction
height: Fraction
margin: Spacing # Additional margi... | 16 | 322 |
textual | src/textual/timer.py | .py | """
Contains the `Timer` class.
Timer objects are created by [set_interval][textual.message_pump.MessagePump.set_interval] or
[set_timer][textual.message_pump.MessagePump.set_timer].
"""
from __future__ import annotations
import weakref
from asyncio import CancelledError, Event, Task, create_task, gather
from ty... | 204 | 6,255 |
textual | src/textual/_parser.py | .py | from __future__ import annotations
from collections import deque
from typing import Callable, Deque, Generator, Generic, Iterable, NamedTuple, TypeVar
from textual._time import get_time
class ParseError(Exception):
"""Base class for parse related errors."""
class ParseEOF(ParseError):
"""End of Stream."""... | 127 | 3,307 |
textual | src/textual/_win_sleep.py | .py | """
A version of `time.sleep` that is more accurate than the standard library (even on Python 3.11).
This should only be imported on Windows.
"""
from __future__ import annotations
import asyncio
from time import sleep as time_sleep
from typing import Coroutine
__all__ = ["sleep"]
INFINITE = 0xFFFFFFFF
WAIT_FAILE... | 122 | 3,773 |
textual | src/textual/_two_way_dict.py | .py | from __future__ import annotations
from typing import Generic, TypeVar
Key = TypeVar("Key")
Value = TypeVar("Value")
class TwoWayDict(Generic[Key, Value]):
"""
A two-way mapping offering O(1) access in both directions.
Wraps two dictionaries and uses them to provide efficient access to
both values ... | 73 | 2,009 |
textual | src/textual/_spatial_map.py | .py | from __future__ import annotations
from collections import defaultdict
from itertools import product
from typing import Generic, Iterable, TypeVar
from typing_extensions import TypeAlias
from textual.geometry import Offset, Region
ValueType = TypeVar("ValueType")
GridCoordinate: TypeAlias = "tuple[int, int]"
clas... | 104 | 3,764 |
textual | src/textual/worker_manager.py | .py | """
Contains `WorkerManager`, a class to manage [workers](/guide/workers) for an app.
You access this object via [App.workers][textual.app.App.workers] or [Widget.workers][textual.dom.DOMNode.workers].
"""
from __future__ import annotations
import asyncio
from collections import Counter
from operator import attrgett... | 182 | 5,602 |
textual | src/textual/features.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, cast
from typing_extensions import Literal
if TYPE_CHECKING:
from typing_extensions import Final
FEATURES: Final = {"devtools", "debug", "headless"}
FeatureFlag = Literal["devtools", "debug", "headless"]
def parse_features(features: str) ->... | 30 | 699 |
textual | src/textual/widget.py | .py | """
This module contains the `Widget` class, the base class for all widgets.
"""
from __future__ import annotations
from asyncio import create_task, gather, wait
from collections import Counter
from contextlib import asynccontextmanager
from fractions import Fraction
from time import monotonic
from types import Trac... | 4,957 | 175,691 |
textual | src/textual/markup.py | .py | """
Utilities related to content markup.
"""
from __future__ import annotations
from operator import itemgetter
from textual.css.parse import substitute_references
from textual.css.tokenizer import UnexpectedEnd
__all__ = ["MarkupError", "escape", "to_content"]
import re
from string import Template
from typing im... | 464 | 13,404 |
textual | src/textual/_types.py | .py | from typing import TYPE_CHECKING, Any, Awaitable, Callable, List, Literal, Union
from typing_extensions import Protocol
if TYPE_CHECKING:
from rich.segment import Segment
from textual.message import Message
class MessageTarget(Protocol):
"""Protocol that must be followed by objects that can receive mes... | 58 | 1,935 |
textual | src/textual/content.py | .py | """
Content is a container for text, with spans marked up with color / style.
It is equivalent to Rich's Text object, with support for more of Textual features.
Unlike Rich Text, Content is *immutable* so you can't modify it in place, and most methods will return a new Content instance.
This is more like the builtin s... | 1,843 | 62,237 |
textual | src/textual/_keyboard_protocol.py | .py | from typing import Final
# https://sw.kovidgoyal.net/kitty/keyboard-protocol/#functional-key-definitions
FUNCTIONAL_KEYS: Final = {
"27u": "escape",
"13u": "enter",
"9u": "tab",
"127u": "backspace",
"2~": "insert",
"3~": "delete",
"1D": "left",
"1C": "right",
"1A": "up",
"1B": "... | 144 | 3,199 |
textual | src/textual/_context.py | .py | from __future__ import annotations
from contextvars import ContextVar
from typing import TYPE_CHECKING, Any, Callable
if TYPE_CHECKING:
from textual.app import App
from textual.message import Message
from textual.message_pump import MessagePump
from textual.screen import Screen
class NoActiveAppErro... | 29 | 1,028 |
textual | src/textual/_immutable_sequence_view.py | .py | """Provides an immutable sequence view class."""
from __future__ import annotations
from sys import maxsize
from typing import TYPE_CHECKING, Generic, Iterator, Sequence, TypeVar, overload
T = TypeVar("T")
class ImmutableSequenceView(Generic[T]):
"""Class to wrap a sequence of some sort, but not allow modifica... | 70 | 1,859 |
textual | src/textual/await_remove.py | .py | """
An *optionally* awaitable object returned by methods that remove widgets.
"""
from __future__ import annotations
import asyncio
from asyncio import Task, gather
from typing import Generator
import rich.repr
from textual._callback import invoke
from textual._debug import get_caller_file_and_line
from textual._ty... | 48 | 1,345 |
textual | src/textual/_duration.py | .py | import re
_match_duration = re.compile(r"^(-?\d+\.?\d*)(s|ms)$").match
class DurationError(Exception):
"""
Exception indicating a general issue with a CSS duration.
"""
class DurationParseError(DurationError):
"""
Indicates a malformed duration string that could not be parsed.
"""
def _du... | 45 | 1,211 |
textual | src/textual/command.py | .py | """
This module contains classes for working with Textual's command palette.
See the guide on the [Command Palette](../guide/command_palette.md) for full details.
"""
from __future__ import annotations
from abc import ABC, abstractmethod
from asyncio import (
CancelledError,
Queue,
Task,
TimeoutErro... | 1,287 | 43,086 |
textual | src/textual/_debug.py | .py | """
Functions related to debugging.
"""
from __future__ import annotations
from textual import constants
def get_caller_file_and_line() -> str | None:
"""Get the caller filename and line, if in debug mode, otherwise return `None`:
Returns:
Path and file if `constants.DEBUG==True`
"""
if no... | 27 | 614 |
textual | src/textual/map_geometry.py | .py | from __future__ import annotations
from typing import NamedTuple
from textual.geometry import Region, Size, Spacing
class MapGeometry(NamedTuple):
"""Defines the absolute location of a Widget."""
region: Region
"""The (screen) [region][textual.geometry.Region] occupied by the widget."""
order: tupl... | 35 | 1,363 |
textual | src/textual/_styles_cache.py | .py | from __future__ import annotations
from functools import lru_cache
from typing import TYPE_CHECKING, Callable, Iterable, Sequence
import rich.repr
from rich.segment import Segment
from rich.style import Style as RichStyle
from rich.terminal_theme import TerminalTheme
from textual import log
from textual._ansi_theme ... | 524 | 19,197 |
textual | src/textual/_queue.py | .py | from __future__ import annotations
import asyncio
from asyncio import Event
from collections import deque
from typing import Generic, TypeVar
QueueType = TypeVar("QueueType")
class Queue(Generic[QueueType]):
"""A cut-down version of asyncio.Queue
This has just enough functionality to run the message pumps.... | 50 | 1,211 |
textual | src/textual/dom.py | .py | """
The module contains `DOMNode`, the base class for any object within the Textual Document Object Model,
which includes all Widgets, Screens, and Apps.
"""
from __future__ import annotations
import re
import threading
from functools import lru_cache, partial
from inspect import getfile
from typing import (
TYP... | 1,945 | 64,878 |
textual | src/textual/cache.py | .py | """
Cache classes are dict-like containers used to avoid recalculating expensive operations such as rendering.
You can also use them in your own apps for similar reasons.
"""
from __future__ import annotations
from typing import TYPE_CHECKING, Dict, Generic, KeysView, TypeVar, overload
CacheKey = TypeVar("CacheKe... | 315 | 9,357 |
textual | src/textual/_box_drawing.py | .py | """
Box drawing utilities for Canvas.
The box drawing characters have zero to four lines radiating from the center of the glyph.
There are three line types: thin, heavy, and double. These are indicated by 1, 2, and 3 respectively (0 for no line).
This code represents the characters as a tuple of 4 integers, (<top>, <... | 367 | 8,159 |
textual | src/textual/scrollbar.py | .py | """
Contains the widgets that manage Textual scrollbars.
!!! note
You will not typically need this for most apps.
"""
from __future__ import annotations
from math import ceil
from typing import ClassVar, Type
import rich.repr
from rich.color import Color
from rich.console import Console, ConsoleOptions, Rende... | 412 | 13,956 |
textual | src/textual/message_pump.py | .py | """
A `MessagePump` is a base class for any object which processes messages, which includes Widget, Screen, and App.
!!! tip
Most of the method here are useful in general app development.
"""
from __future__ import annotations
import asyncio
import threading
from asyncio import CancelledError, QueueEmpty, Tas... | 921 | 32,221 |
textual | src/textual/validation.py | .py | """
This module provides a number of classes for validating input.
See [Validating Input](/widgets/input/#validating-input) for details.
"""
from __future__ import annotations
import math
import re
from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from typing import Callable, Pattern, Se... | 520 | 18,715 |
textual | src/textual/_ansi_theme.py | .py | from __future__ import annotations
from rich.terminal_theme import TerminalTheme
def rgb(red: int, green: int, blue: int) -> tuple[int, int, int]:
"""Define an RGB color.
This exists mainly so that a VSCode extension can render the colors inline.
Args:
red: Red component.
green: Green c... | 73 | 1,509 |
textual | src/textual/reactive.py | .py | """
This module contains the `Reactive` class which implements [reactivity](/guide/reactivity/).
"""
from __future__ import annotations
from functools import partial
from inspect import isawaitable
from typing import (
TYPE_CHECKING,
Any,
Awaitable,
Callable,
ClassVar,
Generic,
Type,
... | 533 | 18,056 |
textual | src/textual/_tree_sitter.py | .py | from __future__ import annotations
from importlib import import_module
from textual import log
try:
from tree_sitter import Language
_LANGUAGE_CACHE: dict[str, Language] = {}
_tree_sitter = True
def get_language(language_name: str) -> Language | None:
if language_name in _LANGUAGE_CACHE:
... | 45 | 1,299 |
textual | src/textual/strip.py | .py | """
This module contains the `Strip` class and related objects.
A `Strip` contains the result of rendering a widget.
See [Line API](/guide/widgets#line-api) for how to use Strips.
"""
from __future__ import annotations
from functools import lru_cache
from typing import Any, Iterable, Iterator, Sequence
import rich.... | 818 | 26,717 |
textual | src/textual/theme.py | .py | from __future__ import annotations
from dataclasses import dataclass, field
from functools import partial
from operator import attrgetter
from typing import Callable
from textual.command import DiscoveryHit, Hit, Hits, Provider
from textual.design import ColorSystem
@dataclass
class Theme:
"""Defines a theme fo... | 545 | 16,788 |
textual | src/textual/_partition.py | .py | from __future__ import annotations
from typing import Callable, Iterable, TypeVar
T = TypeVar("T")
def partition(
predicate: Callable[[T], object], iterable: Iterable[T]
) -> tuple[list[T], list[T]]:
"""Partition a sequence into two list from a given predicate. The first list will contain
the values whe... | 28 | 844 |
textual | src/textual/_wait.py | .py | from asyncio import sleep
from time import monotonic, process_time
SLEEP_GRANULARITY: float = 1 / 50
SLEEP_IDLE: float = SLEEP_GRANULARITY / 20.0
async def wait_for_idle(
min_sleep: float = SLEEP_GRANULARITY, max_sleep: float = 1
) -> None:
"""Wait until the process isn't working very hard.
This will co... | 42 | 1,446 |
textual | src/textual/getters.py | .py | """
Descriptors to define properties on your widget, screen, or App.
"""
from __future__ import annotations
from inspect import isclass
from typing import TYPE_CHECKING, Callable, Generic, TypeVar, overload
from textual._context import NoActiveAppError, active_app
from textual.css.query import NoMatches, QueryType,... | 226 | 6,864 |
textual | src/textual/_auto_scroll.py | .py | from textual.geometry import Region
def get_auto_scroll_regions(
widget_region: Region, auto_scroll_lines: int
) -> tuple[Region, Region]:
"""Get non-overlapping regions which should auto scroll when selecting.
Args:
widget_region: The region occupied by the widget.
auto_scroll_lines: Num... | 31 | 1,080 |
textual | src/textual/events.py | .py | """
Builtin events sent by Textual.
Events may be marked as "Bubbles" and "Verbose".
See the [events guide](/guide/events/#bubbling) for an explanation of bubbling.
Verbose events are excluded from the textual console, unless you explicitly request them with the `-v` switch as follows:
```
textual console -v
```
"""... | 997 | 26,355 |
textual | src/textual/visual.py | .py | from __future__ import annotations
from abc import ABC, abstractmethod
from dataclasses import dataclass
from itertools import islice
from typing import TYPE_CHECKING, Callable, Protocol
import rich.repr
from rich.console import Console, ConsoleOptions, RenderableType
from rich.measure import Measurement
from rich.pr... | 432 | 13,870 |
textual | src/textual/actions.py | .py | from __future__ import annotations
import ast
import re
from functools import lru_cache
from typing import Any
from typing_extensions import TypeAlias
ActionParseResult: TypeAlias = "tuple[str, str, tuple[object, ...]]"
"""An action is its name and the arbitrary tuple of its arguments."""
class SkipAction(Exceptio... | 60 | 1,669 |
textual | src/textual/highlight.py | .py | from __future__ import annotations
import os
from typing import Tuple
from pygments.lexer import Lexer
from pygments.lexers import get_lexer_by_name, guess_lexer_for_filename
from pygments.token import Token
from pygments.util import ClassNotFound
from textual.content import Content, Span
TokenType = Tuple[str, ...... | 239 | 7,952 |
textual | src/textual/demo/demo_app.py | .py | from __future__ import annotations
from textual.app import App
from textual.binding import Binding
from textual.demo.game import GameScreen
from textual.demo.home import HomeScreen
from textual.demo.projects import ProjectsScreen
from textual.demo.widgets import WidgetsScreen
class DemoApp(App):
"""The demo app ... | 106 | 2,965 |
textual | src/textual/demo/_project_stars.py | .py | STARS = {
"Posting": "11.4k",
"Memray": "14.9k",
"Toolong": "3.9k",
"Dolphie": "1.1k",
"Harlequin": "5.8k",
"Elia": "2.4k",
"Trogon": "2.8k",
"TFTUI - The Terraform textual UI": "1.3k",
"RecoverPy": "1.7k",
"Frogmouth": "3.1k",
"oterm": "2.3k",
"logmerger": "250",
"do... | 16 | 335 |
textual | src/textual/demo/_project_stargazer_updater.py | .py | import httpx
import os
import json
from rich.console import Console
# Not using the Absolute reference because
# I can't get python to run it.
from _project_data import PROJECTS
console = Console()
error_console = Console(stderr=True, style="bold red")
def main() -> None:
STARS = {}
for project in PROJECTS... | 51 | 1,523 |
textual | src/textual/demo/game.py | .py | """
An implementation of the "Sliding Tile" puzzle.
Textual isn't a game engine exactly, but it wasn't hard to build this.
"""
from __future__ import annotations
from asyncio import sleep
from collections import defaultdict
from dataclasses import dataclass
from itertools import product
from random import choice
fr... | 590 | 19,438 |
textual | src/textual/demo/home.py | .py | from __future__ import annotations
import asyncio
from importlib.metadata import version
try:
import httpx
HTTPX_AVAILABLE = True
except ImportError:
HTTPX_AVAILABLE = False
from textual import work
from textual.app import ComposeResult
from textual.containers import Horizontal, Vertical, VerticalScroll... | 269 | 8,588 |
textual | src/textual/demo/__main__.py | .py | from textual.demo.demo_app import DemoApp
if __name__ == "__main__":
app = DemoApp()
app.run()
| 6 | 104 |
textual | src/textual/demo/page.py | .py | from __future__ import annotations
import inspect
from rich.syntax import Syntax
from textual import work
from textual.app import ComposeResult
from textual.binding import Binding
from textual.containers import ScrollableContainer
from textual.screen import ModalScreen, Screen
from textual.widgets import Static
cl... | 95 | 2,527 |
textual | src/textual/demo/data.py | .py | import json
COUNTRIES = [
"Afghanistan",
"Albania",
"Algeria",
"Andorra",
"Angola",
"Antigua and Barbuda",
"Argentina",
"Armenia",
"Australia",
"Austria",
"Azerbaijan",
"Bahamas",
"Bahrain",
"Bangladesh",
"Barbados",
"Belarus",
"Belgium",
"Belize"... | 459 | 15,435 |
textual | src/textual/demo/projects.py | .py | from __future__ import annotations
from textual import events, on
from textual.app import ComposeResult
from textual.binding import Binding
from textual.containers import Center, Horizontal, ItemGrid, Vertical, VerticalScroll
from textual.demo._project_data import PROJECTS, ProjectInfo
from textual.demo._project_stars... | 138 | 3,824 |
textual | src/textual/demo/_project_data.py | .py | from dataclasses import dataclass
@dataclass
class ProjectInfo:
"""Dataclass for storing project information."""
title: str
author: str
url: str
description: str
repo_url_part: str
PROJECTS = [
ProjectInfo(
"Posting",
"Darren Burns",
"https://posting.sh/",
... | 108 | 3,444 |
textual | src/textual/demo/widgets.py | .py | from __future__ import annotations
import csv
import io
from math import sin
from rich.syntax import Syntax
from rich.table import Table
from rich.traceback import Traceback
from textual import containers, events, lazy, on
from textual.app import ComposeResult
from textual.binding import Binding
from textual.demo.da... | 823 | 23,870 |
textual | src/textual/widgets/_text_area.py | .py | from __future__ import annotations
import dataclasses
import re
from collections import defaultdict
from dataclasses import dataclass
from functools import lru_cache
from pathlib import Path
from typing import TYPE_CHECKING, ClassVar, Iterable, Optional, Sequence, Tuple
from rich.console import RenderableType
from ri... | 2,799 | 102,337 |
textual | src/textual/widgets/tabbed_content.py | .py | from textual.widgets._tabbed_content import ContentTab, ContentTabs
__all__ = [
"ContentTab",
"ContentTabs",
]
| 7 | 120 |
textual | src/textual/widgets/_footer.py | .py | from __future__ import annotations
from collections import defaultdict
from itertools import groupby
from typing import TYPE_CHECKING
import rich.repr
from rich.text import Text
from textual import events
from textual.app import ComposeResult
from textual.binding import Binding
from textual.containers import Horizon... | 334 | 10,585 |
textual | src/textual/widgets/_welcome.py | .py | """Provides a Textual welcome widget."""
from rich.markdown import Markdown
from textual.app import ComposeResult
from textual.containers import Container
from textual.widgets._button import Button
from textual.widgets._static import Static
WELCOME_MD = """\
# Welcome!
Textual is a TUI, or *Text User Interface*, fr... | 60 | 1,535 |
textual | src/textual/widgets/_masked_input.py | .py | from __future__ import annotations
import re
from dataclasses import dataclass
from enum import Flag, auto
from typing import TYPE_CHECKING, Iterable, Pattern
from rich.console import RenderableType
from rich.segment import Segment
from rich.text import Text
from typing_extensions import Literal
from textual import ... | 708 | 26,291 |
textual | src/textual/widgets/_key_panel.py | .py | from __future__ import annotations
from collections import defaultdict
from itertools import groupby
from operator import itemgetter
from typing import TYPE_CHECKING
from rich import box
from rich.table import Table
from rich.text import Text
from textual.app import ComposeResult
from textual.binding import Binding
... | 183 | 5,569 |
textual | src/textual/widgets/_radio_button.py | .py | """Provides a radio button widget."""
from __future__ import annotations
from textual.widgets._toggle_button import ToggleButton
class RadioButton(ToggleButton):
"""A radio button widget that represents a boolean value.
Note:
A `RadioButton` is best used within a [RadioSet][textual.widgets.RadioSet... | 34 | 1,037 |
textual | src/textual/widgets/_tabbed_content.py | .py | from __future__ import annotations
from asyncio import gather
from dataclasses import dataclass
from itertools import zip_longest
from typing import Awaitable
from rich.repr import Result
from typing_extensions import Final
from textual import events
from textual.app import ComposeResult
from textual.await_complete ... | 717 | 23,958 |
textual | src/textual/widgets/_pretty.py | .py | """Provides a pretty-printing widget."""
from __future__ import annotations
from typing import Any
from rich.pretty import Pretty as PrettyRenderable
from textual.app import RenderResult
from textual.widget import Widget
class Pretty(Widget):
"""A pretty-printing widget.
Used to pretty-print any object.
... | 57 | 1,379 |
textual | src/textual/widgets/directory_tree.py | .py | from textual.widgets._directory_tree import DirEntry
__all__ = ["DirEntry"]
| 4 | 77 |
textual | src/textual/widgets/_checkbox.py | .py | """Provides a check box widget."""
from __future__ import annotations
from textual.widgets._toggle_button import ToggleButton
class Checkbox(ToggleButton):
"""A check box widget that represents a boolean value."""
class Changed(ToggleButton.Changed):
"""Posted when the value of the checkbox changes... | 27 | 803 |
textual | src/textual/widgets/_input.py | .py | from __future__ import annotations
import re
from dataclasses import dataclass
from typing import TYPE_CHECKING, ClassVar, Iterable, NamedTuple
from rich.cells import cell_len, get_character_cell_size
from rich.console import RenderableType
from rich.highlighter import Highlighter
from rich.text import Text
from typi... | 1,134 | 41,180 |
textual | src/textual/widgets/_markdown.py | .py | from __future__ import annotations
import asyncio
import re
import weakref
from contextlib import suppress
from functools import partial
from pathlib import Path, PurePath
from typing import Callable, Iterable, Optional
from urllib.parse import unquote
from markdown_it import MarkdownIt
from markdown_it.token import ... | 1,724 | 54,844 |
textual | src/textual/widgets/data_table.py | .py | from textual.widgets._data_table import (
CellDoesNotExist,
CellKey,
CellType,
Column,
ColumnDoesNotExist,
ColumnKey,
CursorType,
DuplicateKey,
Row,
RowDoesNotExist,
RowKey,
StringKey,
)
__all__ = [
"CellDoesNotExist",
"CellKey",
"CellType",
"Column",
... | 30 | 465 |
textual | src/textual/widgets/_toggle_button.py | .py | """Provides the base code and implementations of toggle widgets.
In particular it provides `Checkbox`, `RadioButton` and `RadioSet`.
"""
from __future__ import annotations
from typing import TYPE_CHECKING, ClassVar
from rich.console import RenderableType
from textual.binding import Binding, BindingType
from textua... | 286 | 8,942 |
textual | src/textual/widgets/_sparkline.py | .py | from __future__ import annotations
from typing import Callable, ClassVar, Optional, Sequence
from textual.app import RenderResult
from textual.color import Color
from textual.reactive import reactive
from textual.renderables.sparkline import Sparkline as SparklineRenderable
from textual.widget import Widget
def _ma... | 110 | 3,884 |
textual | src/textual/widgets/_link.py | .py | from __future__ import annotations
from textual.binding import Binding
from textual.reactive import reactive
from textual.widgets import Static
class Link(Static, can_focus=True):
"""A simple, clickable link that opens a URL."""
DEFAULT_CSS = """
Link {
width: auto;
height: auto;
... | 72 | 1,978 |
textual | src/textual/widgets/_list_item.py | .py | """Provides a list item widget for use with `ListView`."""
from __future__ import annotations
from textual import events, on
from textual.message import Message
from textual.reactive import reactive
from textual.widget import Widget
class ListItem(Widget, can_focus=False):
"""A widget that is an item within a `... | 40 | 1,199 |
textual | src/textual/widgets/_help_panel.py | .py | from __future__ import annotations
from textwrap import dedent
from textual.app import ComposeResult
from textual.css.query import NoMatches
from textual.widget import Widget
from textual.widgets import KeyPanel, Markdown
class HelpPanel(Widget):
"""
Shows context sensitive help for the currently focused wi... | 114 | 2,900 |
textual | src/textual/widgets/_directory_tree.py | .py | from __future__ import annotations
import asyncio
from asyncio import Queue
from dataclasses import dataclass
from pathlib import Path
from typing import TYPE_CHECKING, Callable, ClassVar, Iterable, Iterator
from rich.style import Style
from rich.text import Text, TextType
from textual import work
from textual.await... | 586 | 20,281 |
textual | src/textual/widgets/button.py | .py | from textual.widgets._button import ButtonVariant
__all__ = ["ButtonVariant"]
| 4 | 79 |
textual | src/textual/widgets/__init__.py | .py | from __future__ import annotations
import typing
from importlib import import_module
from textual.case import camel_to_snake
# For any new built-in Widget we create, not only do we have to import them here and add them to `__all__`,
# but also to the `__init__.pyi` file in this same folder - otherwise text editors a... | 117 | 3,817 |
textual | src/textual/widgets/markdown.py | .py | from textual.widgets._markdown import (
Markdown,
MarkdownBlock,
MarkdownFence,
MarkdownStream,
MarkdownTableOfContents,
TableOfContentsType,
)
__all__ = [
"Markdown",
"MarkdownBlock",
"MarkdownFence",
"MarkdownStream",
"MarkdownTableOfContents",
"TableOfContentsType",
]... | 18 | 321 |
textual | src/textual/widgets/rule.py | .py | from textual.widgets._rule import (
InvalidLineStyle,
InvalidRuleOrientation,
LineStyle,
RuleOrientation,
)
__all__ = [
"InvalidLineStyle",
"InvalidRuleOrientation",
"LineStyle",
"RuleOrientation",
]
| 14 | 233 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.