예제 #1
0
    def init_layout(self):
        for i in range(len(self.top_screens)):
            s = self.top_screens[i]
            s.app = self
            s.screen_idx = i
            self.screen_sel_buttons.append(
                Button(text="%s %s" % (s.shortcut.upper(), s.shortcut_label),
                       handler=s.screen_sel))

        self.lbl_screen = Label(text=self.top_screens[0].title)

        self.top_screen = DynamicContainer(self.get_top_screen_container)

        btn_action = Button(text="F8 Action", handler=self.f_action)
        btn_exit = Button(text="F10 Exit", handler=self.f_exit)

        self.root_container = FloatContainer(
            HSplit([
                Box(
                    body=VSplit([self.lbl_screen], align="CENTER", padding=3),
                    style="class:button-bar",
                    height=1,
                ),
                self.top_screen,
                Box(
                    body=VSplit(self.screen_sel_buttons +
                                [btn_action, btn_exit],
                                align="CENTER",
                                padding=3),
                    style="class:button-bar",
                    height=1,
                ),
            ]), self.floats)
        self.top_layout = Layout(self.root_container,
                                 focused_element=self.screen_sel_buttons[0])
예제 #2
0
파일: gui.py 프로젝트: lostatc/skiddie
    def get_root_container(self):
        solution_containers = [
            HSplit([
                self._get_grid_container(grid),
                Button(
                    "Select",
                    functools.partial(self.multi_screen.app.exit,
                                      result=grid)),
            ]) for grid in self.solution_grids
        ]

        challenge_grid_container = Box(
            self._get_grid_container(self.challenge_grid))

        return FloatContainer(
            Box(
                Frame(
                    HSplit(
                        [
                            challenge_grid_container,
                            VSplit(
                                solution_containers,
                                padding=2,
                            ),
                        ],
                        padding=1,
                    ), ), ),
            floats=[],
        )
예제 #3
0
파일: gui.py 프로젝트: lostatc/skiddie
    def get_root_container(self) -> FloatContainer:
        header_row = self.table.format_table().splitlines()[0]
        data_rows = self.table.format_table().splitlines()[1:]

        row_buttons = [
            SelectableLabel(row,
                            handler=functools.partial(self._handle_answer, i))
            for i, row in enumerate(data_rows)
        ]

        table_container = HSplit([
            Label(FormattedText([("class:column-name", header_row)]), ),
            HorizontalLine(),
            *row_buttons,
        ])

        rules_container = Box(
            Label(
                self.table.format_constraints(separator="\n\n"),
                dont_extend_width=True,
            ), )

        return FloatContainer(
            Box(
                Frame(
                    VSplit([
                        table_container,
                        VerticalLine(),
                        rules_container,
                    ])), ),
            floats=[],
        )
예제 #4
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.riitag_info = user.RiitagInfo()  # placeholder

        self.menu_settings_button = Button(
            'Settings', handler=lambda: self._set_state('Settings'))
        self.menu_exit_button = Button('Exit', handler=self.quit_app)
        self.menu_logout_button = Button('Logout', handler=self._logout)

        self.settings_back_button = Button(
            'Back...', width=12, handler=lambda: self._set_state('Menu'))
        self.settings_reset_button = Button('Reset...',
                                            width=12,
                                            handler=self._reset_preferences)
        self.settings_pres_timeout_button = PreferenceButton(
            value=self.app.preferences.presence_timeout,
            increments=10,
            limits=(10, 120))
        self.settings_check_interval_button = PreferenceButton(
            value=self.app.preferences.check_interval,
            increments=10,
            limits=(10, 60))

        self.right_panel_state = 'Menu'
        self.menu_layout = Frame(Box(HSplit([
            self.menu_settings_button,
            Label(''),
            self.menu_exit_button,
            self.menu_logout_button,
        ]),
                                     padding_left=3,
                                     padding_top=2),
                                 title='Menu')
        self.settings_layout = Frame(Box(HSplit([
            Window(FormattedTextControl(
                HTML(
                    'This is where you can modify settings\nregarding the underlying presence\nwatcher.'
                )),
                   wrap_lines=True,
                   width=25),
            Label(''),
            VSplit([
                Label('Presence Timeout (min.):'),
                self.settings_pres_timeout_button
            ],
                   width=15),
            VSplit([
                Label('Refresh Interval (sec.):'),
                self.settings_check_interval_button
            ],
                   padding=3),
            Label(''),
            VSplit([self.settings_back_button, self.settings_reset_button],
                   align=WindowAlign.CENTER)
        ]),
                                         padding_left=3,
                                         padding_top=2),
                                     title='Settings')
예제 #5
0
def progress_dialog(
    title: AnyFormattedText = "",
    text: AnyFormattedText = "",
    run_callback: Callable[[Callable[[int], None], Callable[[str], None]], None] = (
        lambda *a: None
    ),
    style: Optional[BaseStyle] = None,
) -> Application[None]:
    """
    :param run_callback: A function that receives as input a `set_percentage`
        function and it does the work.
    """
    loop = get_event_loop()
    progressbar = ProgressBar()
    text_area = TextArea(
        focusable=False,
        # Prefer this text area as big as possible, to avoid having a window
        # that keeps resizing when we add text to it.
        height=D(preferred=10 ** 10),
    )

    dialog = Dialog(
        body=HSplit(
            [
                Box(Label(text=text)),
                Box(text_area, padding=D.exact(1)),
                progressbar,
            ]
        ),
        title=title,
        with_background=True,
    )
    app = _create_app(dialog, style)

    def set_percentage(value: int) -> None:
        progressbar.percentage = int(value)
        app.invalidate()

    def log_text(text: str) -> None:
        loop.call_soon_threadsafe(text_area.buffer.insert_text, text)
        app.invalidate()

    # Run the callback in the executor. When done, set a return value for the
    # UI, so that it quits.
    def start() -> None:
        try:
            run_callback(set_percentage, log_text)
        finally:
            app.exit()

    def pre_run() -> None:
        run_in_executor_with_context(start)

    app.pre_run_callables.append(pre_run)

    return app
예제 #6
0
def progress_dialog(title='',
                    text='',
                    run_callback=None,
                    style=None,
                    async_=False):
    """
    :param run_callback: A function that receives as input a `set_percentage`
        function and it does the work.
    """
    assert callable(run_callback)

    progressbar = ProgressBar()
    text_area = TextArea(
        focusable=False,

        # Prefer this text area as big as possible, to avoid having a window
        # that keeps resizing when we add text to it.
        height=D(preferred=10**10))

    dialog = Dialog(body=HSplit([
        Box(Label(text=text)),
        Box(text_area, padding=D.exact(1)),
        progressbar,
    ]),
                    title=title,
                    with_background=True)
    app = _create_app(dialog, style)

    def set_percentage(value):
        progressbar.percentage = int(value)
        app.invalidate()

    def log_text(text):
        text_area.buffer.insert_text(text)
        app.invalidate()

    # Run the callback in the executor. When done, set a return value for the
    # UI, so that it quits.
    def start():
        try:
            run_callback(set_percentage, log_text)
        finally:
            app.exit()

    run_in_executor(start)

    if async_:
        return app.run_async()
    else:
        return app.run()
예제 #7
0
    def get_root_container(self) -> FloatContainer:
        buttons = [
            *self._game_buttons.keys(),
            HorizontalLine(),
            Button("Quit", width=MENU_BUTTON_WIDTH, handler=self._exit),
        ]

        menu_keybindings = _create_menu_keybindings(buttons)

        game_buttons_container = Frame(
            HSplit(
                buttons,
                width=Dimension(min=MENU_BUTTON_WIDTH, max=40),
                height=Dimension(),
            ),
            title="Games",
            key_bindings=menu_keybindings,
        )

        game_description_container = Frame(
            Box(
                Label(
                    text=self._get_game_description,
                    dont_extend_height=False,
                    width=Dimension(min=40),
                ),
                padding=0,
                padding_left=1,
            ), )

        return FloatContainer(VSplit([
            game_buttons_container,
            game_description_container,
        ]),
                              floats=[])
예제 #8
0
    def __init__(self,
                 title: str = "DLNest Output",
                 routineTask=None,
                 freq: int = 1,
                 style: str = "class_analyzer_output"):
        super(AnalyzeOutput, self).__init__(title, routineTask, freq, style)

        self.infoText = FormattedTextControl(
            [("", "           No analyze task is running           ")],
            focusable=False,
            show_cursor=False)

        self.infoWindow = Window(content=self.infoText)

        self.infoLabel = Box(
            body=self.infoWindow,
            height=3,
            padding_top=1,
            padding_bottom=1,
            # padding_left=3,
            # padding_right=3,
            style="class:analyzer_info_label")

        self.window = Frame(HSplit([self.infoLabel, self.shower]),
                            title=self.title,
                            style=self.style,
                            modal=True,
                            key_bindings=self.kb)
예제 #9
0
def MenuScreen(controller):
    def on_start_click():
        new_state = PlayingScreenState(username=controller.state.username,
                                       choice_history=[root_branch],
                                       choice_index=0,
                                       start_time=time())
        controller.set_state(new_state)

    def on_help_click():
        new_state = HelpScreenState(username=controller.state.username,
                                    previous_state=controller.state)
        controller.set_state(new_state)

    buttons = [
        Button('start', handler=on_start_click),
        Button('help', handler=on_help_click),
        Button('quit', handler=exit_current_app)
    ]

    kb = create_vertical_button_list_kbs(buttons)

    body = Box(
        VSplit([
            HSplit(children=buttons,
                   padding=Dimension(preferred=1, max=1),
                   key_bindings=kb)
        ]))

    toolbar_content = Window(content=FormattedTextControl(
        'Hello %s. I wish you the best of luck...' %
        controller.state.username),
                             align=WindowAlign.CENTER,
                             height=1)

    return ToolbarFrame(body, toolbar_content)
예제 #10
0
    def process_steps(self):
        if self.intro:
            layout = Window(
                FormattedTextControl(to_formatted_text(HTML(self.intro))),
                wrap_lines=True,
            )
            self.steps.append(
                {
                    'layout': layout,
                    'label': 'Introduction',
                    'handler': None,
                }, )

        for handler in self.handlers:
            layout = handler.get_layout()
            layout.align = HorizontalAlign.JUSTIFY
            self.steps.append(
                {
                    'layout': layout,
                    'label': handler.get_label(),
                    'handler': handler,
                }, )

        if self.summary:
            layout = Box(
                body=DynamicContainer(self.get_summary),
                padding=D(preferred=1, max=1),
                padding_bottom=1,
            )
            self.steps.append(
                {
                    'layout': layout,
                    'label': 'Summary',
                    'handler': None,
                }, )
예제 #11
0
 def _box(self, body):
     return Box(
         body=body,
         height=Dimension(min=1),
         width=Dimension(min=1, weight=4),
         padding=1,
     )
예제 #12
0
def PlayingScreen(controller):
    current_component = get_current_choice(controller)
    component = current_component(controller)
    body = component.render()
    username = controller.state.username
    choice_history = controller.state.choice_history
    choice_index = controller.state.choice_index

    def on_back_click():
        new_state = PlayingScreenState(username=username,
                                       choice_history=choice_history,
                                       choice_index=choice_index - 1,
                                       start_time=controller.state.start_time)
        controller.set_state(new_state)

    def on_help_click():
        new_state = HelpScreenState(username=username,
                                    previous_state=controller.state)
        controller.set_state(new_state)

    def on_menu_click():
        new_state = MenuScreenState(username)
        controller.set_state(new_state)

    def on_next_click():
        new_state = PlayingScreenState(username=username,
                                       choice_history=choice_history,
                                       choice_index=choice_index + 1,
                                       start_time=controller.state.start_time)
        controller.set_state(new_state)

    buttons = [
        Button('help', handler=on_help_click),
        Button('menu', handler=on_menu_click),
        Button('quit', handler=exit_current_app)
    ]

    if choice_index > 0:
        buttons.insert(0, Button('(back)', handler=on_back_click))

    if choice_index < len(choice_history) - 1:
        buttons.append(Button('(next)', handler=on_next_click))

    kb = create_horizontal_button_list_kbs(buttons)

    is_button_focused = reduce(lambda a, b: a | b, map(has_focus, buttons))

    def reset_focus(_):
        component.refocus()

    kb.add('down', filter=is_button_focused)(reset_focus)

    toolbar_content = Box(VSplit(children=buttons,
                                 align=HorizontalAlign.CENTER,
                                 key_bindings=kb),
                          height=1)

    return ToolbarFrame(body, toolbar_content, put_on_top=True)
예제 #13
0
    def get_questions_widgets(self):
        question_widgets = [
            Frame(body=Label(text=unicode(self.header))),
        ]
        question_widgets += self.questions.get_widgets_list()

        create_button = Button(u"Create", handler=self.accept_create)
        exit_button = Button(u"Exit", handler=self.accept_exit)
        question_widgets.append(Box(VSplit([create_button, exit_button])))
        return question_widgets
예제 #14
0
    def creationLayoutFactory(self):

        root_container = Box(
            Frame(
                TextArea(
                    text="CREATION layout placeholder",
                    width=40,
                    height=10,
                )), )

        return Layout(container=root_container)
예제 #15
0
    def editingLayoutFactory(self):  #TODO

        root_container = Box(
            Frame(
                TextArea(
                    text="EDITING layout placeholder",
                    width=40,
                    height=10,
                )), )

        return Layout(container=root_container)
예제 #16
0
    def removingLayoutFactory(self):  #TODO

        root_container = Box(
            Frame(
                TextArea(
                    text="DELETE layout placeholder",
                    width=40,
                    height=10,
                )), )

        return Layout(container=root_container)
예제 #17
0
    def render(self):
        current_time = time()
        time_played = current_time - self._controller.state.start_time

        return Box(TextArea(
            text=self._label.format(name=self._controller.state.username) +
            '\n\nTime Played:\n' + format_time(time_played) + '\n',
            read_only=True,
            focusable=False,
            scrollbar=True),
                   padding=1)
예제 #18
0
파일: gui.py 프로젝트: lostatc/skiddie
 def _get_grid_container(pattern_grid: PatternGrid):
     """Get a container for a given pattern grid."""
     return Frame(
         Box(
             Label(
                 text=pattern_grid.format_grid,
                 dont_extend_width=True,
             ),
             padding_left=1,
             padding_right=1,
         ), )
예제 #19
0
파일: menus.py 프로젝트: 6200m/RiiTag-RPC
    def get_layout(self):
        game_labels = []
        for game in self.riitag_info.games:
            if not game:
                continue

            console_and_game_id = game.split('-')
            if len(console_and_game_id) == 2:
                console: str = console_and_game_id[0]
                game_id: str = console_and_game_id[1]

                label_text = f'<b>-</b> {game_id} ({console.title()})'
            else:
                label_text = f'<b>-</b> {console_and_game_id[0]}'
            game_labels.append(Label(HTML(label_text)))

        right_panel_layout = HSplit([])
        if self.right_panel_state == 'Menu':
            right_panel_layout = self.menu_layout
        elif self.right_panel_state == 'Settings':
            right_panel_layout = self.settings_layout

        return HSplit([
            Box(
                Label(text='Use the arrow keys and enter to navigate.'),
                height=3,
                padding_left=2
            ),
            VSplit([
                Frame(
                    Box(
                        HSplit([
                            Label(HTML(f'<b>Name:</b>   {self.riitag_info.name}')),
                            Label(HTML(f'<b>Games:</b>  {len(game_labels)}')),
                            *game_labels
                        ]), padding_left=3, padding_top=2
                    ), title='RiiTag'),
                right_panel_layout
            ])
        ])
예제 #20
0
    def get_root_container(self) -> FloatContainer:
        tree_lines = self.tree.format_tree(hide_values=True).splitlines()
        self.node_inputs = [
            TextArea(wrap_lines=False,
                     style="class:tree-node",
                     width=NODE_INPUT_WIDTH) for _ in self.tree.descendants
        ]
        tree_labels = [
            Label(line, dont_extend_width=True) for line in tree_lines
        ]

        tree_input_container = Frame(
            HSplit([
                VSplit([label, button])
                for label, button in zip(tree_labels, self.node_inputs)
            ]),
            title="Tree",
        )

        buttons = [
            Button("Done", handler=self.handle_input_confirm),
        ]

        button_container = Box(VSplit(buttons, padding=4), padding_top=1)

        tree_panel_container = Box(
            HSplit([
                tree_input_container,
                button_container,
            ]))

        table_container = Label(self.closure_table.format_table())

        root_container = FloatContainer(
            VSplit([tree_panel_container, table_container]),
            floats=[],
        )

        return root_container
예제 #21
0
    def _create_ui(self):
        btn_start = Button("Start", handler=self.tomato.start)
        btn_pause = Button("Pause", handler=self.tomato.pause)
        btn_reset = Button("Reset", handler=self.tomato.reset)
        btn_reset_all = Button("Reset All", handler=self.tomato.reset_all)
        btn_exit = Button("Exit", handler=self._exit_clicked)
        # All the widgets for the UI.
        self.text_area = FormattedTextControl(focusable=False,
                                              show_cursor=False)
        text_window = Window(
            content=self.text_area,
            dont_extend_height=True,
            height=11,
            style="bg:#ffffff #000000",
        )
        root_container = Box(
            HSplit([
                Label(text="Press `Tab` to move the focus."),
                HSplit([
                    VSplit(
                        [
                            btn_start,
                            btn_pause,
                            btn_reset,
                            btn_reset_all,
                            btn_exit,
                        ],
                        padding=1,
                        style="bg:#cccccc",
                    ),
                    text_window,
                ]),
            ]))
        layout = Layout(container=root_container, focused_element=btn_start)
        self._set_key_bindings()

        # Styling.
        style = Style([
            ("left-pane", "bg:#888800 #000000"),
            ("right-pane", "bg:#00aa00 #000000"),
            ("button", "#000000"),
            ("button-arrow", "#000000"),
            ("button focused", "bg:#ff0000"),
            ("red", "#ff0000"),
            ("green", "#00ff00"),
        ])
        self.application = Application(layout=layout,
                                       key_bindings=self.kb,
                                       style=style,
                                       full_screen=True)
예제 #22
0
def HelpScreen(controller):
    body = Box(TextArea(help_text, focusable=False, scrollbar=True),
               padding=0,
               padding_left=1,
               padding_right=1)

    def on_back_click():
        new_state = controller.state.previous_state
        controller.set_state(new_state)

    buttons = [
        Button('back', handler=on_back_click),
        Button('quit', handler=exit_current_app)
    ]

    kb = create_horizontal_button_list_kbs(buttons)

    toolbar_content = Box(VSplit(children=buttons,
                                 align=HorizontalAlign.CENTER,
                                 padding=Dimension(preferred=10, max=10),
                                 key_bindings=kb),
                          height=1)

    return ToolbarFrame(body, toolbar_content)
예제 #23
0
파일: main.py 프로젝트: bwalkowi/wdsjn
def create_app(listen_handler, home):

    # components
    logo = Label(text=LOGO)
    text_area = TextArea(text=str(home), read_only=True, scrollbar=True)

    listen_btn = Button('Listen', handler=listen_handler(text_area=text_area))
    help_btn = Button('Help', handler=help_handler)
    exit_btn = Button('Exit', handler=lambda: get_app().exit())

    buttons = HSplit(children=[
        Label(text='     MENU'),
        Frame(listen_btn),
        Frame(help_btn),
        Frame(exit_btn)
    ],
                     style='bg:#00aa00 #000000')

    # root container
    root_container = FloatContainer(HSplit([
        Box(body=VSplit([buttons, logo], padding=12),
            padding=0,
            style='bg:#888800 #000000'),
        text_area,
    ]),
                                    floats=[])

    # key bindings
    bindings = KeyBindings()
    bindings.add('tab')(focus_next)
    bindings.add('s-tab')(focus_previous)

    @bindings.add('c-c')
    @bindings.add('q')
    def _(event):
        event.app.exit()

    # application
    application = Application(layout=Layout(root_container,
                                            focused_element=listen_btn),
                              key_bindings=bindings,
                              enable_page_navigation_bindings=True,
                              mouse_support=True,
                              full_screen=True)
    return application
예제 #24
0
    def render(self):
        choices_len = len(self._choices)

        buttons = [
            Button('[%s] %s' % (i, label) if choices_len > 1 else label,
                   handler=self._create_handler(sub_component))
            for ((label, sub_component),
                 i) in zip(self._choices, range(
                     1, choices_len +
                     1))  # this is still a loop even if it is inline..
        ]

        self._first_button = buttons[0]

        global global__default_target_focus
        global__default_target_focus = self._first_button

        kb = create_vertical_button_list_kbs(buttons)

        is_first_selected = has_focus(buttons[0])
        kb.add('up', filter=is_first_selected)(lambda e: focus_first_element())

        return Box(
            HSplit(
                [
                    TextArea(
                        text=self._label.format(
                            name=self._controller.state.username) + '\n',
                        read_only=True,
                        focusable=False,
                        scrollbar=True,
                        # push buttons to bottom of screen
                        height=Dimension(preferred=100000, max=100000)),
                    HSplit([
                        VSplit(children=[button], align=HorizontalAlign.CENTER)
                        for button in buttons
                    ],
                           padding=1,
                           key_bindings=kb)
                ],
                padding=Dimension(preferred=2, max=2),
                width=Dimension(),
                align=VerticalAlign.TOP),
            padding=1)
예제 #25
0
    def __init__(self, buffer):

        self.buffer_control = BufferControl(
            buffer=buffer,
            focusable=True,
            key_bindings=self._get_key_bindings(),
            focus_on_click=True,
        )

        self.window = Window(
            content=self.buffer_control,
            right_margins=[ScrollbarMargin(display_arrows=True)],
        )
        self.window = Frame(body=Box(
            self.window,
            padding_left=2,
            padding_right=2,
            padding_top=0,
            padding_bottom=0,
        ))
예제 #26
0
    def refresh(self, sort_by=None, order=None):

        names = update_servers(sort_by=sort_by, order=order)

        self.server_list = []
        for name in names:
            button_obj = ButtonManager(name)
            button = CustomButton(name, handler=button_obj.click_handler)
            self.server_list.append(button)

        # If there are no servers
        if not self.server_list:
            from prompt_toolkit.layout.containers import Window
            from prompt_toolkit.layout.controls import FormattedTextControl

            window = Window(
                FormattedTextControl(
                    'No Servers',
                    focusable=True,
                    show_cursor=False
                )
            )

            self.server_list.append(window)

        self.hsplit = HSplit(self.server_list)

        boxes = Box(
            width=SERVER_WIDTH,
            padding_top=0,
            padding_left=1,
            body=self.hsplit
        )

        from freud.key_bindings import server_kb

        self.content = HSplit([
            boxes
        ], key_bindings=server_kb)

        return self.content
예제 #27
0
    def create_container(self):

        container = HSplit([
            Box(body=VSplit([self.input_window, self.cancel_button],
                            padding=1),
                padding=1,
                style="class:preview-input-field"),
            Window(height=1, char="-", style="class:preview-divider-line"),
            self.output_field,
            self.search_field,
        ])

        frame = Shadow(body=Frame(
            title=lambda: "Preview: " + self.my_app.selected_object.name,
            body=container,
            style="class:dialog.body",
            width=D(preferred=180, min=30),
            modal=True))

        return ConditionalContainer(content=frame,
                                    filter=ShowPreview(self.my_app) & ~is_done)
예제 #28
0
    def get_layout(self):
        widget = self.get_widget()
        vsplit_components = [widget]
        if 'message' in self._question and self._question['message']:
            vsplit_components.insert(
                0,
                Label(
                    self._question['message'],
                    dont_extend_width=True,
                    dont_extend_height=False,
                    style='class:selectone.question',
                ),
            )

        btn_all = Button('All', widget.select_all)
        btn_none = Button('None', widget.select_none)
        buttons = Box(
            body=VSplit([btn_all, btn_none], padding=1),
            height=D(min=1, max=3, preferred=3),
            padding_left=0,
        )

        hsplit_components = [buttons, VSplit(vsplit_components, padding=1)]
        if 'description' in self._question and self._question['description']:
            hsplit_components.insert(
                0,
                Window(
                    FormattedTextControl(
                        FormattedText([(
                            'class:selectone.question',
                            self._question['description'],
                        )]), ),
                    wrap_lines=True,
                    height=D(min=1, max=5, preferred=3),
                ),
            )
        return HSplit(hsplit_components, padding=1)
예제 #29
0
def generate_layout(input_field: TextArea,
                    output_field: TextArea,
                    log_field: TextArea,
                    right_pane_toggle: Button,
                    log_field_button: Button,
                    search_field: SearchToolbar,
                    timer: TextArea,
                    process_monitor: TextArea,
                    trade_monitor: TextArea,
                    command_tabs: Dict[str, CommandTab],
                    ):
    components = {}

    components["item_top_version"] = Window(FormattedTextControl(get_version), style="class:header")
    components["item_top_active"] = Window(FormattedTextControl(get_active_strategy), style="class:header")
    components["item_top_file"] = Window(FormattedTextControl(get_strategy_file), style="class:header")
    components["item_top_gateway"] = Window(FormattedTextControl(get_gateway_status), style="class:header")
    components["item_top_toggle"] = right_pane_toggle
    components["pane_top"] = VSplit([components["item_top_version"],
                                     components["item_top_active"],
                                     components["item_top_file"],
                                     components["item_top_gateway"],
                                     components["item_top_toggle"]], height=1)
    components["pane_bottom"] = VSplit([trade_monitor,
                                        process_monitor,
                                        timer], height=1)
    output_pane = Box(body=output_field, padding=0, padding_left=2, style="class:output-field")
    input_pane = Box(body=input_field, padding=0, padding_left=2, padding_top=1, style="class:input-field")
    components["pane_left"] = HSplit([output_pane, input_pane], width=Dimension(weight=1))
    if all(not t.is_selected for t in command_tabs.values()):
        log_field_button.window.style = "class:tab_button.focused"
    else:
        log_field_button.window.style = "class:tab_button"
    tab_buttons = [log_field_button]
    for tab in sorted(command_tabs.values(), key=lambda x: x.tab_index):
        if tab.button is not None:
            if tab.is_selected:
                tab.button.window.style = "class:tab_button.focused"
            else:
                tab.button.window.style = "class:tab_button"
            tab.close_button.window.style = tab.button.window.style
            tab_buttons.append(VSplit([tab.button, tab.close_button]))
    pane_right_field = log_field
    focused_right_field = [tab.output_field for tab in command_tabs.values() if tab.is_selected]
    if focused_right_field:
        pane_right_field = focused_right_field[0]
    components["pane_right_top"] = VSplit(tab_buttons, height=1, style="class:log-field", padding_char=" ", padding=2)
    components["pane_right"] = ConditionalContainer(
        Box(body=HSplit([components["pane_right_top"], pane_right_field, search_field], width=Dimension(weight=1)),
            padding=0, padding_left=2, style="class:log-field"),
        filter=True
    )
    components["hint_menus"] = [Float(xcursor=True,
                                      ycursor=True,
                                      transparent=True,
                                      content=CompletionsMenu(max_height=16,
                                                              scroll_offset=1))]

    root_container = HSplit([
        components["pane_top"],
        VSplit(
            [FloatContainer(components["pane_left"], components["hint_menus"]),
             components["pane_right"]]),
        components["pane_bottom"],
    ])
    return Layout(root_container, focused_element=input_field), components
예제 #30
0
        textfield,
    ], height=D()),
    VSplit([
        Frame(body=ProgressBar(),
              title='Progress bar'),
        Frame(title='Checkbox list',
              body=HSplit([
                  checkbox1,
                  checkbox2,
              ])),
        Frame(title='Radio list', body=radios),
    ], padding=1),
    Box(
        body=VSplit([
            yes_button,
            no_button,
        ], align='CENTER', padding=3),
        style='class:button-bar',
        height=3,
    ),
])

root_container = MenuContainer(body=root_container, menu_items=[
    MenuItem('File', children=[
        MenuItem('New'),
        MenuItem('Open', children=[
            MenuItem('From file...'),
            MenuItem('From URL...'),
            MenuItem('Something else..', children=[
                MenuItem('A'),
                MenuItem('B'),
                MenuItem('C'),