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


Python textpad.Textbox方法代码示例

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


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

示例1: search

# 需要导入模块: from curses import textpad [as 别名]
# 或者: from curses.textpad import Textbox [as 别名]
def search(self):
        """Open search window, get input and set the search string."""
        if self.init_search is not None:
            return
        scr2 = curses.newwin(3, self.max_x, self.max_y - 3, 0)
        scr3 = scr2.derwin(1, self.max_x - 12, 1, 9)
        scr2.box()
        scr2.move(1, 1)
        addstr(scr2, "Search: ")
        scr2.refresh()
        curses.curs_set(1)
        self._search_win_open = 3
        self.textpad = Textbox(scr3, insert_mode=True)
        self.search_str = self.textpad.edit(self._search_validator)
        self.search_str = self.search_str.lower().strip()
        try:
            curses.curs_set(0)
        except _curses.error:
            pass
        if self.search_str:
            self.init_search = None
        self._search_win_open = 0 
开发者ID:OpenTrading,项目名称:OpenTrader,代码行数:24,代码来源:tabview.py

示例2: _screen_create_command_textbox

# 需要导入模块: from curses import textpad [as 别名]
# 或者: from curses.textpad import Textbox [as 别名]
def _screen_create_command_textbox(self, existing_command=None):
    """Create command textbox on screen.

    Args:
      existing_command: (str) A command string to put in the textbox right
        after its creation.
    """

    # Display the tfdbg prompt.
    self._stdscr.addstr(self._max_y - self._command_textbox_height, 0,
                        self.CLI_PROMPT, curses.A_BOLD)
    self._stdscr.refresh()

    self._command_window.clear()

    # Command text box.
    self._command_textbox = textpad.Textbox(
        self._command_window, insert_mode=True)

    # Enter existing command.
    self._auto_key_in(existing_command) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:23,代码来源:curses_ui.py

示例3: test_textpad

# 需要导入模块: from curses import textpad [as 别名]
# 或者: from curses.textpad import Textbox [as 别名]
def test_textpad(stdscr, insert_mode=False):
    ncols, nlines = 8, 3
    uly, ulx = 3, 2
    if insert_mode:
        mode = 'insert mode'
    else:
        mode = 'overwrite mode'

    stdscr.addstr(uly-3, ulx, "Use Ctrl-G to end editing (%s)." % mode)
    stdscr.addstr(uly-2, ulx, "Be sure to try typing in the lower-right corner.")
    win = curses.newwin(nlines, ncols, uly, ulx)
    textpad.rectangle(stdscr, uly-1, ulx-1, uly + nlines, ulx + ncols)
    stdscr.refresh()

    box = textpad.Textbox(win, insert_mode)
    contents = box.edit()
    stdscr.addstr(uly+ncols+2, 0, "Text entered in the box\n")
    stdscr.addstr(repr(contents))
    stdscr.addstr('\n')
    stdscr.addstr('Press any key')
    stdscr.getch()

    for i in range(3):
        stdscr.move(uly+ncols+2 + i, 0)
        stdscr.clrtoeol() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:27,代码来源:curses_tests.py

示例4: _screen_create_command_textbox

# 需要导入模块: from curses import textpad [as 别名]
# 或者: from curses.textpad import Textbox [as 别名]
def _screen_create_command_textbox(self, existing_command):
    """Create command textbox on screen.

    Args:
      existing_command: (str) A command string to put in the textbox right
        after its creation.
    """

    # Display the tfdbg prompt.
    self._stdscr.addstr(self._max_y - self._command_textbox_height, 0,
                        self.CLI_PROMPT, curses.A_BOLD)
    self._stdscr.refresh()

    self._command_window.clear()

    # Command text box.
    self._command_textbox = textpad.Textbox(
        self._command_window, insert_mode=True)

    # Enter existing command.
    self._auto_key_in(existing_command) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:23,代码来源:curses_ui.py

示例5: _screen_create_command_textbox

# 需要导入模块: from curses import textpad [as 别名]
# 或者: from curses.textpad import Textbox [as 别名]
def _screen_create_command_textbox(self, existing_command=None):
    """Create command textbox on screen.

    Args:
      existing_command: (str) A command string to put in the textbox right
        after its creation.
    """

    # Display the tfdbg prompt.
    self._addstr(self._max_y - self._command_textbox_height, 0,
                 self.CLI_PROMPT, curses.A_BOLD)
    self._stdscr.refresh()

    self._command_window.clear()

    # Command text box.
    self._command_textbox = textpad.Textbox(
        self._command_window, insert_mode=True)

    # Enter existing command.
    self._auto_key_in(existing_command) 
开发者ID:PacktPublishing,项目名称:Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda,代码行数:23,代码来源:curses_ui.py

示例6: _auto_key_in

# 需要导入模块: from curses import textpad [as 别名]
# 或者: from curses.textpad import Textbox [as 别名]
def _auto_key_in(self, command, erase_existing=False):
    """Automatically key in a command to the command Textbox.

    Args:
      command: The command, as a string or None.
      erase_existing: (bool) whether existing text (if any) is to be erased
          first.
    """
    if erase_existing:
      self._erase_existing_command()

    command = command or ""
    for c in command:
      self._command_textbox.do_command(ord(c)) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:16,代码来源:curses_ui.py

示例7: _auto_key_in

# 需要导入模块: from curses import textpad [as 别名]
# 或者: from curses.textpad import Textbox [as 别名]
def _auto_key_in(self, command):
    """Automatically key in a command to the command Textbox.

    Args:
      command: The command, as a string.
    """
    for c in command:
      self._command_textbox.do_command(ord(c)) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:10,代码来源:curses_ui.py

示例8: show_search_screen

# 需要导入模块: from curses import textpad [as 别名]
# 或者: from curses.textpad import Textbox [as 别名]
def show_search_screen(stdscr):
    curses.curs_set(1)
    stdscr.addstr(1, 2, "Artist name: (Ctrl-G to search)")

    editwin = curses.newwin(1, 40, 3, 3)
    rectangle(stdscr, 2, 2, 4, 44)
    stdscr.refresh()

    box = Textbox(editwin)
    box.edit()

    criteria = box.gather()
    return criteria 
开发者ID:PacktPublishing,项目名称:Python-Programming-Blueprints,代码行数:15,代码来源:app.py

示例9: _show

# 需要导入模块: from curses import textpad [as 别名]
# 或者: from curses.textpad import Textbox [as 别名]
def _show(self, stdscr):
        # Set a reasonable size for our input box.
        lines, cols = curses.LINES - 10, curses.COLS - 40

        y_begin, x_begin = (curses.LINES - lines) // 2, (curses.COLS - cols) // 2
        editwin = curses.newwin(lines, cols, y_begin, x_begin)
        editwin.addstr(0, 1, "{}: (hit Ctrl-G to submit)".format(self._message))
        rectangle(editwin, 1, 0, lines-2, cols-1)
        editwin.refresh()

        inputwin = curses.newwin(lines-4, cols-2, y_begin+2, x_begin+1)
        box = Textbox(inputwin)
        self._load(box, self._content)
        return self._edit(box) 
开发者ID:PacktPublishing,项目名称:Modern-Python-Standard-Library-Cookbook,代码行数:16,代码来源:terminal_10.py

示例10: text_input

# 需要导入模块: from curses import textpad [as 别名]
# 或者: from curses.textpad import Textbox [as 别名]
def text_input(self, window, allow_resize=False):
        """
        Transform a window into a text box that will accept user input and loop
        until an escape sequence is entered.

        If the escape key (27) is pressed, cancel the textbox and return None.
        Otherwise, the textbox will wait until it is full (^j, or a new line is
        entered on the bottom line) or the BEL key (^g) is pressed.
        """

        window.clear()

        # Set cursor mode to 1 because 2 doesn't display on some terminals
        self.curs_set(1)

        # Keep insert_mode off to avoid the recursion error described here
        # http://bugs.python.org/issue13051
        textbox = textpad.Textbox(window)
        textbox.stripspaces = 0

        def validate(ch):
            "Filters characters for special key sequences"
            if ch == self.ESCAPE:
                raise exceptions.EscapeInterrupt()
            if (not allow_resize) and (ch == curses.KEY_RESIZE):
                raise exceptions.EscapeInterrupt()
            # Fix backspace for iterm
            if ch == curses.ascii.DEL:
                ch = curses.KEY_BACKSPACE
            return ch

        # Wrapping in an exception block so that we can distinguish when the
        # user hits the return character from when the user tries to back out
        # of the input.
        try:
            out = textbox.edit(validate=validate)
            if isinstance(out, six.binary_type):
                out = out.decode('utf-8')
        except exceptions.EscapeInterrupt:
            out = None

        self.curs_set(0)
        return self.strip_textpad(out) 
开发者ID:tildeclub,项目名称:ttrv,代码行数:45,代码来源:terminal.py


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