当前位置: 首页>>代码示例>>Python>>正文


Python controls.FormattedTextControl方法代码示例

本文整理汇总了Python中prompt_toolkit.layout.controls.FormattedTextControl方法的典型用法代码示例。如果您正苦于以下问题:Python controls.FormattedTextControl方法的具体用法?Python controls.FormattedTextControl怎么用?Python controls.FormattedTextControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在prompt_toolkit.layout.controls的用法示例。


在下文中一共展示了controls.FormattedTextControl方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: python_sidebar_navigation

# 需要导入模块: from prompt_toolkit.layout import controls [as 别名]
# 或者: from prompt_toolkit.layout.controls import FormattedTextControl [as 别名]
def python_sidebar_navigation(python_input):
    """
    Create the `Layout` showing the navigation information for the sidebar.
    """

    def get_text_fragments():
        # Show navigation info.
        return [
            ("class:sidebar", "    "),
            ("class:sidebar.key", "[Arrows]"),
            ("class:sidebar", " "),
            ("class:sidebar.description", "Navigate"),
            ("class:sidebar", " "),
            ("class:sidebar.key", "[Enter]"),
            ("class:sidebar", " "),
            ("class:sidebar.description", "Hide menu"),
        ]

    return Window(
        FormattedTextControl(get_text_fragments),
        style="class:sidebar",
        width=Dimension.exact(43),
        height=Dimension.exact(1),
    ) 
开发者ID:prompt-toolkit,项目名称:ptpython,代码行数:26,代码来源:layout.py

示例2: exit_confirmation

# 需要导入模块: from prompt_toolkit.layout import controls [as 别名]
# 或者: from prompt_toolkit.layout.controls import FormattedTextControl [as 别名]
def exit_confirmation(
    python_input: "PythonInput", style="class:exit-confirmation"
) -> Container:
    """
    Create `Layout` for the exit message.
    """

    def get_text_fragments() -> StyleAndTextTuples:
        # Show "Do you really want to exit?"
        return [
            (style, "\n %s ([y]/n)" % python_input.exit_message),
            ("[SetCursorPosition]", ""),
            (style, "  \n"),
        ]

    visible = ~is_done & Condition(lambda: python_input.show_exit_confirmation)

    return ConditionalContainer(
        content=Window(
            FormattedTextControl(get_text_fragments), style=style
        ),  # , has_focus=visible)),
        filter=visible,
    ) 
开发者ID:prompt-toolkit,项目名称:ptpython,代码行数:25,代码来源:layout.py

示例3: __init__

# 需要导入模块: from prompt_toolkit.layout import controls [as 别名]
# 或者: from prompt_toolkit.layout.controls import FormattedTextControl [as 别名]
def __init__(self, pymux, client_state):
        self.pymux = pymux
        self.client_state = client_state

        # Popup dialog for displaying keys, etc...
        search_textarea = SearchToolbar()
        self._popup_textarea = TextArea(scrollbar=True, read_only=True, search_field=search_textarea)
        self.popup_dialog = Dialog(
            title='Keys',
            body=HSplit([
                Window(FormattedTextControl(text=''), height=1),  # 1 line margin.
                self._popup_textarea,
                search_textarea,
                Window(
                    FormattedTextControl(
                        text=HTML('Press [<b>q</b>] to quit or [<b>/</b>] for searching.')),
                    align=WindowAlign.CENTER,
                    height=1)
                ])
            )

        self.layout = self._create_layout()

        # Keep track of render information.
        self.pane_write_positions = {} 
开发者ID:prompt-toolkit,项目名称:pymux,代码行数:27,代码来源:layout.py

示例4: __init__

# 需要导入模块: from prompt_toolkit.layout import controls [as 别名]
# 或者: from prompt_toolkit.layout.controls import FormattedTextControl [as 别名]
def __init__(self, editor):
        once_hidden = [False]  # Nonlocal

        def condition():
            # Get editor buffers
            buffers = editor.window_arrangement.editor_buffers

            # Only show when there is only one empty buffer, but once the
            # welcome message has been hidden, don't show it again.
            result = (len(buffers) == 1 and buffers[0].buffer.text == '' and
                      buffers[0].location is None and not once_hidden[0])
            if not result:
                once_hidden[0] = True
            return result

        super(WelcomeMessageWindow, self).__init__(
            Window(
                FormattedTextControl(lambda: WELCOME_MESSAGE_TOKENS),
                align=WindowAlign.CENTER,
                style="class:welcome"),
            filter=Condition(condition)) 
开发者ID:prompt-toolkit,项目名称:pyvim,代码行数:23,代码来源:layout.py

示例5: python_sidebar_help

# 需要导入模块: from prompt_toolkit.layout import controls [as 别名]
# 或者: from prompt_toolkit.layout.controls import FormattedTextControl [as 别名]
def python_sidebar_help(python_input):
    """
    Create the `Layout` for the help text for the current item in the sidebar.
    """
    token = "class:sidebar.helptext"

    def get_current_description():
        """
        Return the description of the selected option.
        """
        i = 0
        for category in python_input.options:
            for option in category.options:
                if i == python_input.selected_option_index:
                    return option.description
                i += 1
        return ""

    def get_help_text():
        return [(token, get_current_description())]

    return ConditionalContainer(
        content=Window(
            FormattedTextControl(get_help_text), style=token, height=Dimension(min=3)
        ),
        filter=ShowSidebar(python_input)
        & Condition(lambda: python_input.show_sidebar_help)
        & ~is_done,
    ) 
开发者ID:prompt-toolkit,项目名称:ptpython,代码行数:31,代码来源:layout.py

示例6: meta_enter_message

# 需要导入模块: from prompt_toolkit.layout import controls [as 别名]
# 或者: from prompt_toolkit.layout.controls import FormattedTextControl [as 别名]
def meta_enter_message(python_input: "PythonInput") -> Container:
    """
    Create the `Layout` for the 'Meta+Enter` message.
    """

    def get_text_fragments() -> StyleAndTextTuples:
        return [("class:accept-message", " [Meta+Enter] Execute ")]

    @Condition
    def extra_condition() -> bool:
        " Only show when... "
        b = python_input.default_buffer

        return (
            python_input.show_meta_enter_message
            and (
                not b.document.is_cursor_at_the_end
                or python_input.accept_input_on_enter is None
            )
            and "\n" in b.text
        )

    visible = ~is_done & has_focus(DEFAULT_BUFFER) & extra_condition

    return ConditionalContainer(
        content=Window(FormattedTextControl(get_text_fragments)), filter=visible
    ) 
开发者ID:prompt-toolkit,项目名称:ptpython,代码行数:29,代码来源:layout.py

示例7: generate_layout

# 需要导入模块: from prompt_toolkit.layout import controls [as 别名]
# 或者: from prompt_toolkit.layout.controls import FormattedTextControl [as 别名]
def generate_layout(input_field: TextArea,
                    output_field: TextArea,
                    log_field: TextArea,
                    search_field: SearchToolbar):
    root_container = HSplit([
        VSplit([
            Window(FormattedTextControl(get_version), style="class:title"),
            Window(FormattedTextControl(get_paper_trade_status), style="class:title"),
            Window(FormattedTextControl(get_title_bar_right_text), align=WindowAlign.RIGHT, style="class:title"),
        ], height=1),
        VSplit([
            FloatContainer(
                HSplit([
                    output_field,
                    Window(height=1, char='-', style='class:primary'),
                    input_field,
                ]),
                [
                    # Completion menus.
                    Float(xcursor=True,
                          ycursor=True,
                          transparent=True,
                          content=CompletionsMenu(
                              max_height=16,
                              scroll_offset=1)),
                ]
            ),
            Window(width=1, char='|', style='class:primary'),
            HSplit([
                log_field,
                search_field,
            ]),
        ]),

    ])
    return Layout(root_container, focused_element=input_field) 
开发者ID:CoinAlpha,项目名称:hummingbot,代码行数:38,代码来源:layout.py

示例8: show_sidebar_button_info

# 需要导入模块: from prompt_toolkit.layout import controls [as 别名]
# 或者: from prompt_toolkit.layout.controls import FormattedTextControl [as 别名]
def show_sidebar_button_info(python_input: "PythonInput") -> Container:
    """
    Create `Layout` for the information in the right-bottom corner.
    (The right part of the status bar.)
    """

    @if_mousedown
    def toggle_sidebar(mouse_event: MouseEvent) -> None:
        " Click handler for the menu. "
        python_input.show_sidebar = not python_input.show_sidebar

    version = sys.version_info
    tokens: StyleAndTextTuples = [
        ("class:status-toolbar.key", "[F2]", toggle_sidebar),
        ("class:status-toolbar", " Menu", toggle_sidebar),
        ("class:status-toolbar", " - "),
        (
            "class:status-toolbar.python-version",
            "%s %i.%i.%i"
            % (platform.python_implementation(), version[0], version[1], version[2]),
        ),
        ("class:status-toolbar", " "),
    ]
    width = fragment_list_width(tokens)

    def get_text_fragments() -> StyleAndTextTuples:
        # Python version
        return tokens

    return ConditionalContainer(
        content=Window(
            FormattedTextControl(get_text_fragments),
            style="class:status-toolbar",
            height=Dimension.exact(1),
            width=Dimension.exact(width),
        ),
        filter=~is_done
        & renderer_height_is_known
        & Condition(
            lambda: python_input.show_status_bar
            and not python_input.show_exit_confirmation
        ),
    ) 
开发者ID:prompt-toolkit,项目名称:ptpython,代码行数:45,代码来源:layout.py


注:本文中的prompt_toolkit.layout.controls.FormattedTextControl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。