Example #1
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
 def __init__(self):
     self._layout = Layout()
     self._table = Table(title="AUTOBOT MENU",
                         expand=True,
                         show_lines=True,
                         box=box.SQUARE_DOUBLE_HEAD,
                         title_style="#0000ff italic")
    def __rich__(self) -> Layout:
        self.layout.split(
            Layout(name="head", size=3),
            Layout(name="body"),
        )

        self.layout["body"].split_column(
            Layout(name='should_be_unused', visible=False),
            Layout(name='table2'),
            Layout(name='action_table'),
        )
        self.table.add_column("Action Button",
                              justify="center",
                              style="cyan",
                              no_wrap=True)
        self.table.add_column("Actions", style="magenta", justify="center")

        self.table.add_row("1", "TO SEARCH WITH LINK CODE")
        self.table.add_row("2", "TO SEARCH WITH SITE ID")
        self.table.add_row("0", "BACK TO MAIN MENU")

        self.layout["head"].update(Header("LDMA-PARSER"))
        self.layout["action_table"].update(self.table)
        self.layout["table2"].update(make_sponsor_message())

        return self.layout
Example #4
0
def update_postseason(title: str, data: Games) -> None:
    layout["header"].update(Panel(Text(title, justify="center")))

    for subleague, games in data.items():
        tables = []
        for game in games.values():
            table = Table.grid(expand=True)
            table.add_column("Seed", width=1)
            table.add_column("Name")
            table.add_column("Championships", style="#FFEB57", width=4)
            table.add_column("Wins", width=1)
            for row in game:
                table.add_row(
                    row.seed,
                    Text(row.name, style=row.color),
                    "●" * row.championships if row.championships < 4 else f"●x{row.championships}",
                    row.wins,
                )
            tables.append(Layout(table))

        all_tables = Layout()
        all_tables.split(*tables)
        layout[subleague].update(Panel(
            all_tables,
            title=subleague,
            padding=0
        ))
    def __rich__(self):
        self._layout.split(
            Layout(name="head", size=3),
            Layout(name="body", ratio=1),
        )

        self._layout["body"].split_column(Layout(name="mid_section", ratio=2),
                                          Layout(name="table", ratio=3))

        # Tables
        self._table.add_column("Action Button",
                               justify="center",
                               header_style="#3be13b",
                               no_wrap=True,
                               style="#3be13b")
        self._table.add_column("Action Description",
                               justify="center",
                               header_style="bold cyan",
                               no_wrap=True,
                               style="cyan")

        self._table.add_row("1", "CREATE NCR 🧩")
        self._table.add_row("2", "CLOSE NCR  🎯")
        self._table.add_row("3", "CANCEL NCR  🧨")
        self._table.add_row("4", "LDMA PARSER  📆")
        self._table.add_row("0", "EXIT AUTOBOT  âš”")

        self._layout["head"].update(Header("WELCOME TO AUTOBOT"))
        self._layout["mid_section"].update(make_sponsor_message())
        self._layout["table"].update(self._table)
        return self._layout
Example #6
0
class TerminalUI:
    def __init__(self, probe, target, tree):
        """
            UI for terminal info panels showing probe parameters, regions
            touched by probe etc. Built as a Live dispay of Layout's showing 
            rich renderables (classes above).
        """
        self.layout = Layout()
        self.layout.split(
            Layout(name="left", ratio=2),
            Layout(tree, name="right", ratio=4),
            direction="horizontal",
        )

        self.layout["left"].split(
            Layout(target, name="ltop"),
            Layout(
                Panel(
                    probe,
                    title="Probe",
                    border_style=salmon_light,
                    title_align="left",
                ),
                name="lbottom",
                ratio=3,
            ),
        )

    def __rich_console__(self, console, measure):
        yield self.layout
Example #7
0
def update_postseason(data: Brackets) -> None:
    for bracket, leagues in data.items():
        if bracket == "overbracket":
            layout["header"].update(
                Text(f"{leagues['name']} {leagues['round']}",
                     justify="center"))
        else:
            layout["footer"].update(
                Text(f"{leagues['name']} {leagues['round']}",
                     justify="center"))
        for subleague, games in leagues["games"].items():
            tables = []
            for game in games.values():
                table = Table.grid(expand=True)
                table.add_column("Seed", width=1)
                table.add_column("Name")
                table.add_column("Championships", width=2)
                table.add_column("Wins", width=1)
                for row in game:
                    table.add_row(
                        str(row.seed),
                        f"[{row.color}]{row.name}[/]",
                        clip_championships(row),
                        str(row.wins),
                    )
                tables.append(Layout(table))

            all_tables = Layout()
            all_tables.split(*tables)
            layout[bracket][subleague].update(
                Panel(all_tables, title=subleague, padding=0))
Example #8
0
def make_layout():
    """Define the layout."""
    layout = Layout(name="root")
    layout.split(Layout(name="header", size=4), Layout(name="main"))
    layout["main"].split_column(Layout(name="info", size=4),
                                Layout(name="body", ratio=2, minimum_size=60))
    layout["info"].split_row(Layout(name="time"), Layout(name="files"))
    return layout
Example #9
0
    def __init__(self, options=None):
        super().__init__(options)

        self.layout.split(Layout(name="upper"), Layout(name="lower"))

        self.layout["lower"].update(self.menu)
        self.layout["upper"].update(Padding("", (8, 8, 2, 2)))
        self.populate()
def get_layout() -> Layout:
    layout = Layout()
    layout.split(
        Layout(name="header", size=3)
        # Layout(name="body", size=2),
    )

    layout["header"].update(Header("Create NCR"))
    return layout
Example #11
0
def make_exit_layout() -> Layout:
    """Define the layout."""
    layout = Layout(name="root")
    message = make_message()

    layout.split(Layout(name="body", ))

    layout["body"].update(message)

    return layout
Example #12
0
def test_add_split():
    layout = Layout()
    layout.split(Layout(), Layout())
    assert len(layout.children) == 2
    layout.add_split(Layout(name="foo"))
    assert len(layout.children) == 3
    assert layout.children[2].name == "foo"
Example #13
0
def main() -> None:
    layout = Layout()
    layout.split_row(
        Layout(name="all"),
        Layout(name="bats"),
        Layout(name="run"),
        Layout(name="def"),
        Layout(name="pitch"),
    )
    layout["all"].update(Panel(
        sort_players("hitting", "defense", "baserunning", "pitching"),
        title="Overall",
    ))
    layout["bats"].update(Panel(
        sort_players("hitting"),
        title="Batting",
    ))
    layout["def"].update(Panel(
        sort_players("defense"),
        title="defense",
    ))
    layout["run"].update(Panel(
        sort_players("baserunning"),
        title="Baserunning",
    ))
    layout["pitch"].update(Panel(
        sort_players("pitching"),
        title="Pitching",
    ))
    console.print(layout)
Example #14
0
    def RichLayout(self) -> Layout:
        layout = Layout()
        layout.split(
            # Layout(name="upper"),
            Layout(" ", name="BufferTop"),
            Layout(Panel(self.calendarView.RichGrid(),
                         title="Calendar",
                         style='grey50'),
                   name="Calendar"),
            Layout(Panel(self.taskView.RichGrid(),
                         title="Tasks",
                         style='grey50'),
                   name="Tasks"),
            # Layout(Panel(str(datetime.now()), title="Console"), name="Console")
            Layout(self.inputManager.RichGrid(), name='Console')
            # Layout(" ", name="BufferBot")
            # Layout(datetime.datetime.now().strftime('%H:%M:%S') + '    ' + self.input, name='Console')
        )

        # layout["upper"].split(
        # 	Layout(Panel(self.calendarView.RichGrid(), title="Calendar"), name="Calendar"),
        # 	# Layout(Panel(self.overview.RichGrid(), title="Overview"), name="Overview"),
        # 	direction="horizontal"
        # )

        # layout['Calendar'].ratio = 2.5
        # layout['Overview'].ratio =
        layout["BufferTop"].size = 1
        layout["Tasks"].ratio = 1.5
        # layout["BufferBot"].size = 1
        layout['Console'].size = 1
        return layout
Example #15
0
def test_unsplit():
    layout = Layout()
    layout.split(Layout(), Layout())
    assert len(layout.children) == 2

    layout.unsplit()
    assert len(layout.children) == 0
Example #16
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
Example #17
0
def display_options(options, selected):
    grids = []

    for i, opt in enumerate(options):
        text = Text(f'{i + 1}. {opt}')

        if selected[opt]:
            text.stylize('yellow')

        grids.append(Layout(text))

    layout = Layout(name='options')
    layout.split(*grids, direction='horizontal')

    return layout
Example #18
0
    def __init__(self, options=None):
        super().__init__(options)

        #Upper is interactive map preview
        #Lower is menu options
        self.layout.split(Layout(name='upper'), Layout(name='lower'))

        self.sleepTime = .5

        self.maps = dict()
        self.maps["diffusion"] = Diffusion(80, 30, 300)
        self.maps["life"] = Life(140, 30, 5, 80)

        self.layout["upper"].size = 35
        self.layout["lower"].update(self.menu)
        self.populate()
Example #19
0
    def __init__(self, options = None):
        super().__init__(options)
        self.layout.split(
            Layout(name='upper'),
            Layout(name='lower')
        )

        self.layout["lower"].update(self.menu)


        self.maps = dict()
        self.maps["diffusion"] = Diffusion(80,30, 300)
        self.maps["life"] = Life(140,30,5,80)

        self.layout["upper"].size = 35
        self.populate()
Example #20
0
 def __init__(self, options = None):
     self.layout = Layout()
     self.options = options
     self.menu = Text()
     self.selection = 0
     self.selectionStyle = "red on black"
     self.populate()
Example #21
0
def test_refresh_screen():
    layout = Layout()
    layout.split_row(Layout(name="foo"), Layout(name="bar"))
    console = Console(force_terminal=True, width=20, height=5)
    console.print(layout)
    with console.screen():
        with console.capture() as capture:
            layout.refresh_screen(console, "foo")
    result = capture.get()
    print(repr(result))
    expected = "\x1b[1;1H\x1b[34m╭─\x1b[0m\x1b[34m \x1b[0m\x1b[32m'foo'\x1b[0m\x1b[34m─╮\x1b[0m\x1b[2;1H\x1b[34m│\x1b[0m Layout \x1b[34m│\x1b[0m\x1b[3;1H\x1b[34m│\x1b[0m \x1b[1m(\x1b[0m      \x1b[34m│\x1b[0m\x1b[4;1H\x1b[34m│\x1b[0m     \x1b[33mna\x1b[0m \x1b[34m│\x1b[0m\x1b[5;1H\x1b[34m╰────────╯\x1b[0m"
    assert result == expected
Example #22
0
def setup_console():
    layout = Layout(name="Autoworkflow")
    layout.split(Layout(name="main", ratio=1), )
    layout["main"].split(
        Layout(name="side"),
        Layout(name="body", ratio=2, minimum_size=60),
        direction="horizontal",
    )
    return layout
def init_render_area():
    # Divide the "screen" in to three parts
    layout.split(
        Layout(name="header", size=3),
        Layout(name="top", size=12),
        Layout(name="main", ratio=1),
        # Layout(name="cmd", size=3),
    )
    # Divide the "side" layout in to two
    layout["top"].split(
        Layout(name="leftfile", ratio=1),
        Layout(name="rightfile", ratio=1),
        direction="horizontal",
    )

    layout["header"].update(Panel("PRS Tool"))
    layout["main"].update(Panel("Loading..."))
    layout["top"]["leftfile"].update(Panel("PRS WM file will appear here"))
    layout["top"]["rightfile"].update(Panel("Genetic data will appear here"))
    console.print(layout)
Example #24
0
def make_layout() -> Layout:
    """Define the layout."""
    layout = Layout(name="root")

    layout.split(
        Layout(name="header", size=3),
        Layout(name="main", ratio=1),
        Layout(name="footer", size=5),
    )
    layout["main"].split(
        Layout(name="side"),
        Layout(name="body", ratio=2, minimum_size=40),
        direction="horizontal",
    )

    # layout["side"].split(Layout(name="box1"), Layout(name="box2"))
    return layout
Example #25
0
def test_tree():
    layout = Layout(name="root")
    layout.split(Layout("foo", size=2), Layout("bar", name="bar"))
    layout["bar"].split_row(Layout(), Layout())

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

    with console.capture() as capture:
        console.print(layout.tree, height=10)
    result = capture.get()
    print(repr(result))
    expected = "⬍ Layout(name='root')                                       \n├── ⬍ Layout(size=2)                                        \n└── ⬌ Layout(name='bar')                                    \n    ├── ⬍ Layout()                                          \n    └── ⬍ Layout()                                          \n"
    print(result, "\n", expected)
    assert result == expected
class MenuLayout:
    def __init__(self):
        self._layout = Layout()
        self._table = Table(title="AUTOBOT MENU",
                            expand=True,
                            show_lines=True,
                            box=box.SQUARE_DOUBLE_HEAD,
                            title_style="#0000ff italic")

    def __rich__(self):
        self._layout.split(
            Layout(name="head", size=3),
            Layout(name="body", ratio=1),
        )

        self._layout["body"].split_column(Layout(name="mid_section", ratio=2),
                                          Layout(name="table", ratio=3))

        # Tables
        self._table.add_column("Action Button",
                               justify="center",
                               header_style="#3be13b",
                               no_wrap=True,
                               style="#3be13b")
        self._table.add_column("Action Description",
                               justify="center",
                               header_style="bold cyan",
                               no_wrap=True,
                               style="cyan")

        self._table.add_row("1", "CREATE NCR 🧩")
        self._table.add_row("2", "CLOSE NCR  🎯")
        self._table.add_row("3", "CANCEL NCR  🧨")
        self._table.add_row("4", "LDMA PARSER  📆")
        self._table.add_row("0", "EXIT AUTOBOT  âš”")

        self._layout["head"].update(Header("WELCOME TO AUTOBOT"))
        self._layout["mid_section"].update(make_sponsor_message())
        self._layout["table"].update(self._table)
        return self._layout
Example #27
0
def _get_binance_layout(
    bin_status: BinanceStatus,
    profit_today: Dict[str, ExchangeRate],
    profit_yesterday: Dict[str, ExchangeRate],
) -> Layout:
    """
    Binance info Layout.

    :param bin_status: current binance status.
    :param profit_today: today's calculated profit.
    :param profit_yesterday: yesterday's calcualted profit.
    :return: binance renderable layout.
    """
    layout = Layout(name="binance_status")
    layout.split_row(
        Layout(
            _get_binance_status(
                bin_status,
            ),
        ),
        Layout(
            _get_profit_table(bin_status, profit_today, profit_yesterday),
            ratio=2,
        ),
    )
    return layout
Example #28
0
def make_info_panel(debugger) -> Layout:
    info_layout = Layout(name='Info')
    info_layout.split_row(Layout(name='runtime_state'),
                          Layout(name='world_state'))

    pc = debugger.executor.vm_context.code.pc + 1
    insn = debugger.executor.disasm_dict[pc]
    opcode = insn.byte
    mnemonic = insn.mnemonic
    msg = debugger.executor.vm_context.msg
    info_table = Table(box=box.SIMPLE)
    info_table.grid(padding=1)
    info_table.add_column('Key', justify="middle", style="cyan", no_wrap=True)
    info_table.add_column("Value", justify="middle", style="magenta")
    info_table.add_row('PC', f'{str(pc)} ({hex(pc)})')
    info_table.add_row('Opcode', f'{int(opcode[2:], 16)} ({opcode})')
    info_table.add_row('Mnemonic', f'{mnemonic}')
    info_table.add_row('', '')
    info_table.add_row('Sender', f'0x{msg.sender.hex()}')
    if msg.to:
        info_table.add_row('To', f'0x{msg.to.hex()}')
    elif msg.storage_address:
        info_table.add_row('To', f'0x{msg.storage_address.hex()}')
    elif msg.code_address:
        info_table.add_row('To', f'0x{msg.code_address.hex()}')
    info_table.add_row('Gas Price', str(msg.gas_price))
    info_table.add_row('Nonce', str(debugger.executor.vm_context.msg.depth))

    info_panel = Panel(
        info_table,
        box=box.ROUNDED,
        title="[b red]Runtime State",
        border_style="bright_blue",
    )

    state = debugger.executor.vm_context.state
    world_state_table = Table(box=box.SIMPLE)
    world_state_table.grid(padding=1)
    world_state_table.add_column('Key',
                                 justify="middle",
                                 style="cyan",
                                 no_wrap=True)
    world_state_table.add_column("Value", justify="middle", style="magenta")
    world_state_table.add_row('coinbase', f'{state.coinbase.hex()}')
    world_state_table.add_row('timestamp', f'{state.timestamp}')
    world_state_table.add_row('block_number', f'{state.block_number}')
    world_state_table.add_row('difficulty', f'{state.difficulty}')
    world_state_table.add_row('gas_limit', f'{state.gas_limit}')

    world_state_panel = Panel(
        world_state_table,
        box=box.ROUNDED,
        title="[b red]World State",
        border_style="bright_blue",
    )

    info_layout["runtime_state"].update(info_panel)
    info_layout["world_state"].update(world_state_panel)

    return info_layout
    def get_renderable(self):
        tasks_panel_rendered = self.tasks_panel.get_renderable()
        metrics_panel_rendered = self.metrics_panel.get_renderable()

        if tasks_panel_rendered is None and metrics_panel_rendered is None:
            return Align(
                Text(f"Waiting for test to start... ({self.test_name})"),
                align="center")

        layout = Layout()

        layout.split_row(
            Layout(name="running", visible=False),
            Layout(name="metrics", ratio=2, visible=False),
        )

        if metrics_panel_rendered is not None:
            layout["metrics"].visible = True
            layout["metrics"].update(metrics_panel_rendered)

        if tasks_panel_rendered is not None:
            layout["running"].visible = True
            layout["running"].update(tasks_panel_rendered)

        return Panel(layout, title=self.test_name)
Example #30
0
def printui():
    print()
    health = ''.join(' ' for i in range(10))
    stamina = "100"
    player_name = "Corengenie"
    player_floor = 14
#     console.print(f'''
# [bold green]Здоровье: [/bold green][white on green]{health}[/white on green]
# __ffhkfghkfghjffgggggggggggggggggggggh__
# [bold cyan]Will[/bold cyan]
#     ''', justify="center")

    layout = Layout()

    layout.split(
        Layout(name="upper"),
        Layout(name="lower")
    )
    layout["upper"].split(
        Layout(name="tabs"),
        Layout(name="stats"),
        Layout(name="maplevel"),
        direction="horizontal"
    )

    layout["upper"]["tabs"].size = 3
    layout["upper"]["stats"].size = 27
    layout["upper"]["maplevel"].size = 70

    layout["upper"]["tabs"].update("")
    layout["upper"]["stats"].update(f'''


Персонаж: {player_name}
Этаж: {player_floor}

[bold green]Здоровье: [/bold green][white on green]{health}[/white on green]
[bold gold1]Выносливость: {stamina}[bold gold1]
Очки защиты: 10
Очки уворота: 2

    
    ''')
    print(layout)