本文整理汇总了Python中curses.KEY_BTAB属性的典型用法代码示例。如果您正苦于以下问题:Python curses.KEY_BTAB属性的具体用法?Python curses.KEY_BTAB怎么用?Python curses.KEY_BTAB使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类curses
的用法示例。
在下文中一共展示了curses.KEY_BTAB属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_up_handlers
# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_BTAB [as 别名]
def set_up_handlers(self):
"""This function should be called somewhere during object initialisation (which all library-defined widgets do). You might like to override this in your own definition,
but in most cases the add_handers or add_complex_handlers methods are what you want."""
#called in __init__
self.handlers = {
curses.ascii.NL: self.h_exit_down,
curses.ascii.CR: self.h_exit_down,
curses.ascii.TAB: self.h_exit_down,
curses.KEY_BTAB: self.h_exit_up,
curses.KEY_DOWN: self.h_exit_down,
curses.KEY_UP: self.h_exit_up,
curses.KEY_LEFT: self.h_exit_left,
curses.KEY_RIGHT: self.h_exit_right,
# "^P": self.h_exit_up,
# "^N": self.h_exit_down,
curses.ascii.ESC: self.h_exit_escape,
curses.KEY_MOUSE: self.h_exit_mouse,
}
self.complex_handlers = []
示例2: set_up_handlers
# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_BTAB [as 别名]
def set_up_handlers(self):
"""This function should be called somewhere during object initialisation (which all library-defined widgets do). You might like to override this in your own definition,
but in most cases the add_handers or add_complex_handlers methods are what you want."""
#called in __init__
self.handlers = {
curses.ascii.NL: self.h_exit_down,
curses.ascii.CR: self.h_exit_down,
curses.ascii.TAB: self.h_exit_down,
curses.KEY_BTAB: self.h_exit_up,
curses.KEY_DOWN: self.h_exit_down,
curses.KEY_UP: self.h_exit_up,
curses.KEY_LEFT: self.h_exit_left,
curses.KEY_RIGHT: self.h_exit_right,
"^P": self.h_exit_up,
"^N": self.h_exit_down,
curses.ascii.ESC: self.h_exit_escape,
curses.KEY_MOUSE: self.h_exit_mouse,
}
self.complex_handlers = []
示例3: set_up_handlers
# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_BTAB [as 别名]
def set_up_handlers(self):
super(SimpleGrid, self).set_up_handlers()
self.handlers = {
curses.KEY_UP: self.h_move_line_up,
curses.KEY_LEFT: self.h_move_cell_left,
curses.KEY_DOWN: self.h_move_line_down,
curses.KEY_RIGHT: self.h_move_cell_right,
"k": self.h_move_line_up,
"h": self.h_move_cell_left,
"j": self.h_move_line_down,
"l": self.h_move_cell_right,
curses.KEY_NPAGE: self.h_move_page_down,
curses.KEY_PPAGE: self.h_move_page_up,
curses.KEY_HOME: self.h_show_beginning,
curses.KEY_END: self.h_show_end,
ord('g'): self.h_show_beginning,
ord('G'): self.h_show_end,
curses.ascii.TAB: self.h_exit,
curses.KEY_BTAB: self.h_exit_up,
'^P': self.h_exit_up,
'^N': self.h_exit_down,
#curses.ascii.NL: self.h_exit,
#curses.ascii.SP: self.h_exit,
#ord('x'): self.h_exit,
ord('q'): self.h_exit,
curses.ascii.ESC: self.h_exit,
curses.KEY_MOUSE: self.h_exit_mouse,
}
self.complex_handlers = [
]
示例4: get_user_string
# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_BTAB [as 别名]
def get_user_string(self, xpos=3, ypos=15, filterfunc=str.isalnum, completer=None):
# filter allowed characters using filterfunc, alphanumeric by default
user_string = ""
user_input = 0
if completer:
completer = completer(self)
while user_input != 10:
user_input = self.screen.getch()
if user_input == -1: # Input comes from pipe/file and is closed
raise IOError
self.screen_lock.acquire()
# osx and unix backspace chars...
if user_input == 127 or user_input == 263:
if len(user_string) > 0:
user_string = user_string[:-1]
if completer:
completer.update_input(user_string)
self.screen.addstr(ypos, xpos, " " * (self.maxx-xpos-1))
elif user_input in [ord('\t'), curses.KEY_BTAB] and completer:
direction = 1 if user_input == ord('\t') else -1
user_string = completer.complete(direction)
self.screen.addstr(ypos, xpos, " " * (self.maxx-xpos-1))
elif user_input < 256 and user_input != 10:
if filterfunc(chr(user_input)) or chr(user_input) == '_':
user_string += chr(user_input)
if completer:
completer.update_input(user_string)
self.screen.addstr(ypos, xpos, str(user_string))
self.screen.refresh()
self.screen_lock.release()
return user_string