Commit 7641996a authored by Fjen Undso's avatar Fjen Undso
Browse files

c.py: add NumberProgressContainer

parent 5c5325f7
......@@ -125,7 +125,7 @@ class CheckBox:
class FocusSwitcher:
def __init__(self, elements=[], prev_key=None, next_key=None):
def __init__(self, *, elements=[], prev_key=None, next_key=None):
self.elements = elements
self.prev_key = prev_key
self.next_key = next_key
......@@ -171,6 +171,21 @@ class FocusSwitcher:
break
class NumberProgressContainer(FocusSwitcher):
def __init__(self, *, elements=[], prev_key=None, next_key=None):
super().__init__(elements=elements, prev_key=None, next_key=None)
def send_key(self, key):
super().send_key(key)
val = 0
for e in self.elements:
if isinstance(e, NumberRange):
val = e.value
for e in self.elements:
if isinstance(e, ProgressBar):
e.set(val)
class ProgressBar:
def __init__(self, window, *, row=0, col=0, width=0, height=0, text='',
max_value=100, attr=curses.A_STANDOUT, prev_key=None, next_key=None):
......@@ -249,8 +264,6 @@ def main(stdscr):
width=5,
height=12,
max_value=255,
prev_key='KEY_DOWN',
next_key='KEY_UP',
text=numbers_text[i]) for i in range(len(numbers_text))]
numbers = [
NumberRange(
......@@ -260,8 +273,8 @@ def main(stdscr):
value=i,
prev_key='KEY_DOWN',
next_key='KEY_UP') for i in range(len(numbers_text))]
fs_pbn = [FocusSwitcher(i) for i in zip(numbers, progress_bars)]
fs_n = FocusSwitcher(fs_pbn, prev_key='KEY_LEFT', next_key='KEY_RIGHT')
fs_pbn = [NumberProgressContainer(elements=i) for i in zip(numbers, progress_bars)]
fs_n = FocusSwitcher(elements=fs_pbn, prev_key='KEY_LEFT', next_key='KEY_RIGHT')
checkboxes = [
CheckBox(
......@@ -271,9 +284,9 @@ def main(stdscr):
toggle_key=' ',
text='ESP' +
str(i)) for i in range(1,9)]
fs_cb = FocusSwitcher(checkboxes, prev_key='KEY_UP', next_key='KEY_DOWN')
fs_cb = FocusSwitcher(elements=checkboxes, prev_key='KEY_UP', next_key='KEY_DOWN')
fs_main = FocusSwitcher([fs_n, fs_cb], prev_key='\t')
fs_main = FocusSwitcher(elements=[fs_n, fs_cb], prev_key='\t')
fs_main.toggle_focus()
stdscr.refresh()
......
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