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