Python curses.A_STANDOUT Examples
The following are 30
code examples of curses.A_STANDOUT().
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: wgtextbox.py From HomePWN with GNU General Public License v3.0 | 6 votes |
def print_cursor(self): # This needs fixing for Unicode multi-width chars. # Cursors do not seem to work on pads. #self.parent.curses_pad.move(self.rely, self.cursor_position - self.begin_at) # let's have a fake cursor _cur_loc_x = self.cursor_position - self.begin_at + self.relx + self.left_margin # The following two lines work fine for ascii, but not for unicode #char_under_cur = self.parent.curses_pad.inch(self.rely, _cur_loc_x) #self.parent.curses_pad.addch(self.rely, self.cursor_position - self.begin_at + self.relx, char_under_cur, curses.A_STANDOUT) #The following appears to work for unicode as well. try: #char_under_cur = self.value[self.cursor_position] #use the real value char_under_cur = self._get_string_to_print()[self.cursor_position] char_under_cur = self.safe_string(char_under_cur) except IndexError: char_under_cur = ' ' except TypeError: char_under_cur = ' ' if self.do_colors(): self.parent.curses_pad.addstr(self.rely, self.cursor_position - self.begin_at + self.relx + self.left_margin, char_under_cur, self.parent.theme_manager.findPair(self, 'CURSOR_INVERSE')) else: self.parent.curses_pad.addstr(self.rely, self.cursor_position - self.begin_at + self.relx + self.left_margin, char_under_cur, curses.A_STANDOUT)
Example #2
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 #3
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 #4
Source File: curses_reporter.py From copycat with MIT License | 6 votes |
def do_keyboard_shortcuts(self): w = self.temperatureWindow # just a random window ordch = w.getch() if ordch in [ord('P'), ord('p')]: w.addstr(0, 0, 'PAUSE', curses.A_STANDOUT) w.refresh() ordch = None while ordch not in [ord('P'), ord('p'), 27, ord('Q'), ord('q')]: time.sleep(0.1) ordch = w.getch() self.fpsTicks = 0 self.fpsSince = time.time() w.erase() w.border() w.refresh() if ordch in [27, ord('Q'), ord('q')]: raise KeyboardInterrupt() if ordch in [ord('F')]: self.fpsGoal = (self.fpsGoal or self.fpsMeasured) * 1.25 if ordch in [ord('f')]: self.fpsGoal = (self.fpsGoal or self.fpsMeasured) * 0.8
Example #5
Source File: wgtexttokens.py From HomePWN with GNU General Public License v3.0 | 6 votes |
def print_cursor(self): _cur_loc_x = self.cursor_position - self.begin_at + self.relx + self.left_margin try: char_under_cur = self.decode_token(self.value[self.cursor_position]) #use the real value char_under_cur = self.safe_string(char_under_cur) except IndexError: char_under_cur = ' ' if isinstance(char_under_cur, bytes): char_under_cur = char_under_cur.decode(self.encoding, 'replace') offset = self.find_cursor_offset_on_screen(self.cursor_position) if self.do_colors(): ATTR_LIST = self.parent.theme_manager.findPair(self) | curses.A_STANDOUT else: ATTR_LIST = curses.A_STANDOUT self.add_line(self.rely, self.begin_at + self.relx + self.left_margin + offset, char_under_cur, self.make_attributes_list(char_under_cur, ATTR_LIST), # I don't understand why the "- self.begin_at" is needed in the following line # but it is or the cursor can end up overrunning the end of the widget. self.maximum_string_length+1 - self.left_margin - offset - self.begin_at, )
Example #6
Source File: wgtexttokens.py From TelegramTUI with MIT License | 6 votes |
def print_cursor(self): _cur_loc_x = self.cursor_position - self.begin_at + self.relx + self.left_margin try: char_under_cur = self.decode_token(self.value[self.cursor_position]) #use the real value char_under_cur = self.safe_string(char_under_cur) except IndexError: char_under_cur = ' ' if isinstance(char_under_cur, bytes): char_under_cur = char_under_cur.decode(self.encoding, 'replace') offset = self.find_cursor_offset_on_screen(self.cursor_position) if self.do_colors(): ATTR_LIST = self.parent.theme_manager.findPair(self) | curses.A_STANDOUT else: ATTR_LIST = curses.A_STANDOUT self.add_line(self.rely, self.begin_at + self.relx + self.left_margin + offset, char_under_cur, self.make_attributes_list(char_under_cur, ATTR_LIST), # I don't understand why the "- self.begin_at" is needed in the following line # but it is or the cursor can end up overrunning the end of the widget. self.maximum_string_length+1 - self.left_margin - offset - self.begin_at, )
Example #7
Source File: wgtextbox.py From TelegramTUI with MIT License | 6 votes |
def print_cursor(self): # This needs fixing for Unicode multi-width chars. # Cursors do not seem to work on pads. #self.parent.curses_pad.move(self.rely, self.cursor_position - self.begin_at) # let's have a fake cursor _cur_loc_x = self.cursor_position - self.begin_at + self.relx + self.left_margin # The following two lines work fine for ascii, but not for unicode #char_under_cur = self.parent.curses_pad.inch(self.rely, _cur_loc_x) #self.parent.curses_pad.addch(self.rely, self.cursor_position - self.begin_at + self.relx, char_under_cur, curses.A_STANDOUT) #The following appears to work for unicode as well. try: #char_under_cur = self.value[self.cursor_position] #use the real value char_under_cur = self._get_string_to_print()[self.cursor_position] char_under_cur = self.safe_string(char_under_cur) except IndexError: char_under_cur = ' ' except TypeError: char_under_cur = ' ' if self.do_colors(): self.parent.curses_pad.addstr(self.rely, self.cursor_position - self.begin_at + self.relx + self.left_margin, char_under_cur, self.parent.theme_manager.findPair(self, 'CURSOR_INVERSE')) else: self.parent.curses_pad.addstr(self.rely, self.cursor_position - self.begin_at + self.relx + self.left_margin, char_under_cur, curses.A_STANDOUT)
Example #8
Source File: wgtextbox.py From apple_bleee with GNU General Public License v3.0 | 6 votes |
def print_cursor(self): # This needs fixing for Unicode multi-width chars. # Cursors do not seem to work on pads. #self.parent.curses_pad.move(self.rely, self.cursor_position - self.begin_at) # let's have a fake cursor _cur_loc_x = self.cursor_position - self.begin_at + self.relx + self.left_margin # The following two lines work fine for ascii, but not for unicode #char_under_cur = self.parent.curses_pad.inch(self.rely, _cur_loc_x) #self.parent.curses_pad.addch(self.rely, self.cursor_position - self.begin_at + self.relx, char_under_cur, curses.A_STANDOUT) #The following appears to work for unicode as well. try: #char_under_cur = self.value[self.cursor_position] #use the real value char_under_cur = self._get_string_to_print()[self.cursor_position] char_under_cur = self.safe_string(char_under_cur) except IndexError: char_under_cur = ' ' except TypeError: char_under_cur = ' ' if self.do_colors(): self.parent.curses_pad.addstr(self.rely, self.cursor_position - self.begin_at + self.relx + self.left_margin, char_under_cur, self.parent.theme_manager.findPair(self, 'CURSOR_INVERSE')) else: self.parent.curses_pad.addstr(self.rely, self.cursor_position - self.begin_at + self.relx + self.left_margin, char_under_cur, curses.A_STANDOUT)
Example #9
Source File: wgtexttokens.py From apple_bleee with GNU General Public License v3.0 | 6 votes |
def print_cursor(self): _cur_loc_x = self.cursor_position - self.begin_at + self.relx + self.left_margin try: char_under_cur = self.decode_token(self.value[self.cursor_position]) #use the real value char_under_cur = self.safe_string(char_under_cur) except IndexError: char_under_cur = ' ' if isinstance(char_under_cur, bytes): char_under_cur = char_under_cur.decode(self.encoding, 'replace') offset = self.find_cursor_offset_on_screen(self.cursor_position) if self.do_colors(): ATTR_LIST = self.parent.theme_manager.findPair(self) | curses.A_STANDOUT else: ATTR_LIST = curses.A_STANDOUT self.add_line(self.rely, self.begin_at + self.relx + self.left_margin + offset, char_under_cur, self.make_attributes_list(char_under_cur, ATTR_LIST), # I don't understand why the "- self.begin_at" is needed in the following line # but it is or the cursor can end up overrunning the end of the widget. self.maximum_string_length+1 - self.left_margin - offset - self.begin_at, )
Example #10
Source File: wgtextbox.py From EDCOP with Apache License 2.0 | 6 votes |
def print_cursor(self): # This needs fixing for Unicode multi-width chars. # Cursors do not seem to work on pads. #self.parent.curses_pad.move(self.rely, self.cursor_position - self.begin_at) # let's have a fake cursor _cur_loc_x = self.cursor_position - self.begin_at + self.relx + self.left_margin # The following two lines work fine for ascii, but not for unicode #char_under_cur = self.parent.curses_pad.inch(self.rely, _cur_loc_x) #self.parent.curses_pad.addch(self.rely, self.cursor_position - self.begin_at + self.relx, char_under_cur, curses.A_STANDOUT) #The following appears to work for unicode as well. try: #char_under_cur = self.value[self.cursor_position] #use the real value char_under_cur = self._get_string_to_print()[self.cursor_position] char_under_cur = self.safe_string(char_under_cur) except IndexError: char_under_cur = ' ' except TypeError: char_under_cur = ' ' if self.do_colors(): self.parent.curses_pad.addstr(self.rely, self.cursor_position - self.begin_at + self.relx + self.left_margin, char_under_cur, self.parent.theme_manager.findPair(self, 'CURSOR_INVERSE')) else: self.parent.curses_pad.addstr(self.rely, self.cursor_position - self.begin_at + self.relx + self.left_margin, char_under_cur, curses.A_STANDOUT)
Example #11
Source File: wgtexttokens.py From EDCOP with Apache License 2.0 | 6 votes |
def print_cursor(self): _cur_loc_x = self.cursor_position - self.begin_at + self.relx + self.left_margin try: char_under_cur = self.decode_token(self.value[self.cursor_position]) #use the real value char_under_cur = self.safe_string(char_under_cur) except IndexError: char_under_cur = ' ' if isinstance(char_under_cur, bytes): char_under_cur = char_under_cur.decode(self.encoding, 'replace') offset = self.find_cursor_offset_on_screen(self.cursor_position) if self.do_colors(): ATTR_LIST = self.parent.theme_manager.findPair(self) | curses.A_STANDOUT else: ATTR_LIST = curses.A_STANDOUT self.add_line(self.rely, self.begin_at + self.relx + self.left_margin + offset, char_under_cur, self.make_attributes_list(char_under_cur, ATTR_LIST), # I don't understand why the "- self.begin_at" is needed in the following line # but it is or the cursor can end up overrunning the end of the widget. self.maximum_string_length+1 - self.left_margin - offset - self.begin_at, )
Example #12
Source File: tabview.py From OpenTrader with GNU Lesser General Public License v3.0 | 5 votes |
def display(self): self.win.erase() addstr(self.win, 1, 1, self.title[:self.term_cols - 3], curses.A_STANDOUT) visible_rows = self.tdata[self.hid_rows:self.hid_rows + self.nlines] addstr(self.win, 2, 1, '\n '.join(visible_rows)) self.win.box() self.win.refresh()
Example #13
Source File: wgtextbox.py From EDCOP with Apache License 2.0 | 5 votes |
def print_cursor_pre_unicode(self): # Cursors do not seem to work on pads. #self.parent.curses_pad.move(self.rely, self.cursor_position - self.begin_at) # let's have a fake cursor _cur_loc_x = self.cursor_position - self.begin_at + self.relx + self.left_margin # The following two lines work fine for ascii, but not for unicode #char_under_cur = self.parent.curses_pad.inch(self.rely, _cur_loc_x) #self.parent.curses_pad.addch(self.rely, self.cursor_position - self.begin_at + self.relx, char_under_cur, curses.A_STANDOUT) #The following appears to work for unicode as well. try: char_under_cur = self.display_value(self.value)[self.cursor_position] except: char_under_cur = ' ' self.parent.curses_pad.addstr(self.rely, self.cursor_position - self.begin_at + self.relx + self.left_margin, char_under_cur, curses.A_STANDOUT)
Example #14
Source File: wgbutton.py From EDCOP with Apache License 2.0 | 5 votes |
def update(self, clear=True): if clear: self.clear() if self.hidden: self.clear() return False if self.value and self.do_colors(): self.parent.curses_pad.addstr(self.rely, self.relx, '>', self.parent.theme_manager.findPair(self)) self.parent.curses_pad.addstr(self.rely, self.relx+self.width-1, '<', self.parent.theme_manager.findPair(self)) elif self.value: self.parent.curses_pad.addstr(self.rely, self.relx, '>') self.parent.curses_pad.addstr(self.rely, self.relx+self.width-1, '<') if self.editing: button_state = curses.A_STANDOUT else: button_state = curses.A_NORMAL button_name = self.name if isinstance(button_name, bytes): button_name = button_name.decode(self.encoding, 'replace') button_name = button_name.center(self.label_width) if self.do_colors(): if self.cursor_color: if self.editing: button_attributes = self.parent.theme_manager.findPair(self, self.cursor_color) else: button_attributes = self.parent.theme_manager.findPair(self, self.color) else: button_attributes = self.parent.theme_manager.findPair(self, self.color) | button_state else: button_attributes = button_state self.add_line(self.rely, self.relx+1, button_name, self.make_attributes_list(button_name, button_attributes), self.label_width )
Example #15
Source File: wgmultilinetree.py From EDCOP with Apache License 2.0 | 5 votes |
def _print(self, left_margin=0): self.left_margin = left_margin self.parent.curses_pad.bkgdset(' ',curses.A_NORMAL) self.left_margin += self._print_tree(self.relx) if self.highlight: self.parent.curses_pad.bkgdset(' ',curses.A_STANDOUT) super(TreeLine, self)._print()
Example #16
Source File: wgcheckbox.py From EDCOP with Apache License 2.0 | 5 votes |
def update(self, clear=True): if clear: self.clear() if self.hidden: self.clear() return False if self.hide: return True if self.value: cb_display = self.__class__.True_box else: cb_display = self.__class__.False_box if self.do_colors(): self.parent.curses_pad.addstr(self.rely, self.relx, cb_display, self.parent.theme_manager.findPair(self, 'CONTROL')) else: self.parent.curses_pad.addstr(self.rely, self.relx, cb_display) if self.editing: if self.value: char_under_cur = 'X' else: char_under_cur = ' ' if self.do_colors(): self.parent.curses_pad.addstr(self.rely, self.relx + 1, char_under_cur, self.parent.theme_manager.findPair(self) | curses.A_STANDOUT) else: self.parent.curses_pad.addstr(self.rely, self.relx + 1, curses.A_STANDOUT)
Example #17
Source File: wgmultilinetreeselectable.py From EDCOP with Apache License 2.0 | 5 votes |
def _print(self, left_margin=0): if not hasattr(self._tree_real_value, 'selected'): return None self.left_margin = left_margin self.parent.curses_pad.bkgdset(' ',curses.A_NORMAL) self.left_margin += self._print_tree(self.relx) self.left_margin += self._print_select_controls() + 1 if self.do_colors(): self.left_margin += self.annotationColor(self.left_margin+self.relx) else: self.left_margin += self.annotationNoColor(self.left_margin+self.relx) if self.highlight: self.parent.curses_pad.bkgdset(' ',curses.A_STANDOUT) super(wgmultilinetree.TreeLine, self)._print()
Example #18
Source File: bookViewer.py From PyLimitOrderBook with MIT License | 5 votes |
def draw_help(self): dimensions = self.screen.getmaxyx() self.screen.addstr(dimensions[0] - 2, 1, self.help_text, curses.A_STANDOUT) if len(self.help_text) < self.screen.getmaxyx()[1] - 4: empty = self.screen.getmaxyx()[1] - len(self.help_text) - 3 self.screen.addstr(dimensions[0] - 2, len(self.help_text) + 1, " " * empty, \ curses.A_STANDOUT)
Example #19
Source File: wgmultilinetreeselectable.py From TelegramTUI with MIT License | 5 votes |
def _print(self, left_margin=0): if not hasattr(self._tree_real_value, 'selected'): return None self.left_margin = left_margin self.parent.curses_pad.bkgdset(' ',curses.A_NORMAL) self.left_margin += self._print_tree(self.relx) self.left_margin += self._print_select_controls() + 1 if self.highlight: self.parent.curses_pad.bkgdset(' ',curses.A_STANDOUT) super(wgmultilinetree.TreeLine, self)._print()
Example #20
Source File: wgmultilinetreeselectable.py From TelegramTUI with MIT License | 5 votes |
def _print(self, left_margin=0): if not hasattr(self._tree_real_value, 'selected'): return None self.left_margin = left_margin self.parent.curses_pad.bkgdset(' ',curses.A_NORMAL) self.left_margin += self._print_tree(self.relx) self.left_margin += self._print_select_controls() + 1 if self.do_colors(): self.left_margin += self.annotationColor(self.left_margin+self.relx) else: self.left_margin += self.annotationNoColor(self.left_margin+self.relx) if self.highlight: self.parent.curses_pad.bkgdset(' ',curses.A_STANDOUT) super(wgmultilinetree.TreeLine, self)._print()
Example #21
Source File: wgmultilinetree.py From TelegramTUI with MIT License | 5 votes |
def _print(self, left_margin=0): self.left_margin = left_margin self.parent.curses_pad.bkgdset(' ',curses.A_NORMAL) self.left_margin += self._print_tree(self.relx) if self.highlight: self.parent.curses_pad.bkgdset(' ',curses.A_STANDOUT) super(TreeLine, self)._print()
Example #22
Source File: wgtextbox.py From TelegramTUI with MIT License | 5 votes |
def print_cursor_pre_unicode(self): # Cursors do not seem to work on pads. #self.parent.curses_pad.move(self.rely, self.cursor_position - self.begin_at) # let's have a fake cursor _cur_loc_x = self.cursor_position - self.begin_at + self.relx + self.left_margin # The following two lines work fine for ascii, but not for unicode #char_under_cur = self.parent.curses_pad.inch(self.rely, _cur_loc_x) #self.parent.curses_pad.addch(self.rely, self.cursor_position - self.begin_at + self.relx, char_under_cur, curses.A_STANDOUT) #The following appears to work for unicode as well. try: char_under_cur = self.display_value(self.value)[self.cursor_position] except: char_under_cur = ' ' self.parent.curses_pad.addstr(self.rely, self.cursor_position - self.begin_at + self.relx + self.left_margin, char_under_cur, curses.A_STANDOUT)
Example #23
Source File: wgbutton.py From TelegramTUI with MIT License | 5 votes |
def update(self, clear=True): if clear: self.clear() if self.hidden: self.clear() return False if self.value and self.do_colors(): self.parent.curses_pad.addstr(self.rely, self.relx, '>', self.parent.theme_manager.findPair(self)) self.parent.curses_pad.addstr(self.rely, self.relx+self.width-1, '<', self.parent.theme_manager.findPair(self)) elif self.value: self.parent.curses_pad.addstr(self.rely, self.relx, '>') self.parent.curses_pad.addstr(self.rely, self.relx+self.width-1, '<') if self.editing: button_state = curses.A_STANDOUT else: button_state = curses.A_NORMAL button_name = self.name if isinstance(button_name, bytes): button_name = button_name.decode(self.encoding, 'replace') button_name = button_name.center(self.label_width) if self.do_colors(): if self.cursor_color: if self.editing: button_attributes = self.parent.theme_manager.findPair(self, self.cursor_color) else: button_attributes = self.parent.theme_manager.findPair(self, self.color) else: button_attributes = self.parent.theme_manager.findPair(self, self.color) | button_state else: button_attributes = button_state self.add_line(self.rely, self.relx+1, button_name, self.make_attributes_list(button_name, button_attributes), self.label_width )
Example #24
Source File: wgcheckbox.py From TelegramTUI with MIT License | 5 votes |
def update(self, clear=True): if clear: self.clear() if self.hidden: self.clear() return False if self.hide: return True if self.value: cb_display = self.__class__.True_box else: cb_display = self.__class__.False_box if self.do_colors(): self.parent.curses_pad.addstr(self.rely, self.relx, cb_display, self.parent.theme_manager.findPair(self, 'CONTROL')) else: self.parent.curses_pad.addstr(self.rely, self.relx, cb_display) if self.editing: if self.value: char_under_cur = 'X' else: char_under_cur = ' ' if self.do_colors(): self.parent.curses_pad.addstr(self.rely, self.relx + 1, char_under_cur, self.parent.theme_manager.findPair(self) | curses.A_STANDOUT) else: self.parent.curses_pad.addstr(self.rely, self.relx + 1, curses.A_STANDOUT)
Example #25
Source File: multi_selection_menu.py From GPIOnext with MIT License | 5 votes |
def draw(self): """ Redraws the menu and refreshes the screen. Should be called whenever something changes that needs to be redrawn. """ self.screen.border(0) if self.title is not None: self.screen.addstr(1, 2, self.title, curses.A_STANDOUT) buttonCount = "{0} Buttons Selected".format(len([ x.defaultText for x in self.items if x.checked ])) self.screen.addstr(1, len(self.title) + 4, "-", curses.A_BOLD) self.screen.addstr(1, len(self.title) + 7, buttonCount, curses.A_STANDOUT) if self.subtitle is not None: self.screen.addstr(2, 2, self.subtitle, curses.A_BOLD) instruction = ("[SPACEBAR]-Check/Uncheck Item " "[ENTER]-Continue") self.screen.addstr(3, 4, instruction, curses.A_BOLD) for index, item in enumerate(self.items): if self.current_option == index: text_style = self.highlight else: text_style = self.normal self.screen.addstr(5 + index, 4, item.show(index), text_style) screen_rows, screen_cols = CursesMenu.stdscr.getmaxyx() top_row = 0 if 6 + len(self.items) > screen_rows: if screen_rows + self.current_option < 6 + len(self.items): top_row = self.current_option else: top_row = 6 + len(self.items) - screen_rows self.screen.refresh(top_row, 0, 0, 0, screen_rows - 1, screen_cols - 1)
Example #26
Source File: extendedMenu.py From GPIOnext with MIT License | 5 votes |
def draw(self): """ Redraws the menu and refreshes the screen. Should be called whenever something changes that needs to be redrawn. """ self.screen.border(0) if self.title is not None: self.screen.addstr(1, 2, self.title, curses.A_STANDOUT) buttonCount = "{0} Buttons Selected".format(len([ x.defaultText for x in self.items if x.checked ])) self.screen.addstr(1, len(self.title) + 4, "-", curses.A_BOLD) self.screen.addstr(1, len(self.title) + 7, buttonCount, curses.A_STANDOUT) if self.subtitle is not None: self.screen.addstr(2, 2, self.subtitle, curses.A_BOLD) instruction = ("[SPACEBAR]-Check/Uncheck Item " "[ENTER]-Continue") self.screen.addstr(3, 4, instruction, curses.A_BOLD) for index, item in enumerate(self.items): if self.current_option == index: text_style = self.highlight else: text_style = self.normal self.screen.addstr(5 + index, 4, item.show(index), text_style) screen_rows, screen_cols = CursesMenu.stdscr.getmaxyx() top_row = 0 if 6 + len(self.items) > screen_rows: if screen_rows + self.current_option < 6 + len(self.items): top_row = self.current_option else: top_row = 6 + len(self.items) - screen_rows self.screen.refresh(top_row, 0, 0, 0, screen_rows - 1, screen_cols - 1)
Example #27
Source File: menu_screen.py From botany with ISC License | 5 votes |
def draw_default(self): # draws default menu clear_bar = " " * (int(self.maxx*2/3)) self.screen_lock.acquire() self.screen.addstr(1, 2, self.title, curses.A_STANDOUT) # Title for this menu self.screen.addstr(3, 2, self.subtitle, curses.A_BOLD) #Subtitle for this menu # clear menu on screen for index in range(len(self.options)+1): self.screen.addstr(4+index, 4, clear_bar, curses.A_NORMAL) # display all the menu items, showing the 'pos' item highlighted for index in range(len(self.options)): textstyle = self.normal if index == self.selected: textstyle = self.highlighted self.screen.addstr(4+index ,4, clear_bar, curses.A_NORMAL) self.screen.addstr(4+index ,4, "%d - %s" % (index+1, self.options[index]), textstyle) self.screen.addstr(12, 2, clear_bar, curses.A_NORMAL) self.screen.addstr(13, 2, clear_bar, curses.A_NORMAL) self.screen.addstr(12, 2, "plant: ", curses.A_DIM) self.screen.addstr(12, 9, self.plant_string, curses.A_NORMAL) self.screen.addstr(13, 2, "score: ", curses.A_DIM) self.screen.addstr(13, 9, self.plant_ticks, curses.A_NORMAL) # display fancy water gauge if not self.plant.dead: water_gauge_str = self.water_gauge() self.screen.addstr(4,14, water_gauge_str, curses.A_NORMAL) else: self.screen.addstr(4,13, clear_bar, curses.A_NORMAL) self.screen.addstr(4,14, "( RIP )", curses.A_NORMAL) # draw cute ascii from files if self.visited_plant: # Needed to prevent drawing over a visited plant self.draw_plant_ascii(self.visited_plant) else: self.draw_plant_ascii(self.plant) self.screen_lock.release()
Example #28
Source File: curses_display.py From anyMesh-Python with MIT License | 5 votes |
def _setattr(self, a): if a is None: self.s.attrset(0) return elif not isinstance(a, AttrSpec): p = self._palette.get(a, (AttrSpec('default', 'default'),)) a = p[0] if self.has_color: if a.foreground_basic: if a.foreground_number >= 8: fg = a.foreground_number - 8 else: fg = a.foreground_number else: fg = 7 if a.background_basic: bg = a.background_number else: bg = 0 attr = curses.color_pair(bg * 8 + 7 - fg) else: attr = 0 if a.bold: attr |= curses.A_BOLD if a.standout: attr |= curses.A_STANDOUT if a.underline: attr |= curses.A_UNDERLINE if a.blink: attr |= curses.A_BLINK self.s.attrset(attr)
Example #29
Source File: event_listening.py From stem with GNU Lesser General Public License v3.0 | 5 votes |
def _render_graph(window, bandwidth_rates): window.erase() download_rates = [entry[0] for entry in bandwidth_rates] upload_rates = [entry[1] for entry in bandwidth_rates] # show the latest values at the top label = "Downloaded (%s/s):" % str_tools.size_label(download_rates[0], 1) window.addstr(0, 1, label, DOWNLOAD_COLOR, curses.A_BOLD) label = "Uploaded (%s/s):" % str_tools.size_label(upload_rates[0], 1) window.addstr(0, GRAPH_WIDTH + 7, label, UPLOAD_COLOR, curses.A_BOLD) # draw the graph bounds in KB max_download_rate = max(download_rates) max_upload_rate = max(upload_rates) window.addstr(1, 1, "%4i" % (max_download_rate / 1024), DOWNLOAD_COLOR) window.addstr(GRAPH_HEIGHT, 1, " 0", DOWNLOAD_COLOR) window.addstr(1, GRAPH_WIDTH + 7, "%4i" % (max_upload_rate / 1024), UPLOAD_COLOR) window.addstr(GRAPH_HEIGHT, GRAPH_WIDTH + 7, " 0", UPLOAD_COLOR) # draw the graph for col in range(GRAPH_WIDTH): col_height = GRAPH_HEIGHT * download_rates[col] / max(max_download_rate, 1) for row in range(col_height): window.addstr(GRAPH_HEIGHT - row, col + 6, " ", DOWNLOAD_COLOR, curses.A_STANDOUT) col_height = GRAPH_HEIGHT * upload_rates[col] / max(max_upload_rate, 1) for row in range(col_height): window.addstr(GRAPH_HEIGHT - row, col + GRAPH_WIDTH + 12, " ", UPLOAD_COLOR, curses.A_STANDOUT) window.refresh()
Example #30
Source File: wgmultilinetreeselectable.py From apple_bleee with GNU General Public License v3.0 | 5 votes |
def _print(self, left_margin=0): if not hasattr(self._tree_real_value, 'selected'): return None self.left_margin = left_margin self.parent.curses_pad.bkgdset(' ',curses.A_NORMAL) self.left_margin += self._print_tree(self.relx) self.left_margin += self._print_select_controls() + 1 if self.highlight: self.parent.curses_pad.bkgdset(' ',curses.A_STANDOUT) super(wgmultilinetree.TreeLine, self)._print()