當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。