diff --git a/picotui/dialogs.py b/picotui/dialogs.py index a0cf535..bc3f275 100644 --- a/picotui/dialogs.py +++ b/picotui/dialogs.py @@ -18,6 +18,23 @@ def add_ok_cancel_buttons(d): b.finish_dialog = ACTION_CANCEL +def add_next_prev_buttons(d): + if d.h == 0: + d.autosize(0, 1) + if d.w < 20: + d.w = 20 + hw = d.w // 2 + off1 = (hw + 1) // 2 - 4 + off2 = (d.w - hw) + hw // 2 - 4 + b = WButton(8, "Next") + d.add(off1, d.h - 1, b) + b.finish_dialog = ACTION_NEXT + + b = WButton(8, "Back") + d.add(off2, d.h - 1, b) + b.finish_dialog = ACTION_PREV + + class DTextEntry(Dialog): def __init__(self, entry_w, text, title=""): @@ -49,8 +66,8 @@ def result(self): class DConfirmation(Dialog): - def __init__(self, lines, title=""): - super().__init__(10, 5, title=title) + def __init__(self, x, y, entry_w, entry_h, lines, title=""): + super().__init__(x, y, entry_w, entry_h, title=title) if not isinstance(lines, list): lines = [lines] i = 1 diff --git a/picotui/widgets.py b/picotui/widgets.py index 5410cff..2e70af3 100644 --- a/picotui/widgets.py +++ b/picotui/widgets.py @@ -11,6 +11,7 @@ "EditableWidget", "Dialog", "WLabel", + "WProgress", "WFrame", "WButton", "WCheckbox", @@ -150,11 +151,35 @@ def __init__(self, text, w=0): self.w = w if not w: self.w = len(text) + self.validate = False + self.valid = False def redraw(self): self.goto(self.x, self.y) + if self.validate: + if not self.valid: + self.attr_color(C_B_RED, None) + else: + self.attr_color(C_B_GREEN, None) self.wr_fixedw(self.t, self.w) + self.attr_reset() + + +class WProgress(Widget): + + def __init__(self, text, w=10): + self.t = text + self.h = 1 + self.w = w + def redraw(self): + self.goto(self.x, self.y) + self.wr_fixedw(self.t, self.w) + self.attr_reset() + + def update(self, text): + self.t = text + self.redraw() class WFrame(Widget):