Commit 2bd0dd5e authored by Fjen Undso's avatar Fjen Undso
Browse files

c.py/ProgressBar: fix draw

parent 91a5d956
......@@ -179,21 +179,28 @@ class ProgressBar:
self.width = width
self.height = height
self.max = max_value
self.value = 50
self.value = 0
self.attr = attr
self.focus = True
self.text = text
self.prev_key = prev_key
self.next_key = next_key
self.window = window.subwin(height, width, row, col)
self.window.border(0)
if len(text) > width:
self.window.addstr(text)
else:
self.window.addstr(0, (width - len(text)) // 2, text)
self.draw()
def toggle_focus(self):
pass
def draw(self):
self.window.clear()
# draw frame
self.window.border(0)
if len(self.text) > self.width:
self.window.addstr(self.text)
else:
self.window.addstr(0, (self.width - len(self.text)) // 2, self.text)
# draw bar
top = self.height - 1 - int(self.value / self.max * (self.height - 2))
bottom = self.height - 1
for i in range(top, bottom):
......
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