python类echo()的实例源码

view.py 文件源码 项目:melomaniac 作者: sdispater 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def search_mode(self, search_mode):
        self._search_mode = search_mode

        #if search_mode is True:
        #    curses.setsyx(0, 0)
        #    self.scr.clrtoeol()
        #    s = 'Search for: '
        #    self.line(s, 0, len(s), color='blue')
        #    curses.echo()
        #    curses.curs_set(1)

        return self
wrapper.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def wrapper(func, *args, **kwds):
    """Wrapper function that initializes curses and calls another function,
    restoring normal keyboard/screen behavior on error.
    The callable object 'func' is then passed the main window 'stdscr'
    as its first argument, followed by any other arguments passed to
    wrapper().
    """

    try:
        # Initialize curses
        stdscr = curses.initscr()

        # Turn off echoing of keys, and enter cbreak mode,
        # where no buffering is performed on keyboard input
        curses.noecho()
        curses.cbreak()

        # In keypad mode, escape sequences for special keys
        # (like the cursor keys) will be interpreted and
        # a special value like curses.KEY_LEFT will be returned
        stdscr.keypad(1)

        # Start color, too.  Harmless if the terminal doesn't have
        # color; user can test with has_color() later on.  The try/catch
        # works around a minor bit of over-conscientiousness in the curses
        # module -- the error return from C start_color() is ignorable.
        try:
            curses.start_color()
        except:
            pass

        return func(stdscr, *args, **kwds)
    finally:
        # Set everything back to normal
        if 'stdscr' in locals():
            stdscr.keypad(0)
            curses.echo()
            curses.nocbreak()
            curses.endwin()
gui.py 文件源码 项目:pycreate2 作者: MomsFriendlyRobotCompany 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __del__(self):
        curses.nocbreak()
        curses.echo()
        curses.endwin()
        # print('done')
gintonic.py 文件源码 项目:gintonic 作者: redahe 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def close_curses():
    mainwindow.keypad(0)
    curses.echo()
    curses.nocbreak()
    curses.curs_set(2)
    curses.endwin()
interpreter.py 文件源码 项目:AsciiDots-Java 作者: LousyLynx 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def curses_input(self, stdscr, r, c, prompt_string):
        curses.echo()
        stdscr.addstr(r, c, str(prompt_string), curses.A_REVERSE)
        stdscr.addstr(r + 1, c, " " * (curses.COLS - 1))
        stdscr.refresh()
        input_val = ""

        while len(input_val) <= 0:
            input_val = stdscr.getstr(r + 1, c, 20)

        return input_val
interpreter.py 文件源码 项目:AsciiDots-Java 作者: LousyLynx 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def on_finish(self):
        global interpreter

        if self.debug and not self.compat_debug:
            curses.nocbreak()
            self.stdscr.keypad(False)
            curses.echo()

            curses.endwin()

        # sys.exit(0)
stats_print.py 文件源码 项目:sawtooth-validator 作者: hyperledger-archives 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def cpstop(self):
        if self.use_curses:
            curses.nocbreak()
            self.scrn.keypad(0)
            curses.echo()
            curses.endwin()
ui.py 文件源码 项目:WxNeteaseMusic 作者: yaphone 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def get_account(self):
        self.screen.timeout(-1)  # disable the screen timeout
        curses.echo()
        account = self.screen.getstr(8, self.startcol + 6, 60)
        self.screen.timeout(100)  # restore the screen timeout
        return account.decode('utf-8')
ui.py 文件源码 项目:WxNeteaseMusic 作者: yaphone 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def get_param(self, prompt_string):
        # keep playing info in line 1
        curses.echo()
        self.screen.move(4, 1)
        self.screen.clrtobot()
        self.addstr(5, self.startcol, prompt_string,
                    curses.color_pair(1))
        self.screen.refresh()
        info = self.screen.getstr(10, self.startcol, 60)
        if info == '':
            return '/return'
        elif info.strip() is '':
            return self.get_param(prompt_string)
        else:
            return info
wrapper.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def wrapper(func, *args, **kwds):
    """Wrapper function that initializes curses and calls another function,
    restoring normal keyboard/screen behavior on error.
    The callable object 'func' is then passed the main window 'stdscr'
    as its first argument, followed by any other arguments passed to
    wrapper().
    """

    try:
        # Initialize curses
        stdscr = curses.initscr()

        # Turn off echoing of keys, and enter cbreak mode,
        # where no buffering is performed on keyboard input
        curses.noecho()
        curses.cbreak()

        # In keypad mode, escape sequences for special keys
        # (like the cursor keys) will be interpreted and
        # a special value like curses.KEY_LEFT will be returned
        stdscr.keypad(1)

        # Start color, too.  Harmless if the terminal doesn't have
        # color; user can test with has_color() later on.  The try/catch
        # works around a minor bit of over-conscientiousness in the curses
        # module -- the error return from C start_color() is ignorable.
        try:
            curses.start_color()
        except:
            pass

        return func(stdscr, *args, **kwds)
    finally:
        # Set everything back to normal
        if 'stdscr' in locals():
            stdscr.keypad(0)
            curses.echo()
            curses.nocbreak()
            curses.endwin()
screen.py 文件源码 项目:sciibo 作者: fdev 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def create_screen(fn):
    """
    Initializes curses and passes a Screen to the main loop function `fn`.
    Based on curses.wrapper.
    """
    try:
        # Make escape key more responsive
        os.environ['ESCDELAY'] = '25'

        stdscr = curses.initscr()

        curses.noecho()
        curses.cbreak()
        stdscr.keypad(1)
        stdscr.nodelay(1)
        curses.curs_set(0)

        curses.mousemask(curses.BUTTON1_CLICKED)

        if curses.has_colors():
            curses.start_color()
            curses.use_default_colors()

        screen = Screen(stdscr)
        fn(screen)

    finally:
        # Set everything back to normal
        if 'stdscr' in locals():
            curses.use_default_colors()
            curses.curs_set(1)
            stdscr.keypad(0)
            curses.echo()
            curses.nocbreak()
            curses.endwin()
wrapper.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def wrapper(func, *args, **kwds):
    """Wrapper function that initializes curses and calls another function,
    restoring normal keyboard/screen behavior on error.
    The callable object 'func' is then passed the main window 'stdscr'
    as its first argument, followed by any other arguments passed to
    wrapper().
    """

    try:
        # Initialize curses
        stdscr = curses.initscr()

        # Turn off echoing of keys, and enter cbreak mode,
        # where no buffering is performed on keyboard input
        curses.noecho()
        curses.cbreak()

        # In keypad mode, escape sequences for special keys
        # (like the cursor keys) will be interpreted and
        # a special value like curses.KEY_LEFT will be returned
        stdscr.keypad(1)

        # Start color, too.  Harmless if the terminal doesn't have
        # color; user can test with has_color() later on.  The try/catch
        # works around a minor bit of over-conscientiousness in the curses
        # module -- the error return from C start_color() is ignorable.
        try:
            curses.start_color()
        except:
            pass

        return func(stdscr, *args, **kwds)
    finally:
        # Set everything back to normal
        if 'stdscr' in locals():
            stdscr.keypad(0)
            curses.echo()
            curses.nocbreak()
            curses.endwin()
cursebox.py 文件源码 项目:cursebox 作者: Tenchi2xh 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def __exit__(self, exc_type, exc_val, exc_tb):
        # for thread in self.threads:
        #     thread.join()
        curses.noraw()
        self.screen.keypad(False)
        curses.echo()
        curses.endwin()
curses_interface.py 文件源码 项目:gdax-trader 作者: mcardillo55 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def close(self):
        if not self.enable:
            return
        curses.nocbreak()
        self.stdscr.keypad(0)
        curses.echo()
        curses.endwin()
game.py 文件源码 项目:wpm 作者: cslarsen 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def deinit(self):
        curses.nocbreak()
        self.screen.keypad(False)
        curses.echo()
        curses.endwin()
wrapper.py 文件源码 项目:sslstrip-hsts-openwrt 作者: adde88 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def wrapper(func, *args, **kwds):
    """Wrapper function that initializes curses and calls another function,
    restoring normal keyboard/screen behavior on error.
    The callable object 'func' is then passed the main window 'stdscr'
    as its first argument, followed by any other arguments passed to
    wrapper().
    """

    try:
        # Initialize curses
        stdscr = curses.initscr()

        # Turn off echoing of keys, and enter cbreak mode,
        # where no buffering is performed on keyboard input
        curses.noecho()
        curses.cbreak()

        # In keypad mode, escape sequences for special keys
        # (like the cursor keys) will be interpreted and
        # a special value like curses.KEY_LEFT will be returned
        stdscr.keypad(1)

        # Start color, too.  Harmless if the terminal doesn't have
        # color; user can test with has_color() later on.  The try/catch
        # works around a minor bit of over-conscientiousness in the curses
        # module -- the error return from C start_color() is ignorable.
        try:
            curses.start_color()
        except:
            pass

        return func(stdscr, *args, **kwds)
    finally:
        # Set everything back to normal
        if 'stdscr' in locals():
            stdscr.keypad(0)
            curses.echo()
            curses.nocbreak()
            curses.endwin()
curses_console.py 文件源码 项目:solent 作者: solent-eng 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def screen_curses_exit():
    global STDSCR
    STDSCR.keypad(0)
    curses.echo()
    curses.nocbreak()
    curses.endwin()
main.py 文件源码 项目:Music-Scraper 作者: srivatsan-ramesh 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def start_gui(process):
    """
    A function that takes care of starting the GUI and stops the Scrapy crawler process when exited from program.

    :param CrawlerProcess process: The scrapy crawler process that is used to scrape the web. The instance is used for stopping the process.
    """

    def create_ui(screen):
        """
        A function passes to curses wrapper for safe execution of terminal GUI.

        :param screen: The screen parameter to run the GUI. Sent from the curses wrapper.
        """

        GUI.screen = screen  # All the statis variables of the GUI class is initialized
        GUI.strings = []  # the list of songs is empty initially
        GUI.init_display()  # init the variables required for GUI
        GUI.update_on_key()  # Starts a loop that waits for key input and acts accordingly

        curses.nocbreak()
        curses.echo()
        curses.endwin()
        GUI.gui_stopped = True

    curses.wrapper(create_ui)
    process.stop()  # Stopping the scrapy crawler process
gui.py 文件源码 项目:Music-Scraper 作者: srivatsan-ramesh 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def my_raw_input(r, c, prompt_string):
        """
        Gets input on the screen
        :param r: y coordinate
        :param c: x coordinate
        :param prompt_string: The prompt string
        :return: The input string
        """
        curses.echo()
        GUI.box.addstr(r, c, prompt_string, GUI.high_light_text)
        GUI.box.refresh()
        input_str = GUI.box.getstr(r + 2, c, curses.COLS)
        return input_str.decode('UTF-8')
ui.py 文件源码 项目:youtube_watcher 作者: Sjc1000 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def shutdown(self):
        curses.echo()
        curses.nocbreak()
        self.screen.keypad(False)
        curses.endwin()
        return None


问题


面经


文章

微信
公众号

扫码关注公众号