def __show_lines(self, lines, header, highlight=None): lines_as_string = "" t = Terminal() color = 0 for line in lines: if line[0]['name'] == '_SEPARATOR_': #import pdb;pdb.set_trace() lines_as_string += "%s\n" % self.__get_dots(header) continue else: lines_as_string += self.column_token for cell in line: try: name = cell['name'] if highlight in name: name = "%s" % t.bold_black_on_yellow(name) lines_as_string += " %s%s %s" % (name, " " * (cell['len'] - len(cell['name'])), self.column_token) except TypeError: if self.color: if color == 1: lines_as_string += " %s%s%s%s%s %s" % (self.c.get_cell_a_background_color(), self.c.get_cell_a_color(), name, " " * (cell['len'] - len(str(cell['name']))), self.c.ENDC, self.column_token) else: lines_as_string += " %s%s%s%s%s %s" % (self.c.get_cell_b_background_color(), self.c.get_cell_b_color(), name, " " * (cell['len'] - len(str(cell['name']))), self.c.ENDC, self.column_token) else: lines_as_string += " %s%s %s" % (name, " " * (cell['len'] - len(str(cell['name']))), self.column_token) if self.color: if color == 0: color = 1 else: color = 0 lines_as_string += "\n" print lines_as_string.strip("\n") self.__show_dots(header)
def __show_lines(self, lines, header, highlight=None): lines_as_string = "" t = Terminal() for line in lines: lines_as_string += self.column_token for cell in line: try: name = cell['name'] if highlight in name: name = "%s" % t.bold_black_on_yellow(name) lines_as_string += " %s%s %s" % (name, " " * (cell['len'] - len(cell['name'])), self.column_token) except TypeError: lines_as_string += " %s%s %s" % (name, " " * (cell['len'] - len(str(cell['name']))), self.column_token) lines_as_string += "\n" print lines_as_string.strip("\n") self.__show_dots(header)
#!/usr/bin/env python3 from blessings import Terminal t = Terminal() print(t.clear()) print(t.bold_black_on_yellow("Print yellow text"))
#!/usr/bin/env python3 from blessings import Terminal t = Terminal() print(t.clear()) def yellow_np(): print(t.bold_black_on_yellow('Print yellow text')) yellow_wp(p): print(t.bold_black_on_yellow(p)) yellow_np() yellow_wp("I want this to print in YELLOW") print(t.move_down) print(t.bold_red_on_bright_green('It hurts my eyes!')) print(t.move_down+t.bold_underline_black_on_yellow('Look! A 1997 web page! No, the font would have to be blinking')) print(t.move_down) print(" Terminal width: ",t.width) print(" Terminal height: ",t.height) print(t.move_down+"A one-liner way to show terminal width and height",t.reverse,t.width,"by",t.height," ") with t.location(20, t.height - 1): print(t.reverse + t.blink('This is at the bottom and printed in REVERSE.'))
#!/usr/bin/env python3 #Defining Functions and formating text #Written by Homer Walden from blessings import Terminal t = Terminal() print(t.clear()) print(t.bold_black_on_yellow('Print yellow text')) def yellow_np(): print(t.bold_black_on_yellow('Print yellow text')) def yellow_wp(p): print(t.bold_black_on_yellow(p)) yellow_np() yellow_wp("I want this to print in YELLOW")