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


Python curses.KEY_ENTER属性代码示例

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


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

示例1: validator

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_ENTER [as 别名]
def validator(self, char):
        """here we tweak the behavior slightly, especially we want to
        end modal editing mode immediately on arrow up/down and on enter
        and we also want to catch ESC and F10, to abort the entire dialog"""
        if curses.ascii.isprint(char):
            return char
        if char == curses.ascii.TAB:
            char = curses.KEY_DOWN
        if char in [curses.KEY_DOWN, curses.KEY_UP]:
            self.result = char
            return curses.ascii.BEL
        if char in [10, 13, curses.KEY_ENTER, curses.ascii.BEL]:
            self.result = 10
            return curses.ascii.BEL
        if char == 127:
            char = curses.KEY_BACKSPACE
        if char in [27, curses.KEY_F10]:
            self.result = -1
            return curses.ascii.BEL
        return char 
开发者ID:caktux,项目名称:pytrader,代码行数:22,代码来源:pytrader.py

示例2: process_user_input

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_ENTER [as 别名]
def process_user_input(self):
		"""
		Gets the next single character and decides what to do with it
		"""
		user_input = self.get_input()

		go_to_max = ord("9") if len(self.items) >= 9 else ord(str(len(self.items)))

		if ord('1') <= user_input <= go_to_max:
			self.go_to(user_input - ord('0') - 1)
		elif user_input == curses.KEY_DOWN:
			self.go_down()
		elif user_input == curses.KEY_UP:
			self.go_up()
		elif user_input == ord(" "):
			if self.items[ self.current_option] .defaultText != '← Return to Main Menu':
				item = self.items[self.current_option]
				item.checked = not item.checked
				item.text = ('[X] ' if item.checked else '[ ] ') + item.defaultText
				self.items[self.current_option] = item
				self.draw()
		elif user_input in {curses.KEY_ENTER, 10, 13}:
			self.select_many()

		return user_input 
开发者ID:mholgatem,项目名称:GPIOnext,代码行数:27,代码来源:multi_selection_menu.py

示例3: process_user_input

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_ENTER [as 别名]
def process_user_input(self):
		"""
		Gets the next single character and decides what to do with it
		"""
		user_input = self.get_input()

		go_to_max = ord("9") if len(self.items) >= 9 else ord(str(len(self.items)))

		if ord('1') <= user_input <= go_to_max:
			self.go_to(user_input - ord('0') - 1)
		elif user_input == curses.KEY_DOWN:
			self.go_down()
		elif user_input == curses.KEY_UP:
			self.go_up()
		elif user_input in {curses.KEY_ENTER, 10, 13}:
			self.select()

		return user_input 
开发者ID:mholgatem,项目名称:GPIOnext,代码行数:20,代码来源:curses_menu.py

示例4: setup_handlers

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_ENTER [as 别名]
def setup_handlers(self):
        self.handlers = {'\n':              self.close,
                         curses.KEY_ENTER:  self.close,
                         'q':               self.close,
                         curses.KEY_RESIZE: self.close,
                         curses.KEY_DOWN:   self.scroll_down,
                         'j':               self.scroll_down,
                         curses.KEY_UP:     self.scroll_up,
                         'k':               self.scroll_up,
                         } 
开发者ID:OpenTrading,项目名称:OpenTrader,代码行数:12,代码来源:tabview.py

示例5: getstr

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_ENTER [as 别名]
def getstr(w, y, x):
    window = curses.newwin(1, w, y, x)

    result = ""
    window.addstr("> ", curses.A_BOLD + curses.A_BLINK)
    window.refresh()
    window.keypad(True)

    while True:
        try:
            character = -1
            while (character < 0):
                character = window.getch()
        except:
            break

        if character == curses.KEY_ENTER or character == ord('\n'):
            break

        elif character == curses.KEY_BACKSPACE or character == 127:
            if len(result):
                window.move(0, len(result)+1)
                window.delch()
                result = result[:-1]
                continue

        elif (137 > character > 31 and len(result) < w-3): # ascii range TODO: unicode
                result += chr(character)
                window.addstr(chr(character))

    window.addstr(0, 0, "> ", curses.A_BOLD + curses.color_pair(3))
    window.refresh()

    window.keypad(False)
    return result 
开发者ID:esotericnonsense,项目名称:bitcoind-ncurses,代码行数:37,代码来源:getstr.py

示例6: check

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_ENTER [as 别名]
def check(block_viewer, state, window, rpcc, poller):
    key = window.getch()

    if key < 0 or state['mode'] == 'splash':
        return False

    if state['mode'] == "block":
        if block_viewer.handle_hotkey(key):
            return False

    if key in keymap:
        if key in (curses.KEY_LEFT, curses.KEY_RIGHT, curses.KEY_ENTER, ord('\n')):
            keymap[key](block_viewer, state, window, rpcc, poller)
        else:
            keymap[key](state, window, rpcc, poller)

    elif key in modemap:
        mode = modemap[key]

        if mode == "forks":
            rpcc.request('getchaintips')

        change_mode(block_viewer, state, window, mode, poller)

    elif key == ord('q') or key == ord('Q'): # quit
        return True

    return False 
开发者ID:esotericnonsense,项目名称:bitcoind-ncurses,代码行数:30,代码来源:hotkey.py

示例7: handle_events

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_ENTER [as 别名]
def handle_events(self, key):
        if key == curses.KEY_UP:
            self.previous()
        elif key == curses.KEY_DOWN:
            self.next()
        elif key == curses.KEY_ENTER or key == NEW_LINE or key == CARRIAGE_RETURN:
            selected_item = self.get_selected()
            return selected_item.action 
开发者ID:PacktPublishing,项目名称:Python-Programming-Blueprints,代码行数:10,代码来源:menu.py

示例8: __init__

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_ENTER [as 别名]
def __init__(self, log, stdscr, title, subtitle=None, items=[]):
        self.log = log
        self.stdscr = stdscr
        self.title = title
        self.subtitle = subtitle
        self.items = items
        self.num_selects = (
            [ord(str(n)) for n in range(len(self.items)) if n < 10])
        self.enter_selects = [curses.KEY_ENTER, ord('\n')]
        curses.curs_set(0)
        self.cursor_pos = 0 
开发者ID:IBM,项目名称:power-up,代码行数:13,代码来源:menu.py

示例9: kye_handling

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_ENTER [as 别名]
def kye_handling(self):
        self.draw_frame()
        self.scr_h, self.scr_w = self.screen.getmaxyx()

        while True:
            c = self.screen.getch()

            if c == curses.KEY_HOME:
                self.x = 1
                self.y = 1
            elif c == curses.KEY_NPAGE:
                offset_intent = self.offset + (self.scr_h - 4)
                if offset_intent < len(self.acs) - 5:
                    self.offset = offset_intent
            elif c == curses.KEY_PPAGE:
                offset_intent = self.offset - (self.scr_h - 4)
                if offset_intent > 0:
                    self.offset = offset_intent
                else:
                    self.offset = 0
            elif c == curses.KEY_DOWN:
                y_intent = self.y + 1
                if y_intent < self.scr_h - 3:
                    self.y = y_intent
            elif c == curses.KEY_UP:
                y_intent = self.y - 1
                if y_intent > 2:
                    self.y = y_intent
            elif c == curses.KEY_ENTER or c == 10 or c == 13:
                self.lock_icao = (self.screen.instr(self.y, 1, 6)).decode()
            elif c == 27:  # escape key
                self.lock_icao = None
            elif c == curses.KEY_F5:
                self.screen.refresh()
                self.draw_frame() 
开发者ID:junzis,项目名称:pyModeS,代码行数:37,代码来源:screen.py

示例10: __init__

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_ENTER [as 别名]
def __init__(self):
        self.GOTO_PAGE        = [ord('G')]
        self.GOTO             = [ord('g')]
        self.NEXT_PAGE        = [ord('j'), curses.KEY_DOWN, ord(' ')]
        self.PREV_PAGE        = [ord('k'), curses.KEY_UP]
        self.GO_BACK          = [ord('p')]
        self.NEXT_CHAP        = [ord('l'), curses.KEY_RIGHT]
        self.PREV_CHAP        = [ord('h'), curses.KEY_LEFT]
        self.BUFFER_CYCLE     = [ord('b')]
        self.BUFFER_CYCLE_REV = [ord('B')]
        self.HINTS            = [ord('f')]
        self.OPEN             = [curses.KEY_ENTER, curses.KEY_RIGHT, 10]
        self.SHOW_TOC         = [ord('t')]
        self.SHOW_META        = [ord('M')]
        self.UPDATE_FROM_BIB  = [ord('b')]
        self.SHOW_LINKS       = [ord('f')]
        self.TOGGLE_TEXT_MODE = [ord('T')]
        self.ROTATE_CW        = [ord('r')]
        self.ROTATE_CCW       = [ord('R')]
        self.VISUAL_MODE      = [ord('s')]
        self.SELECT           = [ord('v')]
        self.YANK             = [ord('y')]
        self.INSERT_NOTE      = [ord('n')]
        self.APPEND_NOTE      = [ord('a')]
        self.TOGGLE_AUTOCROP  = [ord('c')]
        self.TOGGLE_ALPHA     = [ord('A')]
        self.TOGGLE_INVERT    = [ord('i')]
        self.TOGGLE_TINT      = [ord('d')]
        self.SET_PAGE_LABEL   = [ord('P')]
        self.SET_PAGE_ALT     = [ord('I')]
        self.INC_FONT         = [ord('=')]
        self.DEC_FONT         = [ord('-')]
        self.OPEN_GUI         = [ord('X')]
        self.REFRESH          = [18, curses.KEY_RESIZE]            # CTRL-R
        self.QUIT             = [3, ord('q')]
        self.DEBUG            = [ord('D')]

# Kitty graphics functions 
开发者ID:dsanson,项目名称:termpdf.py,代码行数:40,代码来源:termpdf.py

示例11: __init__

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_ENTER [as 别名]
def __init__(self, *args, **kwargs):
        super(AppMessageBox, self).__init__(*args, **kwargs)
        self.entry_widget.add_handlers({
            '^A': self._handleEnter,
            curses.KEY_ENTER: self._handleEnter,
            CURSES_OTHER_ENTER: self._handleEnter
        }) 
开发者ID:jwoglom,项目名称:signal-curses,代码行数:9,代码来源:messages.py

示例12: test_subscription_select

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_ENTER [as 别名]
def test_subscription_select(subscription_page):

    # Select a subreddit
    subscription_page.controller.trigger(curses.KEY_ENTER)
    subscription_page.handle_selected_page()

    assert subscription_page.selected_page
    assert not subscription_page.active 
开发者ID:michael-lazar,项目名称:rtv,代码行数:10,代码来源:test_subscription.py

示例13: define_keys

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_ENTER [as 别名]
def define_keys(self):
        self.keys = {'j':   self.down,
                     'k':   self.up,
                     'h':   self.left,
                     'l':   self.right,
                     'J':   self.page_down,
                     'K':   self.page_up,
                     'm':   self.mark,
                     "'":   self.goto_mark,
                     'L':   self.page_right,
                     'H':   self.page_left,
                     'q':   self.quit,
                     'Q':   self.quit,
                     '$':   self.line_end,
                     '^':   self.line_home,
                     '0':   self.line_home,
                     'g':   self.home,
                     'G':   self.goto_row,
                     '|':   self.goto_col,
                     '\n':  self.show_cell,
                     '/':   self.search,
                     'n':   self.search_results,
                     'p':   self.search_results_prev,
                     't':   self.toggle_header,
                     '-':   self.column_gap_down,
                     '+':   self.column_gap_up,
                     '<':   self.column_width_all_down,
                     '>':   self.column_width_all_up,
                     ',':   self.column_width_down,
                     '.':   self.column_width_up,
                     'a':   self.sort_by_column_natural,
                     'A':   self.sort_by_column_natural_reverse,
                     's':   self.sort_by_column,
                     'S':   self.sort_by_column_reverse,
                     'y':   self.yank_cell,
                     'r':   self.reload,
                     'c':   self.toggle_column_width,
                     'C':   self.set_current_column_width,
                     ']':   self.skip_to_row_change,
                     '[':   self.skip_to_row_change_reverse,
                     '}':   self.skip_to_col_change,
                     '{':   self.skip_to_col_change_reverse,
                     '?':   self.help,
                     curses.KEY_F1:     self.help,
                     curses.KEY_UP:     self.up,
                     curses.KEY_DOWN:   self.down,
                     curses.KEY_LEFT:   self.left,
                     curses.KEY_RIGHT:  self.right,
                     curses.KEY_HOME:   self.line_home,
                     curses.KEY_END:    self.line_end,
                     curses.KEY_PPAGE:  self.page_up,
                     curses.KEY_NPAGE:  self.page_down,
                     curses.KEY_IC:     self.mark,
                     curses.KEY_DC:     self.goto_mark,
                     curses.KEY_ENTER:  self.show_cell,
                     KEY_CTRL('a'):  self.line_home,
                     KEY_CTRL('e'):  self.line_end,
                     } 
开发者ID:OpenTrading,项目名称:OpenTrader,代码行数:60,代码来源:tabview.py


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