Python curses.curs_set() Examples
The following are 30
code examples of curses.curs_set().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
curses
, or try the search function
.
Example #1
Source File: interface.py From bitcoind-ncurses with MIT License | 8 votes |
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
Example #2
Source File: CLI.py From email_hack with MIT License | 7 votes |
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)
Example #3
Source File: termpdf.py From termpdf.py with MIT License | 7 votes |
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)
Example #4
Source File: command.py From SpotipyTUI with MIT License | 6 votes |
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
Example #5
Source File: writer.py From gpymusic with MIT License | 6 votes |
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()
Example #6
Source File: writer.py From gpymusic with MIT License | 6 votes |
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')
Example #7
Source File: start.py From gpymusic with MIT License | 6 votes |
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()
Example #8
Source File: monitor.py From cantools with MIT License | 6 votes |
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
Example #9
Source File: termdown.py From termdown with GNU General Public License v3.0 | 6 votes |
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)
Example #10
Source File: cli.py From SecureChat with MIT License | 6 votes |
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()
Example #11
Source File: pg-top.py From postgresql-perf-tools with GNU General Public License v2.0 | 6 votes |
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
Example #12
Source File: gcore_box.py From gaycore with MIT License | 6 votes |
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()
Example #13
Source File: bookViewer.py From PyLimitOrderBook with MIT License | 6 votes |
def get_int_value(self, message): dimensions = self.screen.getmaxyx() if len(message) < dimensions[1]: empty = dimensions[1] - len(message) - 2 self.screen.addstr(dimensions[0] - 2, len(message) + 1, \ " " * empty, curses.A_STANDOUT) self.screen.addstr(dimensions[0] - 2, 1, message, curses.A_STANDOUT) curses.curs_set(1); curses.echo() # show cursor value = self.screen.getstr() self.draw_help() curses.curs_set(0); curses.noecho() try: return int(value) except ValueError: return None
Example #14
Source File: bookViewer.py From PyLimitOrderBook with MIT License | 6 votes |
def get_int_value(self, message): dimensions = self.screen.getmaxyx() if len(message) < dimensions[1]: empty = dimensions[1] - len(message) - 2 self.screen.addstr(dimensions[0] - 2, len(message) + 1, \ " " * empty, curses.A_STANDOUT) self.screen.addstr(dimensions[0] - 2, 1, message, curses.A_STANDOUT) curses.curs_set(1); curses.echo() # show cursor value = self.screen.getstr() self.draw_help() curses.curs_set(0); curses.noecho() try: return int(value) except ValueError: return None
Example #15
Source File: tabview.py From OpenTrader with GNU Lesser General Public License v3.0 | 6 votes |
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()
Example #16
Source File: lcd.py From bitnodes-hardware with MIT License | 6 votes |
def show(self, screen): self.screen = screen curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK) self.white = curses.color_pair(1) curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK) self.green = curses.color_pair(2) curses.init_pair(3, curses.COLOR_YELLOW, curses.COLOR_BLACK) self.yellow = curses.color_pair(3) curses.init_pair(4, curses.COLOR_RED, curses.COLOR_BLACK) self.red = curses.color_pair(4) curses.curs_set(0) self.addstr(1, 1, 'BITNODES HARDWARE', self.white) self.addstr(1, 19, 'LOADING', self.yellow) while True: time.sleep(self.update())
Example #17
Source File: ui.py From scorer.py with GNU General Public License v2.0 | 6 votes |
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)
Example #18
Source File: unimatrix.py From unimatrix with GNU General Public License v3.0 | 5 votes |
def __init__(self, screen): self.screen = screen self.screen.scrollok(0) curses.curs_set(0) curses.use_default_colors() curses.init_pair(1, start_color, start_bg) curses.init_pair(2, curses.COLOR_WHITE, start_bg) curses.init_pair(3, curses.COLOR_BLACK, curses.COLOR_WHITE) self.white = curses.color_pair(2)
Example #19
Source File: mouse_events.py From Learning-Python-by-building-games with MIT License | 5 votes |
def main(screen): c.curs_set(0) c.mousemask(1) inp = screen.getch() if inp == c.KEY_MOUSE: screen.addstr(17, 40, "Mouse is clicked") screen.refresh() screen.getch() time.sleep(10)
Example #20
Source File: curses_display.py From anyMesh-Python with MIT License | 5 votes |
def _curs_set(self,x): if self.cursor_state== "fixed" or x == self.cursor_state: return try: curses.curs_set(x) self.cursor_state = x except _curses.error: self.cursor_state = "fixed"
Example #21
Source File: top.py From python-scripts with GNU General Public License v3.0 | 5 votes |
def init_screen(): curses.start_color() # load colors curses.use_default_colors() curses.noecho() # do not echo text curses.cbreak() # do not wait for "enter" curses.mousemask(curses.ALL_MOUSE_EVENTS) # Hide cursor, if terminal AND curse supports it if hasattr(curses, 'curs_set'): try: curses.curs_set(0) except: pass
Example #22
Source File: cgroup_top.py From ctop with MIT License | 5 votes |
def init_screen(): curses.start_color() # load colors curses.use_default_colors() curses.noecho() # do not echo text curses.cbreak() # do not wait for "enter" curses.mousemask(curses.ALL_MOUSE_EVENTS) # Hide cursor, if terminal AND curse supports it if hasattr(curses, 'curs_set'): try: curses.curs_set(0) except: pass
Example #23
Source File: terminal_dungeon.py From terminal_dungeon with MIT License | 5 votes |
def init_curses(screen): curses.curs_set(0) curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK) screen.attron(curses.color_pair(1))
Example #24
Source File: tui.py From wifiphisher with GNU General Public License v3.0 | 5 votes |
def gather_info(self, screen, info): """ Get the information from pywifiphisher and print them out :param self: A TuiMain object :param screen: A curses window object :param info: A namedtuple of printing information :type self: TuiMain :type screen: _curses.curses.window :type info: namedtuple :return: None :rtype: None """ # setup curses try: curses.curs_set(0) except curses.error: pass screen.nodelay(True) curses.init_pair(1, curses.COLOR_BLUE, screen.getbkgd()) curses.init_pair(2, curses.COLOR_YELLOW, screen.getbkgd()) curses.init_pair(3, curses.COLOR_RED, screen.getbkgd()) self.blue_text = curses.color_pair(1) | curses.A_BOLD self.yellow_text = curses.color_pair(2) | curses.A_BOLD self.red_text = curses.color_pair(3) | curses.A_BOLD while True: # catch the exception when screen size is smaller than # the text length is_done = self.display_info(screen, info) if is_done: return
Example #25
Source File: tui.py From wifiphisher with GNU General Public License v3.0 | 5 votes |
def gather_info(self, screen, info): """ Get the information from pywifiphisher and print them out :param self: A TuiApSel object :type self: TuiApSel :param screen: A curses window object :type screen: _curses.curses.window :param info: A namedtuple of information from pywifiphisher :type info: namedtuple :return AccessPoint object if users type enter :rtype AccessPoint if users type enter else None """ # setup curses # make cursor invisible try: curses.curs_set(0) except curses.error: pass # don't wait for user input screen.nodelay(True) # setup the font color curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_CYAN) self.highlight_text = curses.color_pair(1) self.normal_text = curses.A_NORMAL # information regarding access points ap_info = self.init_display_info(screen, info) # show information until user presses Esc key while ap_info.key != 27: # display info will modifiy the key value is_done = self.display_info(screen, ap_info) if is_done: # turn off access point discovery and return the result self.access_point_finder.stop_finding_access_points() return self.access_points[ap_info.pos - 1] # turn off access point discovery self.access_point_finder.stop_finding_access_points()
Example #26
Source File: npyspmfuncs.py From HomePWN with GNU General Public License v3.0 | 5 votes |
def showcursor(): try: curses.curs_set(1) except: pass
Example #27
Source File: npyspmfuncs.py From HomePWN with GNU General Public License v3.0 | 5 votes |
def hidecursor(): try: curses.curs_set(0) except: pass
Example #28
Source File: cli.py From wifibroadcast with GNU General Public License v3.0 | 5 votes |
def main(): stderr = sys.stderr if len(sys.argv) != 2: print("Usage: %s <profile>" % (sys.argv[0],), file=stderr) sys.exit(1) fd = tempfile.TemporaryFile() log.startLogging(fd) stdscr = curses.initscr() curses.noecho() curses.cbreak() curses.curs_set(0) stdscr.keypad(1) reactor.callWhenRunning(lambda: defer.maybeDeferred(init, stdscr, sys.argv[1])\ .addErrback(abort_on_crash)) reactor.run() curses.endwin() rc = exit_status() if rc: log.msg('Exiting with code %d' % rc) fd.seek(0) for l in fd: stderr.write(l) sys.exit(rc)
Example #29
Source File: menu.py From power-up with Apache License 2.0 | 5 votes |
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
Example #30
Source File: terminal.py From ttrv with MIT License | 5 votes |
def curs_set(val): """ Change the cursor visibility, may fail for some terminals with limited cursor support. """ try: curses.curs_set(val) except: pass