Python curses 模块,ERR 实例源码

我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用curses.ERR

项目:bittyband    作者:yam655    | 项目源码 | 文件源码
def get_key(self, block=True, timeout=None):
        if timeout:
            check = select.select([sys.stdin], [], [], timeout)[0]
            if len(check) == 0:
                return None
            ret = self.stdscrs[-1].getkey()
        elif block:
            ret = self.stdscrs[-1].getkey()
        else:
            self.stdscrs[-1].nodelay(1)
            try:
                ret = self.stdscrs[-1].getkey()
                if ret == curses.ERR:
                    ret = None
            except:
                ret = None
            finally:
                self.stdscrs[-1].nodelay(0)
        if len(ret) == 1:
            if ord(ret) < 0x20:
                ret = "^{}".format(chr(ord(ret) + ord('@')))
            elif ord(ret) == 0x7f:
                ret = "^?"
        return ret
项目:Qaf    作者:jonathanabennett    | 项目源码 | 文件源码
def main(stdscr):
    curses.start_color()
    curses.use_default_colors()
    for i in range(0, curses.COLORS):
        curses.init_pair(i + 1, i, -1)
    try:
        for i in range(0, 255):
            stdscr.addstr(str(i), curses.color_pair(i))
            stdscr.addstr(" ")
    except curses.ERR:
        # End of screen reached
        pass
    stdscr.getch()
项目:s2e-env    作者:S2E    | 项目源码 | 文件源码
def _run(self, callback):
        self._create_desktop()

        if not callback(self):
            return

        self._redraw()
        self._desktop.window.nodelay(True)

        while True:
            c = self._desktop.window.getch()
            if c == curses.ERR:
                if not callback(self):
                    return

                time.sleep(1)

            elif c == ord('q'):
                break
            elif c == curses.KEY_RESIZE:
                self._updated = True

            if self._updated:
                self._redraw()
                self._updated = False