From 4ad7896e7d505727977224bac9d43c2cdb5d0103 Mon Sep 17 00:00:00 2001 From: Stephen Arnold Date: Mon, 13 May 2019 13:37:33 -0700 Subject: [PATCH 1/4] dialogs.py: button and confirmation dialog feature/fixes * add next/prev button function * add size params to DConfirmation Dialog class Signed-off-by: Stephen Arnold --- picotui/dialogs.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) 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 From 20ef9cfa0af12fc43996a5d2e5bc1fe26e8f04ea Mon Sep 17 00:00:00 2001 From: Stephen Arnold Date: Mon, 13 May 2019 13:41:03 -0700 Subject: [PATCH 2/4] widgets.py: add input text validation to WLabel widget class * this adds colors for valid/invalid text when .validate is True Signed-off-by: Stephen Arnold --- picotui/widgets.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/picotui/widgets.py b/picotui/widgets.py index 5410cff..58aaea6 100644 --- a/picotui/widgets.py +++ b/picotui/widgets.py @@ -150,10 +150,18 @@ 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 WFrame(Widget): From 2614c9a649246ee39b064745df4db64d811ce038 Mon Sep 17 00:00:00 2001 From: Stephen Arnold Date: Mon, 27 May 2019 21:56:06 -0700 Subject: [PATCH 3/4] picotui/widgets.py: add simple WProgress widget class Signed-off-by: Stephen Arnold --- picotui/widgets.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/picotui/widgets.py b/picotui/widgets.py index 58aaea6..d10f815 100644 --- a/picotui/widgets.py +++ b/picotui/widgets.py @@ -164,6 +164,22 @@ def redraw(self): 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): def __init__(self, w, h, title=""): From c8f1c636ebec5f2d731659707389c2598b696e21 Mon Sep 17 00:00:00 2001 From: Stephen Arnold Date: Thu, 30 May 2019 20:40:47 -0700 Subject: [PATCH 4/4] picotui/widgets.py: fix missing class name (something got lost somewhere) Signed-off-by: Stephen Arnold --- picotui/widgets.py | 1 + 1 file changed, 1 insertion(+) diff --git a/picotui/widgets.py b/picotui/widgets.py index d10f815..2e70af3 100644 --- a/picotui/widgets.py +++ b/picotui/widgets.py @@ -11,6 +11,7 @@ "EditableWidget", "Dialog", "WLabel", + "WProgress", "WFrame", "WButton", "WCheckbox",