Python curses.halfdelay() Examples
The following are 12
code examples of curses.halfdelay().
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: worldmap.py From EasY_HaCk with Apache License 2.0 | 6 votes |
def run(self, scr): """ Initialize and run the application """ m = AsciiMap() curses.halfdelay(self.sleep) while True: now = int(time.time()) refresh = self.fetch_data(now) m.set_data(self.data) m.draw(scr) scr.addstr(0, 1, 'Shodan Radar', curses.A_BOLD) scr.addstr(0, 40, time.strftime("%c UTC", time.gmtime(now)).rjust(37), curses.A_BOLD) # Key Input # q - Quit event = scr.getch() if event == ord('q'): break # redraw window (to fix encoding/rendering bugs and to hide other messages to same tty) # user pressed 'r' or new data was fetched if refresh: m.window.redrawwin()
Example #2
Source File: cryptop.py From cryptop with MIT License | 5 votes |
def conf_scr(): '''Configure the screen and colors/etc''' curses.curs_set(0) curses.start_color() curses.use_default_colors() text, banner, banner_text, background = get_theme_colors() curses.init_pair(2, text, background) curses.init_pair(3, banner_text, banner) curses.halfdelay(10)
Example #3
Source File: cryptop.py From cryptop with MIT License | 5 votes |
def get_string(stdscr, prompt): '''Requests and string from the user''' curses.echo() stdscr.clear() stdscr.addnstr(0, 0, prompt, -1, curses.color_pair(2)) curses.curs_set(1) stdscr.refresh() in_str = stdscr.getstr(1, 0, 20).decode() curses.noecho() curses.curs_set(0) stdscr.clear() curses.halfdelay(10) return in_str
Example #4
Source File: user_engine.py From tetrisRL with MIT License | 5 votes |
def init(): # Don't display user input curses.noecho() # React to keys without pressing enter (700ms delay) curses.halfdelay(7) # Enumerate keys stdscr.keypad(True) #return stdscr
Example #5
Source File: curses_display.py From anyMesh-Python with MIT License | 5 votes |
def start(self): """ Initialize the screen and input mode. """ assert self._started == False self.s = curses.initscr() self.has_color = curses.has_colors() if self.has_color: curses.start_color() if curses.COLORS < 8: # not colourful enough self.has_color = False if self.has_color: try: curses.use_default_colors() self.has_default_colors=True except _curses.error: self.has_default_colors=False self._setup_colour_pairs() curses.noecho() curses.meta(1) curses.halfdelay(10) # use set_input_timeouts to adjust self.s.keypad(0) if not self._signal_keys_set: self._old_signal_keys = self.tty_signal_keys() super(Screen, self).start()
Example #6
Source File: curses_display.py From anyMesh-Python with MIT License | 5 votes |
def _getch(self, wait_tenths): if wait_tenths==0: return self._getch_nodelay() if wait_tenths is None: curses.cbreak() else: curses.halfdelay(wait_tenths) self.s.nodelay(0) return self.s.getch()
Example #7
Source File: curses_display.py From anyMesh-Python with MIT License | 5 votes |
def _dbg_instr(self): # messy input string (intended for debugging) curses.echo() self.s.nodelay(0) curses.halfdelay(100) str = self.s.getstr() curses.noecho() return str
Example #8
Source File: worldmap.py From EasY_HaCk with Apache License 2.0 | 5 votes |
def __init__(self, api): self.api = api self.data = None self.last_fetch = 0 self.sleep = 10 # tenths of seconds, for curses.halfdelay() self.polling_interval = 60
Example #9
Source File: wgwidget.py From apple_bleee with GNU General Public License v3.0 | 4 votes |
def get_and_use_key_press(self): global TEST_SETTINGS if (TEST_SETTINGS['TEST_INPUT'] is None) and (TEST_SETTINGS['INPUT_GENERATOR'] is None): curses.raw() curses.cbreak() curses.meta(1) self.parent.curses_pad.keypad(1) if self.parent.keypress_timeout: curses.halfdelay(self.parent.keypress_timeout) ch = self._get_ch() if ch == -1: return self.try_while_waiting() else: self.parent.curses_pad.timeout(-1) ch = self._get_ch() # handle escape-prefixed rubbish. if ch == curses.ascii.ESC: #self.parent.curses_pad.timeout(1) self.parent.curses_pad.nodelay(1) ch2 = self.parent.curses_pad.getch() if ch2 != -1: ch = curses.ascii.alt(ch2) self.parent.curses_pad.timeout(-1) # back to blocking mode #curses.flushinp() elif (TEST_SETTINGS['INPUT_GENERATOR']): self._last_get_ch_was_unicode = True try: ch = next(TEST_SETTINGS['INPUT_GENERATOR']) except StopIteration: if TEST_SETTINGS['CONTINUE_AFTER_TEST_INPUT']: TEST_SETTINGS['INPUT_GENERATOR'] = None return else: raise ExhaustedTestInput else: self._last_get_ch_was_unicode = True try: ch = TEST_SETTINGS['TEST_INPUT'].pop(0) TEST_SETTINGS['TEST_INPUT_LOG'].append(ch) except IndexError: if TEST_SETTINGS['CONTINUE_AFTER_TEST_INPUT']: TEST_SETTINGS['TEST_INPUT'] = None return else: raise ExhaustedTestInput self.handle_input(ch) if self.check_value_change: self.when_check_value_changed() if self.check_cursor_move: self.when_check_cursor_moved() self.try_adjust_widgets()
Example #10
Source File: wgwidget.py From HomePWN with GNU General Public License v3.0 | 4 votes |
def get_and_use_key_press(self): global TEST_SETTINGS if (TEST_SETTINGS['TEST_INPUT'] is None) and (TEST_SETTINGS['INPUT_GENERATOR'] is None): curses.raw() curses.cbreak() curses.meta(1) self.parent.curses_pad.keypad(1) if self.parent.keypress_timeout: curses.halfdelay(self.parent.keypress_timeout) ch = self._get_ch() if ch == -1: return self.try_while_waiting() else: self.parent.curses_pad.timeout(-1) ch = self._get_ch() # handle escape-prefixed rubbish. if ch == curses.ascii.ESC: #self.parent.curses_pad.timeout(1) self.parent.curses_pad.nodelay(1) ch2 = self.parent.curses_pad.getch() if ch2 != -1: ch = curses.ascii.alt(ch2) self.parent.curses_pad.timeout(-1) # back to blocking mode #curses.flushinp() elif (TEST_SETTINGS['INPUT_GENERATOR']): self._last_get_ch_was_unicode = True try: ch = next(TEST_SETTINGS['INPUT_GENERATOR']) except StopIteration: if TEST_SETTINGS['CONTINUE_AFTER_TEST_INPUT']: TEST_SETTINGS['INPUT_GENERATOR'] = None return else: raise ExhaustedTestInput else: self._last_get_ch_was_unicode = True try: ch = TEST_SETTINGS['TEST_INPUT'].pop(0) TEST_SETTINGS['TEST_INPUT_LOG'].append(ch) except IndexError: if TEST_SETTINGS['CONTINUE_AFTER_TEST_INPUT']: TEST_SETTINGS['TEST_INPUT'] = None return else: raise ExhaustedTestInput self.handle_input(ch) if self.check_value_change: self.when_check_value_changed() if self.check_cursor_move: self.when_check_cursor_moved() self.try_adjust_widgets()
Example #11
Source File: wgwidget.py From EDCOP with Apache License 2.0 | 4 votes |
def get_and_use_key_press(self): global TEST_SETTINGS if (TEST_SETTINGS['TEST_INPUT'] is None) and (TEST_SETTINGS['INPUT_GENERATOR'] is None): curses.raw() curses.cbreak() curses.meta(1) self.parent.curses_pad.keypad(1) if self.parent.keypress_timeout: curses.halfdelay(self.parent.keypress_timeout) ch = self._get_ch() if ch == -1: return self.try_while_waiting() else: self.parent.curses_pad.timeout(-1) ch = self._get_ch() # handle escape-prefixed rubbish. if ch == curses.ascii.ESC: #self.parent.curses_pad.timeout(1) self.parent.curses_pad.nodelay(1) ch2 = self.parent.curses_pad.getch() if ch2 != -1: ch = curses.ascii.alt(ch2) self.parent.curses_pad.timeout(-1) # back to blocking mode #curses.flushinp() elif (TEST_SETTINGS['INPUT_GENERATOR']): self._last_get_ch_was_unicode = True try: ch = next(TEST_SETTINGS['INPUT_GENERATOR']) except StopIteration: if TEST_SETTINGS['CONTINUE_AFTER_TEST_INPUT']: TEST_SETTINGS['INPUT_GENERATOR'] = None return else: raise ExhaustedTestInput else: self._last_get_ch_was_unicode = True try: ch = TEST_SETTINGS['TEST_INPUT'].pop(0) TEST_SETTINGS['TEST_INPUT_LOG'].append(ch) except IndexError: if TEST_SETTINGS['CONTINUE_AFTER_TEST_INPUT']: TEST_SETTINGS['TEST_INPUT'] = None return else: raise ExhaustedTestInput self.handle_input(ch) if self.check_value_change: self.when_check_value_changed() if self.check_cursor_move: self.when_check_cursor_moved() self.try_adjust_widgets()
Example #12
Source File: wgwidget.py From TelegramTUI with MIT License | 4 votes |
def get_and_use_key_press(self): global TEST_SETTINGS if (TEST_SETTINGS['TEST_INPUT'] is None) and (TEST_SETTINGS['INPUT_GENERATOR'] is None): curses.raw() curses.cbreak() curses.meta(1) self.parent.curses_pad.keypad(1) if self.parent.keypress_timeout: curses.halfdelay(self.parent.keypress_timeout) ch = self._get_ch() if ch == -1: return self.try_while_waiting() else: self.parent.curses_pad.timeout(-1) ch = self._get_ch() # handle escape-prefixed rubbish. if ch == curses.ascii.ESC: #self.parent.curses_pad.timeout(1) self.parent.curses_pad.nodelay(1) ch2 = self.parent.curses_pad.getch() if ch2 != -1: ch = curses.ascii.alt(ch2) self.parent.curses_pad.timeout(-1) # back to blocking mode #curses.flushinp() elif (TEST_SETTINGS['INPUT_GENERATOR']): self._last_get_ch_was_unicode = True try: ch = next(TEST_SETTINGS['INPUT_GENERATOR']) except StopIteration: if TEST_SETTINGS['CONTINUE_AFTER_TEST_INPUT']: TEST_SETTINGS['INPUT_GENERATOR'] = None return else: raise ExhaustedTestInput else: self._last_get_ch_was_unicode = True try: ch = TEST_SETTINGS['TEST_INPUT'].pop(0) TEST_SETTINGS['TEST_INPUT_LOG'].append(ch) except IndexError: if TEST_SETTINGS['CONTINUE_AFTER_TEST_INPUT']: TEST_SETTINGS['TEST_INPUT'] = None return else: raise ExhaustedTestInput self.handle_input(ch) if self.check_value_change: self.when_check_value_changed() if self.check_cursor_move: self.when_check_cursor_moved() self.try_adjust_widgets()