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