コード例 #1
0
from pytermgui import Label, Container, boxes

art = """\
[bold 157] ____      [60] _____                  [210]  ____ _   _ ___ [/]
[bold 157]|  _ \ _   [60]|_   _|__ _ __ _ __ ___ [210] / ___| | | |_ _|[/]
[bold 157]| |_) | | | |[60]| |/ _ \ '__| '_ ` _ .[210]| |  _| | | || | [/]
[bold 157]|  __/| |_| |[60]| |  __/ |  | | | | | [210]| |_| | |_| || | [/]
[bold 157]|_|    \__, |[60]|_|\___|_|  |_| |_| |_|[210]\____|\___/|___|[/]
 ====== [bold 157]|___/[/fg] ======================================= [/]
"""

Container.set_char("border", [""] * 4)
root = Container()
for line in art.splitlines():
    root += Label(line)

root.center()
root.print()
コード例 #2
0
"""

from pytermgui import (
    Container,
    Prompt,
    Label,
    Splitter,
    alt_buffer,
    getch,
    ListView,
    ColorPicker,
    real_length,
)

with alt_buffer(cursor=False):
    Container.set_char("border", ["│ ", "─", " │", "─"])
    Container.set_char("corner", ["╭", "╮", "╯", "╰"])
    Splitter.set_char("separator", " ")

    main = Container(horiz_align=Container.HORIZ_ALIGN_LEFT)

    header = Splitter()
    header += Label("color picker one:", Label.ALIGN_LEFT)
    # header += Label("one", Label.ALIGN_CENTER)
    # header += Label("onne", Label.ALIGN_CENTER)
    # header += Label("onne", Label.ALIGN_CENTER)
    header += Label("color picker two:", Label.ALIGN_RIGHT)

    splitter = Splitter()
    splitter += ColorPicker(16)
    splitter += ColorPicker(16)
コード例 #3
0
    """Style function for values"""

    return color(item, 33 + 36 * depth)  # type: ignore


def highlight_style(depth: int, item: str) -> str:
    """Style function for highlighted elements"""

    return highlight(item, 99)


delimiter_style = create_style(225)
padding_label = Label()

with alt_buffer():
    Container.set_char("border", ["|| ", "~", " ||", "~"])

    Label.set_style("value", value_style)

    Prompt.set_style("value", value_style)
    Prompt.set_style("label", delimiter_style)
    Prompt.set_style("delimiter", delimiter_style)
    Prompt.set_style("highlight", highlight_style)

    ListView.set_style("highlight", highlight_style)
    ListView.set_style("options", value_style)
    ListView.set_style("delimiter", delimiter_style)

    ProgressBar.set_style("fill", delimiter_style)
    ProgressBar.set_style("delimiter", value_style)