Commit 18e54a8a authored by Fjen Undso's avatar Fjen Undso
Browse files

c.py/ProgressBar: add colors

parent 7641996a
......@@ -207,8 +207,8 @@ class ProgressBar:
pass
def draw(self):
self.window.clear()
# draw frame
self.window.erase()
self.window.border(0)
if len(self.text) > self.width:
self.window.addstr(self.text)
......@@ -219,7 +219,7 @@ class ProgressBar:
top = self.height - 1 - int(self.value / self.max * (self.height - 2))
bottom = self.height - 1
for i in range(top, bottom):
self.window.addstr(i, 1, '#' * (self.width - 2), self.attr)
self.window.addstr(i, 1, ' ' * (self.width - 2), self.attr)
self.window.refresh()
def set(self, value):
......@@ -247,16 +247,22 @@ def main(stdscr):
# init colors
curses.start_color()
curses.use_default_colors()
curses.init_pair(curses.COLOR_RED, curses.COLOR_RED, curses.COLOR_WHITE)
curses.init_pair(curses.COLOR_GREEN, curses.COLOR_GREEN, curses.COLOR_WHITE)
curses.init_pair(curses.COLOR_BLUE, curses.COLOR_BLUE, curses.COLOR_WHITE)
curses.init_pair(curses.COLOR_RED, 0, curses.COLOR_RED)
curses.init_pair(curses.COLOR_GREEN, 0, curses.COLOR_GREEN)
curses.init_pair(curses.COLOR_BLUE, 0, curses.COLOR_BLUE)
curses.init_pair(curses.COLOR_WHITE, 0, curses.COLOR_WHITE)
# logging
logger = logging.getLogger(__name__)
logger.addHandler(CursesHandler(stdscr))
logger.setLevel(logging.INFO)
numbers_text = ['R', 'G', 'B', 'W']
numbers_text = [
('R', curses.COLOR_RED),
('G', curses.COLOR_GREEN),
('B', curses.COLOR_BLUE),
('W', curses.COLOR_WHITE)
]
progress_bars = [
ProgressBar(stdscr,
row=0,
......@@ -264,7 +270,8 @@ def main(stdscr):
width=5,
height=12,
max_value=255,
text=numbers_text[i]) for i in range(len(numbers_text))]
attr=curses.color_pair(numbers_text[i][1]),
text=numbers_text[i][0]) for i in range(len(numbers_text))]
numbers = [
NumberRange(
stdscr,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment