Beispiel #1
0
def test_render():
    layout = Layout(name="root")
    repr(layout)

    layout.split_column(Layout(name="top"), Layout(name="bottom"))
    top = layout["top"]
    top.update(Panel("foo"))

    print(type(top._renderable))
    assert isinstance(top.renderable, Panel)
    layout["bottom"].split_row(Layout(name="left"), Layout(name="right"))

    assert layout["root"].name == "root"
    assert layout["left"].name == "left"
    with pytest.raises(KeyError):
        top["asdasd"]

    layout["left"].update("foobar")
    print(layout["left"].children)

    console = Console(width=60, color_system=None)

    with console.capture() as capture:
        console.print(layout, height=10)

    result = capture.get()
    print(repr(result))
    expected = "╭──────────────────────────────────────────────────────────╮\n│ foo                                                      │\n│                                                          │\n│                                                          │\n╰──────────────────────────────────────────────────────────╯\nfoobar                        ╭───── 'right' (30 x 5) ─────╮\n                              │                            │\n                              │    Layout(name='right')    │\n                              │                            │\n                              ╰────────────────────────────╯\n"

    assert result == expected
Beispiel #2
0
def get_layout(
    nb_status: Optional[NBMinerStatus],
    bin_status: BinanceStatus,
    profit_today: Dict[str, ExchangeRate],
    profit_yesterday: Dict[str, ExchangeRate],
) -> Layout:
    """
    Get cli layout.

    :param nb_status: current miner status.
    :param bin_status: current binanace status.
    :param profit_today: Mined amout of crypto today.
    :param profit_yesterday: Mined amount of crypto yesterday.
    :return: layout for render in terminal.
    """
    main_layout = Layout()
    nb_layout: Any = Text("Can't connect to NBMiner.", justify="center")
    if nb_status is not None:
        nb_layout = _get_nb_layout(nb_status)
    bin_layout = _get_binance_layout(bin_status, profit_today, profit_yesterday)
    main_layout.split_column(
        nb_layout,
        bin_layout,
    )
    return main_layout
Beispiel #3
0
                ],
                expand=True,
                column_first=True,
            ),
            title=name,
        )
        for name, y in mail.items()
    ],
    column_first=True,
)

# Partition the screen into manageable chunks
layout = Layout()
layout.split_column(
    Layout(Padding(""), name="padding", size=1),
    Layout(Rule(platform.node()), name="title", size=1),
    Layout(name="content"),
)
timed_layout = Layout()
timed_layout.split_row(
    Layout(Panel(events, title="Calendar"), name="calendar"),
    Layout(Panel(mails, title="Emails"), name="email"),
)
layout["content"].split_row(
    Layout(Panel(fetch), name="fetch"),
    Layout(Panel(timed_layout, title=str(datetime.date.today())), name="timed", ratio=4),
)

# Do it
console.print(layout)
        for case, answer in huge_tests:
            test_cases.append(TestCase(cast("Sea", case), int(answer)))

    for test_number, test in enumerate(test_cases):
        sea = stringify(test.case)
        header = f"test #{test_number + 1}"

        if TYPE_CHECKING:
            live: Union[FakeLive, Live]

        if RICH or TYPE_CHECKING:
            sea_table = SeaTable.from_sea(sea)
            layout = Layout()
            layout.split_column(
                Layout(Rule(header), name="header"),
                Layout(sea_table, name="table"),
                Layout("press Enter to continue", name="footer"),
            )
            layout["header"].size = 1
            layout["footer"].size = 1
            live = Live(layout,
                        auto_refresh=False,
                        refresh_per_second=16,
                        screen=True)
        else:
            live = FakeLive()

        if not RICH and DEBUGGING:
            print(header)

        with live: