From: ewt Date: Tue, 2 May 2000 13:27:33 +0000 (+0000) Subject: added help support and testing X-Git-Tag: r0-50-10~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6177ee9b305940361825caaf25b0496cd3348a70;p=thirdparty%2Fnewt.git added help support and testing --- diff --git a/popcorn.py b/popcorn.py index e1283a4..96b44bf 100755 --- a/popcorn.py +++ b/popcorn.py @@ -4,7 +4,8 @@ from snack import * import sys def help(screen, text): - ButtonChoiceWindow(screen, "Help", text) + raise ValueError, "foo" + ButtonChoiceWindow(screen, "Help", text, help = "Help on help") t = TextboxReflowed(25, "Some text which needs to be wrapped at a good place.") li = Listbox(5, width = 20, returnExit = 1) @@ -58,7 +59,8 @@ foo = EntryWindow(screen, 'Title', 'This is some text for the entry window', lbcw = ListboxChoiceWindow(screen, 'Title 2', 'Choose one item from the list below:', - ('One', 'Two', 'Three', 'Four', 'Five'), default = 2) + ('One', 'Two', 'Three', 'Four', 'Five'), default = 2, + help = "Help for a listbox") sg = Grid(2, 3) sg.setField(b, 0, 0, anchorLeft = 1) diff --git a/snack.py b/snack.py index 3a46607..a8e6591 100644 --- a/snack.py +++ b/snack.py @@ -371,12 +371,12 @@ class ButtonBar(Grid): return None -class GridForm(Grid): +class GridFormHelp(Grid): - def __init__(self, screen, title, *args): + def __init__(self, screen, title, help, *args): self.screen = screen self.title = title - self.form = Form() + self.form = Form(help) self.childList = [] self.form_created = 0 args = list(args) @@ -428,6 +428,12 @@ class GridForm(Grid): def setCurrent (self, co): self.form.setCurrent (co) +class GridForm(GridFormHelp): + + def __init__(self, screen, title, *args): + myargs = (self, screen, title, None) + args + apply(GridFormHelp.__init__, myargs) + class CheckboxTree(Widget): def append(self, text, item = None, selected = 0): self.addItem(text, (snackArgs['append'], ), item, selected) @@ -466,7 +472,8 @@ class CheckboxTree(Widget): def ListboxChoiceWindow(screen, title, text, items, buttons = ('Ok', 'Cancel'), - width = 40, scroll = 0, height = -1, default = None): + width = 40, scroll = 0, height = -1, default = None, + help = None): if (height == -1): height = len(items) bb = ButtonBar(screen, buttons) @@ -491,7 +498,7 @@ def ListboxChoiceWindow(screen, title, text, items, if (default != None): l.setCurrent (default) - g = GridForm(screen, title, 1, 3) + g = GridFormHelp(screen, title, help, 1, 3) g.add(t, 0, 0) g.add(l, 0, 1, padding = (0, 1, 0, 1)) g.add(bb, 0, 2, growx = 1) @@ -502,17 +509,17 @@ def ListboxChoiceWindow(screen, title, text, items, def ButtonChoiceWindow(screen, title, text, buttons = [ 'Ok', 'Cancel' ], - width = 40, x = None, y = None): + width = 40, x = None, y = None, help = None): bb = ButtonBar(screen, buttons) t = TextboxReflowed(width, text, maxHeight = screen.height - 12) - g = GridForm(screen, title, 1, 2) + g = GridFormHelp(screen, title, help, 1, 2) g.add(t, 0, 0, padding = (0, 0, 0, 1)) g.add(bb, 0, 1, growx = 1) return bb.buttonPressed(g.runOnce(x, y)) def EntryWindow(screen, title, text, prompts, allowCancel = 1, width = 40, - entryWidth = 20, buttons = [ 'Ok', 'Cancel' ]): + entryWidth = 20, buttons = [ 'Ok', 'Cancel' ], help = None): bb = ButtonBar(screen, buttons); t = TextboxReflowed(width, text) @@ -535,7 +542,7 @@ def EntryWindow(screen, title, text, prompts, allowCancel = 1, width = 40, count = count + 1 entryList.append(e) - g = GridForm(screen, title, 1, 3) + g = GridFormHelp(screen, title, help, 1, 3) g.add(t, 0, 0, padding = (0, 0, 0, 1)) g.add(sg, 0, 1, padding = (0, 0, 0, 1))