Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
solid_fill.py49 linesDownload Raw Back to widget
1from __future__ import annotations2 3from urwid.canvas import SolidCanvas4 5from .constants import SHADE_SYMBOLS, Sizing6from .widget import Widget7 8 9class SolidFill(Widget):10    """11    A box widget that fills an area with a single character12    """13 14    _selectable = False15    ignore_focus = True16    _sizing = frozenset([Sizing.BOX])17 18    Symbols = SHADE_SYMBOLS19 20    def __init__(self, fill_char: str = " ") -> None:21        """22        :param fill_char: character to fill area with23        :type fill_char: bytes or unicode24 25        >>> SolidFill("8")26        <SolidFill box widget '8'>27        """28        super().__init__()29        self.fill_char = fill_char30 31    def _repr_words(self) -> list[str]:32        return [*super()._repr_words(), repr(self.fill_char)]33 34    def render(35        self,36        size: tuple[int, int],  # type: ignore[override]37        focus: bool = False,38    ) -> SolidCanvas:39        """40        Render the Fill as a canvas and return it.41 42        >>> SolidFill().render((4, 2)).text  # ... = b in Python 343        [...'    ', ...'    ']44        >>> SolidFill("#").render((5, 3)).text45        [...'#####', ...'#####', ...'#####']46        """47        maxcol, maxrow = size48        return SolidCanvas(self.fill_char, maxcol, maxrow)49 
codekingpro/portable-devtools · Team Ai