def render(self, win): w, h = self.size win.erase() # colours col_text = get_colour_pair(self.fg_colour, self.bg_colour) col_info = get_colour_pair(self.info_fg_colour, self.info_bg_colour) col_text_sel = get_colour_pair(self.selected_fg_colour, self.selected_bg_colour) col_info_sel = get_colour_pair(self.selected_info_fg_colour, self.selected_info_bg_colour) # background win.bkgd(col_text) # create a list of lines for the complete list box # and their respective colours lines = [] selected_line = 0 for index, item in enumerate(self.items): if index == self._selected_item_index: selected_line = len(lines) this_ite_col_text = col_text_sel this_ite_col_info = col_info_sel else: this_ite_col_text = col_text this_ite_col_info = col_info lines.append((this_ite_col_text, item.caption)) lines.extend([(this_ite_col_info, info) for info in item.info]) # choose, where to start rendering ("scrolling") # (if the list of lines is longer than the availible height) nr_lines = len(lines) first_line = selected_line - int(h / 2) if first_line + h - 1 >= nr_lines: first_line = nr_lines - h if first_line < 0: first_line = 0 # draw the lines visible_lines = lines[first_line:first_line + h] for index, (colour, line) in enumerate(visible_lines): # draw the text in the chosen colour render_text(win, line, 0, index, w, 1, text_format=colour, fill_bg=True)
def render(self, pad): # check, if the pattern needs to be recalculated if self.size != self.last_bg_pattern.shape or self.transition_pos < 1.0: self.update_bg_pattern() # draw w, h = self.size for x in range(w): for y in range(h): # get the style for the current "pixel" pattern_value = self.last_bg_pattern[x, y] if pattern_value > .1: style_character = self.style1_character style_colour_fg = self.style1_colour_fg style_colour_bg = self.style1_colour_bg elif pattern_value < -.1: style_character = self.style2_character style_colour_fg = self.style2_colour_fg style_colour_bg = self.style2_colour_bg else: style_character = self.border_character style_colour_fg = self.border_colour_fg style_colour_bg = self.border_colour_bg # draw try: pad.addstr( y, x, style_character, get_colour_pair(*style_colour_fg, *style_colour_bg)) except curses.error: pass
def render(self, win): # make a white bg win.erase() win.bkgd(get_colour_pair(0, 0, 0, 1, 1, 1)) # black border win.border()
def render(self, win): w, h = self.size win.erase() # background border_col_pair = get_colour_pair(0, 0, 0, 1, 1, 1) win.bkgd(border_col_pair) # draw the labels for the text boxes label_color = get_colour_pair(0, 0, 0, 1, 1, 1) render_text(win, "Server Address:", 1, 2, w - 2, 1, text_format=label_color) render_text(win, "Port:", 1, 9, w - 2, 1, text_format=label_color)
def render(self, win): win.erase() w, h = self.size text_format = get_colour_pair(0, 1, 0, 0, 0, 0) hx, hy = self._help.position hw, hh = self._help.size render_text( win, f"x:{hx} y:{hy} w:{hw} h:{hh}", 5, 5, w-5, h-5, text_format=text_format, )
def render(self, win): w, h = self.size win.erase() # border border_col_pair = get_colour_pair( self.border_fg_colour, self.border_bg_colour) win.bkgd(border_col_pair) win.hline(h-1, 0,curses.ACS_HLINE, w) # colours col_text = get_colour_pair( self.fg_colour, self.bg_colour) col_cursor = get_colour_pair(self.cursor_fg_colour, self.cursor_bg_colour) # calculate the positions text_w = w if self.cursor_pos < text_w: start_char = 0 cursor_position = self.cursor_pos else: start_char = self.cursor_pos - text_w + 1 cursor_position = text_w - 1 # draw the text render_text( win, self.text[start_char:], 0, 0, text_w, 1, text_format=col_text ) # draw the cursor char_under_cursor = (self.text + ' ')[self.cursor_pos] if self.use_cursor: render_text( win, char_under_cursor, cursor_position, 0, 1, 1, text_format=col_cursor )
def render(self, win): w, h = self.size # cls win.erase() # render text text_format = get_colour_pair(self.text_fg_colour, self.text_bg_colour) render_text( win, self.text, 0, 0, w, h, text_format=text_format, fill_bg=True )
def render(self, win): # make a white bg win.erase() win.bkgd(get_colour_pair(0, 0, 0, 1, 1, 1)) # show the title sprite, centered w, h = self.size sprite_w, sprite_h = self._title.size x = int(w / 2 - sprite_w / 2) y = int(h / 2 - sprite_h / 2) self._title.draw(win, x, y) win.border()
def render(self, win): w, h = self.size win.erase() colour = get_colour_pair(0, 0, 0, 1, 1, 1) win.bkgd(colour) if not self._server_list_box_visible: render_text( win, "Searching for servers...", 0, 0, w, h, alignment=TextAlignment.CENTER, valignment=VerticalTextAlignment.CENTER, text_format=colour, )