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


Python Textbox.do_command方法代码示例

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


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

示例1: do_command

# 需要导入模块: from curses.textpad import Textbox [as 别名]
# 或者: from curses.textpad.Textbox import do_command [as 别名]
 def do_command(self, ch):
     if ch == curses.KEY_RESIZE:
         resizeWindows()
         for i in range(8): # delete 8 input window lines
             Textbox.do_command(self, 1)
             Textbox.do_command(self, 11)
             Textbox.do_command(self, 16)
         return Textbox.do_command(self, 7)
     if ch == 10: # Enter
         return 0
     if ch == 127: # Backspace
         return 8
     return Textbox.do_command(self, ch)
开发者ID:felipedau,项目名称:pyaxo,代码行数:15,代码来源:axotor.py

示例2: do_command

# 需要导入模块: from curses.textpad import Textbox [as 别名]
# 或者: from curses.textpad.Textbox import do_command [as 别名]
 def do_command(self, ch):
     if ch == 10:  # Enter
         return 0
     if ch == 127:  # Enter
         return 8
     return Textbox.do_command(self, ch)
开发者ID:SpaceAppsXploration,项目名称:glances,代码行数:8,代码来源:glances_curses.py

示例3: cursesWindow

# 需要导入模块: from curses.textpad import Textbox [as 别名]
# 或者: from curses.textpad.Textbox import do_command [as 别名]

#.........这里部分代码省略.........
        curses.init_pair(2, curses.COLOR_RED, -1)
        curses.init_pair(3, curses.COLOR_GREEN, -1)
        curses.init_pair(4, curses.COLOR_YELLOW, -1)
        curses.init_pair(5, curses.COLOR_BLUE, -1)
        curses.init_pair(6, curses.COLOR_MAGENTA, -1)
        curses.init_pair(7, curses.COLOR_CYAN, -1)
        curses.init_pair(8, curses.COLOR_WHITE, -1)

    def windowSizeChangeEventHandler(self, n, frame):
        self.size = os.popen('stty size', 'r').read().split()

    def setCursorVisibility(self, visible):
        try:
            curses.curs_set(visible)
        except:
            pass

    def getUserInput(self):
        return self.screen.getch()

    def close(self):
        self.setCursorVisibility(1)
        curses.nocbreak()
        self.screen.keypad(0)
        curses.echo()
        curses.endwin()

    def getInput(self, edit_window):
        self.setCursorVisibility(1)
        value = curses.textpad.Textbox(edit_window, insert_mode = True).edit().strip()
        self.setCursorVisibility(0)
        return value

    def wait(self, delay):
        self.screen.timeout(delay)

    def refresh(self):
        try:
            self.screen.noutrefresh()
        except:
            pass

    def update(self):
        curses.doupdate()

    def clear(self):
        self.screen.clear()
        self.pad.clear()

    # Drawing
    def addStr(self, string, color = ''):
        try:
            if not color:
                self.screen.addstr(string)
            else:
                self.screen.addstr(string, curses.color_pair(color))
        except:
            pass

    def addString(self, posX, posY, string, color = ''):
        try:
            if not color:
                self.screen.addstr(posY, posX, string)
            else:
                self.screen.addstr(posY, posX, string, curses.color_pair(color))
        except:
            pass

    def draw(self, screen):
        if not screen:
            return

        if len(screen[0]) == 4:
            for (y, x, line, color) in screen:
                self.addString(y, x, line, color)
        elif len(screen[0]) == 2:
            for (line, color) in screen:
                self.addStr(line, color)

    def editTextOnScreen(self, line_index, line_contents):
        editwin = self.window.subwin(1, int(self.size[1]) - 33, line_index, 7)
        editwin.addstr(0, 0, ' ' * (int(self.size[1]) - 34))
        editwin.addstr(0, 0, line_contents)
        return self.editTextField(editwin)

    def editTextField(self, editwin):
        self.setCursorVisibility(1)
        self.textbox = Textbox(editwin, insert_mode = True)
        newname = self.textbox.edit(self.deleteKeyPressHandler).strip()
        self.textbox = ''
        self.setCursorVisibility(0)
        return newname

    def deleteKeyPressHandler(self, keyPressed):
        if keyPressed in (330, 263, 127):  # Delete
            self.textbox.do_command(curses.KEY_BACKSPACE)
        else:
            return keyPressed

        return
开发者ID:HenrikDK,项目名称:sabcli,代码行数:104,代码来源:cursesWindow.py

示例4: EditField

# 需要导入模块: from curses.textpad import Textbox [as 别名]
# 或者: from curses.textpad.Textbox import do_command [as 别名]

#.........这里部分代码省略.........
        be valid in the context of any validation function this EditField
        has.

        If numeric_pad is set, pad text with it if field isn't blank.
        '''
        self._modified = True
        self._set_text(text)

    def _do_pad(self, text):
        '''Apply the numeric padding to text'''
        if self.numeric_pad is not None:
            width = self.area.columns - 1
            if text:
                text = text.lstrip(self.numeric_pad)
                text = rjust_columns(text, width, self.numeric_pad)
        return text

    def _set_text(self, text, do_pad=True):
        '''Used internally to bypass the the public
        interface's numeric_pad functionality'''
        if do_pad:
            text = self._do_pad(text)
        if text is None:
            text = u""
        self._reset_text()
        terminalui.LOGGER.log(LOG_LEVEL_INPUT,
                    "_set_text textwidth=%s, columns=%s, text=%s",
                    textwidth(text), self.area.columns, text)
        length_diff = textwidth(text) - self.area.columns
        if (length_diff >= 0):
            self.scroll(scroll_to_column=length_diff)
        for idx, char in enumerate(text):
            if length_diff > 0 and idx == length_diff:
                self.textbox.do_command(EditField.LARROW_CHAR)
            elif self.masked:
                self.textbox.do_command(self.masked_char)
            else:
                self.textbox.do_command(ord(char))
            self.text.append(char)
        self.no_ut_refresh()

    def handle_input(self, input_key):
        '''
        For each keystroke, determine if it's a special character (and needs
        to end editing), printable character, or backspace.

        For special characters, send the return the done-editing code (CTRL-G),
        and store the special character for processing by parent window
        objects.

        If printable, append it to self.text, and try to validate. If
        validation fails, reject the character.

        '''
        input_key = self.translate_input(input_key)
        if self.is_special_char(input_key):
            self.input_key = input_key
            return EditField.CMD_DONE_EDIT
        else:
            self.input_key = None
        if isprint(input_key) or (ismeta(input_key) and
                                  input_key < curses.KEY_MIN):
            # isprint: ASCII characters
            # ismeta and < curses.KEY_MIN: Remaining UTF-8 characters
            # > curses.KEY_MIN: Special key such as down arrow, backspace, etc.
            self.text.append(unichr(input_key))
开发者ID:PluribusNetworks,项目名称:pluribus_userland,代码行数:70,代码来源:edit_field.py


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