本文整理汇总了Python中curses.curs_set方法的典型用法代码示例。如果您正苦于以下问题:Python curses.curs_set方法的具体用法?Python curses.curs_set怎么用?Python curses.curs_set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类curses
的用法示例。
在下文中一共展示了curses.curs_set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search
# 需要导入模块: import curses [as 别名]
# 或者: from curses import curs_set [as 别名]
def search(self):
"""Open search window, get input and set the search string."""
if self.init_search is not None:
return
scr2 = curses.newwin(3, self.max_x, self.max_y - 3, 0)
scr3 = scr2.derwin(1, self.max_x - 12, 1, 9)
scr2.box()
scr2.move(1, 1)
addstr(scr2, "Search: ")
scr2.refresh()
curses.curs_set(1)
self._search_win_open = 3
self.textpad = Textbox(scr3, insert_mode=True)
self.search_str = self.textpad.edit(self._search_validator)
self.search_str = self.search_str.lower().strip()
try:
curses.curs_set(0)
except _curses.error:
pass
if self.search_str:
self.init_search = None
self._search_win_open = 0
示例2: _calculate_layout
# 需要导入模块: import curses [as 别名]
# 或者: from curses import curs_set [as 别名]
def _calculate_layout(self):
"""Setup popup window and format data. """
self.scr.touchwin()
self.term_rows, self.term_cols = self.scr.getmaxyx()
self.box_height = self.term_rows - int(self.term_rows / 2)
self.win = curses.newwin(int(self.term_rows / 2),
self.term_cols, self.box_height, 0)
try:
curses.curs_set(False)
except _curses.error:
pass
# transform raw data into list of lines ready to be printed
s = self.data.splitlines()
s = [wrap(i, self.term_cols - 3, subsequent_indent=" ")
or [""] for i in s]
self.tdata = [i for j in s for i in j]
# -3 -- 2 for the box lines and 1 for the title row
self.nlines = min(len(self.tdata), self.box_height - 3)
self.scr.refresh()
示例3: process_user_input_filter
# 需要导入模块: import curses [as 别名]
# 或者: from curses import curs_set [as 别名]
def process_user_input_filter(self, key):
if key == '\n':
self._show_filter = False
curses.curs_set(False)
elif key in ['KEY_BACKSPACE', '\b']:
self._filter = self._filter[:-1]
else:
self._filter += key
self.compile_filter()
self._filtered_sorted_message_names = []
for name in self._formatted_messages:
self.insort_filtered(name)
self._modified = True
示例4: init_curses
# 需要导入模块: import curses [as 别名]
# 或者: from curses import curs_set [as 别名]
def init_curses():
window = curses.initscr()
curses.noecho() # prevents user input from being echoed
curses.curs_set(0) # make cursor invisible
curses.start_color()
curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK)
curses.init_pair(2, curses.COLOR_CYAN, curses.COLOR_BLACK)
curses.init_pair(3, curses.COLOR_RED, curses.COLOR_BLACK)
curses.init_pair(4, curses.COLOR_MAGENTA, curses.COLOR_BLACK)
curses.init_pair(5, curses.COLOR_YELLOW, curses.COLOR_BLACK)
window.timeout(50)
window.keypad(1) # interpret arrow keys, etc
return window
示例5: init_curses
# 需要导入模块: import curses [as 别名]
# 或者: from curses import curs_set [as 别名]
def init_curses(self):
"""Setup the curses"""
self.window = curses.initscr()
self.height, self.width = self.window.getmaxyx()
if self.width < 60:
self.too_small = True
return
self.window.keypad(True)
# self.window.nodelay(True)
curses.noecho()
curses.curs_set(False)
curses.cbreak()
curses.start_color()
curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK)
curses.init_pair(2, curses.COLOR_YELLOW, curses.COLOR_BLACK)
curses.init_pair(3, curses.COLOR_WHITE, curses.COLOR_BLACK)
curses.init_pair(4, curses.COLOR_GREEN, curses.COLOR_BLACK)
curses.init_pair(5, curses.COLOR_WHITE, curses.COLOR_CYAN)
示例6: main
# 需要导入模块: import curses [as 别名]
# 或者: from curses import curs_set [as 别名]
def main(stdscr, matches):
curses.curs_set(False)
selected = 0
curses.init_pair(2, curses.COLOR_RED, curses.COLOR_BLACK)
curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK)
while True:
printGames(stdscr, matches, selected)
event = stdscr.getch()
if event == ord("\n"):
logging.info("Enter key pressed")
return selected
elif event == curses.KEY_UP:
logging.info("Up key pressed")
if selected != 0:
selected -= 1
printGames(stdscr, matches, selected)
elif event == curses.KEY_DOWN:
logging.info("Down key pressed")
if selected != len(matches) - 1:
selected += 1
printGames(stdscr, matches, selected)
示例7: _init_curses
# 需要导入模块: import curses [as 别名]
# 或者: from curses import curs_set [as 别名]
def _init_curses(self):
self.stdscr = curses.initscr()
self.stdscr.keypad(1)
curses.noecho()
curses.cbreak()
curses.curs_set(0)
curses.start_color()
try:
curses.init_pair(1, curses.COLOR_BLACK, 197) # 接近机核主题的颜色
except:
# 树莓派 windows无法使用机核like色
curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_RED)
curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_BLACK)
self.stdscr.bkgd(curses.color_pair(2))
self.stdscr.timeout(100)
self.stdscr.refresh()
示例8: clean_exit
# 需要导入模块: import curses [as 别名]
# 或者: from curses import curs_set [as 别名]
def clean_exit(message=''):
scr.create_text_win(1, ' ')
for doc in bufs.docs:
# save current state
doc.write_state()
# close the document
doc.close()
# close curses
scr.stdscr.keypad(False)
curses.echo()
curses.curs_set(1)
curses.endwin()
raise SystemExit(message)
示例9: get_input
# 需要导入模块: import curses [as 别名]
# 或者: from curses import curs_set [as 别名]
def get_input(self, prompt):
"""Get user input through the user interface and return it."""
curses.curs_set(2)
self.prompt_area.clear()
self.input_prompt.addstr(0, 0, prompt)
self.search_window.clear()
self.prompt_area.refresh()
curses.echo()
user_input = self.search_window.getstr().decode(encoding="utf-8")
curses.noecho()
self.prompt_area.clear()
self.prompt_area.refresh()
curses.curs_set(0)
return user_input
示例10: pg_top
# 需要导入模块: import curses [as 别名]
# 或者: from curses import curs_set [as 别名]
def pg_top(scr, pgt, con, opts):
curses.noecho() # disable echo
curses.cbreak() # keys are read directly, without hitting Enter
# curses.curs_set(0) # disable mouse
pgt.init(scr, con, opts)
t = threading.Thread(target=main_loop, args=(pgt,))
t.daemon = True
t.start()
while 1:
try:
key = pgt.getkey()
if key == 'q':
pgt.terminate = True
break
except KeyboardInterrupt:
break
pgt.terminate = True
示例11: login
# 需要导入模块: import curses [as 别名]
# 或者: from curses import curs_set [as 别名]
def login(user):
"""
Log into Google Play Music. Succeeds or exits.
Arguments:
user: Dict containing auth information.
"""
crs.curs_set(0)
common.w.outbar_msg('Logging in...')
try:
if not common.mc.login(user['email'], user['password'], user['deviceid']):
common.w.goodbye('Login failed: Exiting.')
common.w.outbar_msg(
'Logging in... Logged in as %s (%s).' %
(user['email'], 'Full' if common.mc.is_subscribed else 'Free')
)
except KeyboardInterrupt:
common.w.goodbye()
示例12: goodbye
# 需要导入模块: import curses [as 别名]
# 或者: from curses import curs_set [as 别名]
def goodbye(self, msg=''):
"""
Exit gpymusic.
Arguements:
msg='': Message to display prior to exiting.
"""
if not self.curses:
if not self.test:
print(msg)
sys.exit()
self.addstr(self.outbar, msg)
common.mc.logout()
try:
common.client.mm.logout()
except:
pass
sleep(2)
crs.curs_set(1)
crs.endwin()
sys.exit()
示例13: get_input
# 需要导入模块: import curses [as 别名]
# 或者: from curses import curs_set [as 别名]
def get_input(self):
"""
Get user input in the bottom bar.
Returns: The user-inputted string.
"""
if not self.curses:
return input('Enter some input: ')
self.addstr(self.inbar, '> ')
crs.curs_set(2) # Show the cursor.
try:
string = self.inbar.getstr()
except KeyboardInterrupt:
common.np.close()
self.goodbye('Goodbye, thanks for using Google Py Music!')
self.inbar.deleteln()
crs.curs_set(0) # Hide the cursor.
return string.decode('utf-8')
示例14: setup
# 需要导入模块: import curses [as 别名]
# 或者: from curses import curs_set [as 别名]
def setup(stdscr):
# curses
curses.use_default_colors()
curses.init_pair(1, curses.COLOR_RED, -1)
curses.init_pair(2, curses.COLOR_RED, curses.COLOR_RED)
curses.init_pair(3, curses.COLOR_GREEN, -1)
curses.init_pair(4, -1, curses.COLOR_RED)
try:
curses.curs_set(False)
except curses.error:
# fails on some terminals
pass
stdscr.timeout(0)
# prepare input thread mechanisms
curses_lock = Lock()
input_queue = Queue()
quit_event = Event()
return (curses_lock, input_queue, quit_event)
示例15: setup
# 需要导入模块: import curses [as 别名]
# 或者: from curses import curs_set [as 别名]
def setup(self):
"""
Perform basic command-line interface setup.
"""
curses.curs_set(1)
curses.noecho()
curses.cbreak()
# Keypad disabled until scrolling properly implemented
# self.stdscr.keypad(True)
self.stdscr.clear()
self.stdscr.addstr("SecureChat v{}".format(__version__))
self.chat_container.box()
self.chat_win.addstr("Welcome to SecureChat!")
self.chat_win.scrollok(True)
self.chat_win.setscrreg(0, self.max_y - 5)
self.prompt_win.addstr("> ")
self.refresh_all()