~ubuntu-branches/ubuntu/dapper/newt/dapper

« back to all changes in this revision

Viewing changes to debian/patches/15_documentation.patch

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2005-03-22 12:44:37 UTC
  • mfrom: (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050322124437-nuhl0pqjcijjno9z
Tags: 0.51.6-20ubuntu3
Add Xhosa translation (thanks, Adi Attar).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
diff -ruN newt-0.51.6-old/newt.c newt-0.51.6/newt.c
 
2
--- newt-0.51.6-old/newt.c      2004-07-11 12:25:36 +0100
 
3
+++ newt-0.51.6/newt.c  2004-07-11 12:27:41 +0100
 
4
@@ -186,6 +186,9 @@
 
5
     }
 
6
 }
 
7
 
 
8
+/**
 
9
+ * @brief Refresh the screen
 
10
+ */
 
11
 void newtRefresh(void) {
 
12
     SLsmg_refresh();
 
13
 }
 
14
@@ -197,6 +200,10 @@
 
15
     SLtt_set_cursor_visibility (cursorOn);
 
16
 }
 
17
 
 
18
+/**
 
19
+ *  @brief Return after suspension.
 
20
+ *  @return 0 on success.
 
21
+ */
 
22
 void newtResume(void) {
 
23
     SLsmg_resume_smg ();
 
24
     SLsmg_refresh();
 
25
@@ -211,6 +218,10 @@
 
26
     newtRefresh();
 
27
 }
 
28
 
 
29
+/**
 
30
+ * @brief Resize the screen
 
31
+ * @param redraw - boolean - should we redraw the screen?
 
32
+ */
 
33
 void newtResizeScreen(int redraw) {
 
34
     SLtt_get_screen_size();
 
35
     SLsmg_reinit_smg();
 
36
@@ -220,6 +231,10 @@
 
37
     }
 
38
 }
 
39
 
 
40
+/**
 
41
+ * @brief Initialize the newt library
 
42
+ * @return int - 0 for success, else < 0
 
43
+ */
 
44
 int newtInit(void) {
 
45
     char * MonoValue, * MonoEnv = "NEWT_MONO";
 
46
     const char *lang;
 
47
@@ -262,6 +277,10 @@
 
48
     return 0;
 
49
 }
 
50
 
 
51
+/**
 
52
+ * @brief Closedown the newt library, tidying screen.
 
53
+ * @returns int , 0. (no errors reported)
 
54
+ */
 
55
 int newtFinished(void) {
 
56
     SLsmg_gotorc(SLtt_Screen_Rows - 1, 0);
 
57
     newtCursorOn();
 
58
@@ -272,6 +291,10 @@
 
59
     return 0;
 
60
 }
 
61
 
 
62
+/**
 
63
+ * @brief Set the colors used.
 
64
+ * @param colors - newtColor struct used.
 
65
+ */
 
66
 void newtSetColors(struct newtColors colors) {
 
67
     if (!SLtt_Use_Ansi_Colors) {
 
68
         int i;
 
69
@@ -425,6 +448,9 @@
 
70
     return *chptr;
 
71
 }
 
72
 
 
73
+/**
 
74
+ * @brief Wait for a keystroke
 
75
+ */
 
76
 void newtWaitForKey(void) {
 
77
     newtRefresh();
 
78
 
 
79
@@ -432,12 +458,24 @@
 
80
     newtClearKeyBuffer();
 
81
 }
 
82
 
 
83
+/**
 
84
+ * @brief Clear the keybuffer
 
85
+ */
 
86
 void newtClearKeyBuffer(void) {
 
87
     while (SLang_input_pending(1)) {
 
88
        getkey();
 
89
     }
 
90
 }
 
91
 
 
92
+/**
 
93
+ * Open a new window.
 
94
+ * @param left. unsigned int Size; _not_ including border
 
95
+ * @param top: unsigned int size, _not_ including border
 
96
+ * @param width unsigned int
 
97
+ * @param height unsigned int
 
98
+ * @param title - title string
 
99
+ * @return zero on success (currently no errors reported)
 
100
+ */
 
101
 int newtOpenWindow(int left, int top, int width, int height,
 
102
                          const char * title) {
 
103
     int j, row, col;
 
104
@@ -516,6 +554,13 @@
 
105
     return 0;
 
106
 }
 
107
 
 
108
+/**
 
109
+ * @brief Draw a centered window.
 
110
+ * @param width - width in char cells
 
111
+ * @param height - no. of char cells.
 
112
+ * @param title - fixed title
 
113
+ * @returns 0. No errors reported
 
114
+ */
 
115
 int newtCenteredWindow(int width, int height, const char * title) {
 
116
     int top, left;
 
117
 
 
118
@@ -531,6 +576,9 @@
 
119
     return 0;
 
120
 }
 
121
 
 
122
+/**
 
123
+ * @brief Remove the top window
 
124
+ */
 
125
 void newtPopWindow(void) {
 
126
     int j, row, col;
 
127
     int n = 0;
 
128
@@ -634,6 +682,10 @@
 
129
 }
 
130
 #endif
 
131
 
 
132
+/**
 
133
+ * @brief Delay for a specified number of usecs
 
134
+ * @param int - number of usecs to wait for.
 
135
+ */
 
136
 void newtDelay(int usecs) {
 
137
     fd_set set;
 
138
     struct timeval tv;
 
139
diff -ruN newt-0.51.6-old/peanuts.py newt-0.51.6/peanuts.py
 
140
--- newt-0.51.6-old/peanuts.py  1999-07-13 16:40:07 +0100
 
141
+++ newt-0.51.6/peanuts.py      2004-07-11 12:25:36 +0100
 
142
@@ -1,5 +1,7 @@
 
143
 #!/usr/bin/python
 
144
 
 
145
+# Demo program to show use of python-newt module
 
146
+
 
147
 from snack import *
 
148
 
 
149
 screen = SnackScreen()
 
150
diff -ruN newt-0.51.6-old/snack.py newt-0.51.6/snack.py
 
151
--- newt-0.51.6-old/snack.py    2003-02-05 07:11:35 +0000
 
152
+++ newt-0.51.6/snack.py        2004-07-11 12:25:36 +0100
 
153
@@ -4,6 +4,41 @@
 
154
 # The second section contains convenience classes that amalgamate
 
155
 # the literal classes and make them more object-oriented.
 
156
 
 
157
+"""
 
158
+This module provides the NEWT Windowing toolkit API for Python
 
159
+This is a lightweight text-mode windowing library, based on slang.
 
160
+
 
161
+Classes:
 
162
+
 
163
+ - Widget  
 
164
+ - Button  
 
165
+ - CompactButton
 
166
+ - Checkbox
 
167
+ - SingleRadioButton
 
168
+ - Listbox
 
169
+ - Textbox
 
170
+ - TextboxReflowed
 
171
+ - Label
 
172
+ - Scale
 
173
+ - Entry
 
174
+ - Form
 
175
+ - Grid
 
176
+ - SnackScreen
 
177
+ - RadioGroup
 
178
+ - RadioBar
 
179
+ - ButtonBar
 
180
+ - GridFormHelp
 
181
+ - GridForm
 
182
+ - CheckboxTree
 
183
+ - Clistbox
 
184
+
 
185
+Functions:
 
186
+
 
187
+ - ListboxChoiceWindow
 
188
+ - ButtonChoiceWindow
 
189
+ - EntryWindow
 
190
+"""
 
191
+
 
192
 import _snack
 
193
 import types
 
194
 import string
 
195
@@ -19,6 +54,15 @@
 
196
 snackArgs = {"append":-1}
 
197
 
 
198
 class Widget:
 
199
+    """Base class for NEWT toolkit
 
200
+
 
201
+    methods:
 
202
+
 
203
+     - Widget(self)
 
204
+     - setCallback(self, obj, data = None) : 
 
205
+          The callback for when object activated.
 
206
+          data is passed to obj.
 
207
+    """
 
208
     def setCallback(self, obj, data = None):
 
209
         if data:
 
210
             self.w.setCallback(obj, data)
 
211
@@ -26,78 +70,119 @@
 
212
             self.w.setCallback(obj)
 
213
             
 
214
     def __init__(self):
 
215
-       self.w = None
 
216
+        self.w = None
 
217
 
 
218
 class Button(Widget):
 
219
+    """Basic button class, takes button text as parameter
 
220
 
 
221
+    method:
 
222
+
 
223
+     - Button(self, text): returns a button
 
224
+    """
 
225
     def __init__(self, text):
 
226
-       self.w = _snack.button(text)
 
227
+        self.w = _snack.button(text)
 
228
 
 
229
 class CompactButton(Widget):
 
230
+    """Compact Button class (less frilly button decoration).
 
231
+
 
232
+    methods:
 
233
 
 
234
+     - CompactButton(self,text) : create button, with text.
 
235
+    """
 
236
     def __init__(self, text):
 
237
-       self.w = _snack.compactbutton(text)
 
238
+        self.w = _snack.compactbutton(text)
 
239
 
 
240
 class Checkbox(Widget):
 
241
+    """A checkbox.
 
242
 
 
243
+    methods:
 
244
+    
 
245
+      - Checkbox(self, text, isOn = 0) : text, and boolean as to default value
 
246
+      - setValue(self)                 : set value
 
247
+      - value(self, value)             : return checkbox value
 
248
+      - selected(self)                 : returns boolean
 
249
+      - setFlags(self, flag, sense)    : set flags
 
250
+
 
251
+      flags:  FLAG_DISABLED, FLAGS_SET, FLAGS_RESET
 
252
+    """
 
253
     def value(self):
 
254
-       return self.w.checkboxValue
 
255
+        return self.w.checkboxValue
 
256
 
 
257
     def selected(self):
 
258
-       return self.w.checkboxValue != 0
 
259
+        return self.w.checkboxValue != 0
 
260
 
 
261
     def setFlags (self, flag, sense):
 
262
+
 
263
         return self.w.checkboxSetFlags(flag, sense)
 
264
 
 
265
     def setValue (self, value):
 
266
         return self.w.checkboxSetValue(value)
 
267
 
 
268
     def __init__(self, text, isOn = 0):
 
269
-       self.w = _snack.checkbox(text, isOn)
 
270
+        self.w = _snack.checkbox(text, isOn)
 
271
 
 
272
 class SingleRadioButton(Widget):
 
273
+    """Single Radio Button.
 
274
 
 
275
+    methods:
 
276
+    
 
277
+     -  SingleRadioButton(text, group, isOn = 0)  : create button
 
278
+     -  selected(self)                            : returns bool, whether or not is selected.
 
279
+    """
 
280
+    
 
281
     def selected(self):
 
282
-       return self.w.key == self.w.radioValue;
 
283
+        return self.w.key == self.w.radioValue;
 
284
     
 
285
     def __init__(self, text, group, isOn = 0):
 
286
-       if group:
 
287
-           self.w = _snack.radiobutton(text, group.w, isOn)
 
288
-       else:
 
289
-           self.w = _snack.radiobutton(text, None, isOn)
 
290
+        if group:
 
291
+            self.w = _snack.radiobutton(text, group.w, isOn)
 
292
+        else:
 
293
+            self.w = _snack.radiobutton(text, None, isOn)
 
294
 
 
295
 class Listbox(Widget):
 
296
+    """Listbox class.
 
297
 
 
298
+    methods:
 
299
+
 
300
+     - Listbox(self,height, scroll = 0l returnExit = 0, width = 0, showCursor = 0)
 
301
+     - insert(self, text, item, before) : insert element; before = key to item to insert before, or None.
 
302
+     - delete(self, item)               : delete item from list.
 
303
+     - replace(self, text,item)         : Replace a given item's text
 
304
+     - current(self)                    : returns currently selected item
 
305
+     - setCurrent(self,i tem)           : select current.
 
306
+     - clear(self)                      : clear listbox
 
307
+    """
 
308
+    
 
309
     def append(self, text, item):
 
310
-       key = self.w.listboxAddItem(text)
 
311
-       self.key2item[key] = item
 
312
-       self.item2key[item] = key
 
313
+        key = self.w.listboxAddItem(text)
 
314
+        self.key2item[key] = item
 
315
+        self.item2key[item] = key
 
316
 
 
317
     def insert(self, text, item, before):
 
318
-       if (not before):
 
319
-           key = self.w.listboxInsertItem(text, 0)
 
320
-       else:
 
321
-           key = self.w.listboxInsertItem(text, self.item2key[before])
 
322
-       self.key2item[key] = item
 
323
-       self.item2key[item] = key
 
324
+        if (not before):
 
325
+            key = self.w.listboxInsertItem(text, 0)
 
326
+        else:
 
327
+            key = self.w.listboxInsertItem(text, self.item2key[before])
 
328
+        self.key2item[key] = item
 
329
+        self.item2key[item] = key
 
330
 
 
331
     def delete(self, item):
 
332
-       self.w.listboxDeleteItem(self.item2key[item])
 
333
-       del self.key2item[self.item2key[item]]
 
334
-       del self.item2key[item]
 
335
+        self.w.listboxDeleteItem(self.item2key[item])
 
336
+        del self.key2item[self.item2key[item]]
 
337
+        del self.item2key[item]
 
338
 
 
339
     def replace(self, text, item):
 
340
-       key = self.w.listboxInsertItem(text, self.item2key[item])
 
341
-       self.w.listboxDeleteItem(self.item2key[item])
 
342
-       del self.key2item[self.item2key[item]]
 
343
-       self.item2key[item] = key
 
344
-       self.key2item[key] = item
 
345
+        key = self.w.listboxInsertItem(text, self.item2key[item])
 
346
+        self.w.listboxDeleteItem(self.item2key[item])
 
347
+        del self.key2item[self.item2key[item]]
 
348
+        self.item2key[item] = key
 
349
+        self.key2item[key] = item
 
350
 
 
351
     def current(self):
 
352
-       return self.key2item[self.w.listboxGetCurrent()]
 
353
+        return self.key2item[self.w.listboxGetCurrent()]
 
354
 
 
355
     def setCurrent(self, item):
 
356
-       self.w.listboxSetCurrent(self.item2key[item])
 
357
+        self.w.listboxSetCurrent(self.item2key[item])
 
358
 
 
359
     def clear(self):
 
360
         self.key2item = {}
 
361
@@ -105,59 +190,91 @@
 
362
         self.w.listboxClear()
 
363
 
 
364
     def __init__(self, height, scroll = 0, returnExit = 0, width = 0, showCursor = 0):
 
365
-       self.w = _snack.listbox(height, scroll, returnExit, showCursor)
 
366
-       self.key2item = {}
 
367
-       self.item2key = {}
 
368
-       if (width):
 
369
-           self.w.listboxSetWidth(width)
 
370
+        self.w = _snack.listbox(height, scroll, returnExit, showCursor)
 
371
+        self.key2item = {}
 
372
+        self.item2key = {}
 
373
+        if (width):
 
374
+            self.w.listboxSetWidth(width)
 
375
 
 
376
 class Textbox(Widget):
 
377
+    """Textbox, container for text.
 
378
 
 
379
+    methods:
 
380
+
 
381
+     - Textbox(self, width, height, scroll = 0, wrap = 0): scroll, wrap are flags
 
382
+                                   include scroll bars, or text wrap.
 
383
+     - setText(text) : set text.
 
384
+    """
 
385
+    
 
386
     def setText(self, text):
 
387
-       self.w.textboxText(text)
 
388
+        self.w.textboxText(text)
 
389
 
 
390
     def __init__(self, width, height, text, scroll = 0, wrap = 0):
 
391
-       self.w = _snack.textbox(width, height, text, scroll, wrap)
 
392
+        self.w = _snack.textbox(width, height, text, scroll, wrap)
 
393
 
 
394
 class TextboxReflowed(Textbox):
 
395
 
 
396
     def __init__(self, width, text, flexDown = 5, flexUp = 10, maxHeight = -1):
 
397
-       (newtext, width, height) = reflow(text, width, flexDown, flexUp)
 
398
+        (newtext, width, height) = reflow(text, width, flexDown, flexUp)
 
399
         if maxHeight != -1 and height > maxHeight:
 
400
             Textbox.__init__(self, width, maxHeight, newtext, 1)
 
401
         else:
 
402
             Textbox.__init__(self, width, height, newtext, 0)
 
403
 
 
404
 class Label(Widget):
 
405
+    """A Label (simple text).
 
406
 
 
407
+    methods:
 
408
+
 
409
+     - Label(self,text)   : create label
 
410
+     - setText(self,text) : change text.
 
411
+    """
 
412
     def setText(self, text):
 
413
-       self.w.labelText(text)
 
414
+        self.w.labelText(text)
 
415
 
 
416
     def __init__(self, text):
 
417
-       self.w = _snack.label(text)
 
418
+        self.w = _snack.label(text)
 
419
 
 
420
 class Scale(Widget):
 
421
+    """A Scale (progress bar).
 
422
+
 
423
+    methods:
 
424
 
 
425
+     - Scale(self,width, total) : create scale; width: size on screen, fullamount: integer.
 
426
+     - set(self,amount)         : set amount to integer.
 
427
+    """
 
428
     def set(self, amount):
 
429
-       self.w.scaleSet(amount)
 
430
+        self.w.scaleSet(amount)
 
431
 
 
432
     def __init__(self, width, total):
 
433
-       self.w = _snack.scale(width, total)
 
434
+        self.w = _snack.scale(width, total)
 
435
 
 
436
 class Entry(Widget):
 
437
+    """Entry widget.
 
438
 
 
439
+    methods:
 
440
+
 
441
+     - Entry(self, width, text = "", hidden = 0, password = 0, scroll = 1, returnExit = 0)
 
442
+          constructor. hidden doesn't show text, password stars it out,
 
443
+          scroll includes scroll bars;
 
444
+          if returnExit is set, return from Form when exiting this element, else
 
445
+           proceed to next entry widget.
 
446
+     - value(self): return value.
 
447
+     - set(text) : set the text
 
448
+     - setFlags (flag, sense) : flags can be FLAG_DISABLED, FLAGS_SET, FLAGS_RESET, FLAGS_TOGGLE
 
449
+    """
 
450
     def value(self):
 
451
-       return self.w.entryValue
 
452
+        return self.w.entryValue
 
453
 
 
454
     def set(self, text):
 
455
-       return self.w.entrySetValue(text)
 
456
+        return self.w.entrySetValue(text)
 
457
 
 
458
     def setFlags (self, flag, sense):
 
459
         return self.w.entrySetFlags(flag, sense)
 
460
 
 
461
     def __init__(self, width, text = "", hidden = 0, password = 0, scroll = 1, 
 
462
-                returnExit = 0):
 
463
-       self.w = _snack.entry(width, text, hidden, password, scroll, returnExit)
 
464
+         returnExit = 0):
 
465
+        self.w = _snack.entry(width, text, hidden, password, scroll, returnExit)
 
466
 
 
467
 
 
468
 # Form uses hotkeys
 
469
@@ -171,44 +288,56 @@
 
470
     hotkeys[hotkeys[n]] = n
 
471
 
 
472
 class Form:
 
473
+    """ Base Form class, from which Grid, etc. inherit
 
474
+
 
475
+    methods:
 
476
 
 
477
+     - Form(self, helpArg = None) : constructor. 
 
478
+     - addHotKey(self, keyname) : keynames of form "F1" through "F12", "ESC"
 
479
+     - add(self, widget) : Add a widget
 
480
+     - run(self): run a  form, expecting input
 
481
+     - draw(self): draw form.
 
482
+     - setTimer(self, timer) : add a timer
 
483
+     - watchFile(self, file, flags) : watch a named file
 
484
+     - setCurrent (self, co): Set a given widget as the current focus
 
485
+    """
 
486
     def addHotKey(self, keyname):
 
487
-       self.w.addhotkey(hotkeys[keyname])
 
488
+        self.w.addhotkey(hotkeys[keyname])
 
489
 
 
490
     def add(self, widget):
 
491
-       if widget.__dict__.has_key('hotkeys'):
 
492
-           for key in widget.hotkeys.keys():
 
493
-               self.addHotKey(key)
 
494
-
 
495
-       if widget.__dict__.has_key('gridmembers'):
 
496
-           for w in widget.gridmembers:
 
497
-               self.add(w)
 
498
-       elif widget.__dict__.has_key('w'):
 
499
-           self.trans[widget.w.key] = widget
 
500
-           return self.w.add(widget.w)
 
501
-       return None
 
502
+        if widget.__dict__.has_key('hotkeys'):
 
503
+            for key in widget.hotkeys.keys():
 
504
+                self.addHotKey(key)
 
505
+
 
506
+        if widget.__dict__.has_key('gridmembers'):
 
507
+            for w in widget.gridmembers:
 
508
+                self.add(w)
 
509
+        elif widget.__dict__.has_key('w'):
 
510
+            self.trans[widget.w.key] = widget
 
511
+            return self.w.add(widget.w)
 
512
+        return None
 
513
 
 
514
     def run(self):
 
515
-       (what, which) = self.w.run()
 
516
-       if (what == _snack.FORM_EXIT_WIDGET):
 
517
-           return self.trans[which]
 
518
-       elif (what == _snack.FORM_EXIT_TIMER):
 
519
-           return "TIMER"
 
520
-       elif (what == _snack.FORM_EXIT_FDREADY):
 
521
-           return self.filemap[which]
 
522
+        (what, which) = self.w.run()
 
523
+        if (what == _snack.FORM_EXIT_WIDGET):
 
524
+            return self.trans[which]
 
525
+        elif (what == _snack.FORM_EXIT_TIMER):
 
526
+            return "TIMER"
 
527
+        elif (what == _snack.FORM_EXIT_FDREADY):
 
528
+            return self.filemap[which]
 
529
 
 
530
-       return hotkeys[which]
 
531
+        return hotkeys[which]
 
532
 
 
533
     def draw(self):
 
534
-       self.w.draw()
 
535
-       return None
 
536
+        self.w.draw()
 
537
+        return None
 
538
 
 
539
     def __init__(self, helpArg = None):
 
540
-       self.trans = {}
 
541
-       self.filemap = {}
 
542
-       self.w = _snack.form(helpArg)
 
543
-       # we do the reference count for the helpArg in python! gross
 
544
-       self.helpArg = helpArg
 
545
+        self.trans = {}
 
546
+        self.filemap = {}
 
547
+        self.w = _snack.form(helpArg)
 
548
+        # we do the reference count for the helpArg in python! gross
 
549
+        self.helpArg = helpArg
 
550
 
 
551
     def setCurrent (self, co):
 
552
         self.w.setcurrent (co.w)
 
553
@@ -217,67 +346,90 @@
 
554
         self.w.settimer (timer)
 
555
 
 
556
     def watchFile (self, file, flags):
 
557
-       self.filemap[file.fileno()] = file
 
558
-       self.w.watchfd (file.fileno(), flags)
 
559
+        self.filemap[file.fileno()] = file
 
560
+        self.w.watchfd (file.fileno(), flags)
 
561
 
 
562
 class Grid:
 
563
+    """Grid class.
 
564
 
 
565
+    methods:
 
566
+
 
567
+     - place(self,x,y): Return what is placed at (x,y)
 
568
+     - setField(self, what, col, row, padding = (0, 0, 0, 0),
 
569
+                anchorLeft = 0, anchorTop = 0, anchorRight = 0,
 
570
+                anchorBottom = 0, growx = 0, growy = 0):
 
571
+                used to add widget 'what' to grid.
 
572
+     - Grid(self, *args): eg. g = Grid(2,3) for 2x3 grid
 
573
+    """
 
574
     def place(self, x, y):
 
575
-       return self.g.place(x, y)
 
576
+        return self.g.place(x, y)
 
577
 
 
578
     def setField(self, what, col, row, padding = (0, 0, 0, 0),
 
579
-                anchorLeft = 0, anchorTop = 0, anchorRight = 0,
 
580
-                anchorBottom = 0, growx = 0, growy = 0):
 
581
-       self.gridmembers.append(what)
 
582
-       anchorFlags = 0
 
583
-       if (anchorLeft):
 
584
-           anchorFlags = _snack.ANCHOR_LEFT
 
585
-       elif (anchorRight):
 
586
-           anchorFlags = _snack.ANCHOR_RIGHT
 
587
-
 
588
-       if (anchorTop):
 
589
-           anchorFlags = anchorFlags | _snack.ANCHOR_TOP
 
590
-       elif (anchorBottom):
 
591
-           anchorFlags = anchorFlags | _snack.ANCHOR_BOTTOM
 
592
-
 
593
-       gridFlags = 0
 
594
-       if (growx):
 
595
-           gridFlags = _snack.GRID_GROWX
 
596
-       if (growy):
 
597
-           gridFlags = gridFlags | _snack.GRID_GROWY
 
598
-
 
599
-       if (what.__dict__.has_key('g')):
 
600
-           return self.g.setfield(col, row, what.g, padding, anchorFlags,
 
601
-                                  gridFlags)
 
602
-       else:
 
603
-           return self.g.setfield(col, row, what.w, padding, anchorFlags)
 
604
-
 
605
+         anchorLeft = 0, anchorTop = 0, anchorRight = 0,
 
606
+         anchorBottom = 0, growx = 0, growy = 0):
 
607
+        self.gridmembers.append(what)
 
608
+        anchorFlags = 0
 
609
+        if (anchorLeft):
 
610
+            anchorFlags = _snack.ANCHOR_LEFT
 
611
+        elif (anchorRight):
 
612
+            anchorFlags = _snack.ANCHOR_RIGHT
 
613
+
 
614
+        if (anchorTop):
 
615
+            anchorFlags = anchorFlags | _snack.ANCHOR_TOP
 
616
+        elif (anchorBottom):
 
617
+            anchorFlags = anchorFlags | _snack.ANCHOR_BOTTOM
 
618
+
 
619
+        gridFlags = 0
 
620
+        if (growx):
 
621
+            gridFlags = _snack.GRID_GROWX
 
622
+        if (growy):
 
623
+            gridFlags = gridFlags | _snack.GRID_GROWY
 
624
+
 
625
+        if (what.__dict__.has_key('g')):
 
626
+            return self.g.setfield(col, row, what.g, padding, anchorFlags,
 
627
+                       gridFlags)
 
628
+        else:
 
629
+            return self.g.setfield(col, row, what.w, padding, anchorFlags)
 
630
+    
 
631
     def __init__(self, *args):
 
632
-       self.g = apply(_snack.grid, args)
 
633
-       self.gridmembers = []
 
634
+        self.g = apply(_snack.grid, args)
 
635
+        self.gridmembers = []
 
636
 
 
637
 class SnackScreen:
 
638
+    """A Screen;
 
639
 
 
640
+    methods:
 
641
+
 
642
+    - Screen(self) : constructor
 
643
+    - finish(self)
 
644
+    - resume(self)
 
645
+    - suspend(self)
 
646
+    - doHelpCallback(self,arg) call callback with arg
 
647
+    - helpCallback(self,cb): Set help callback
 
648
+    - suspendcallback(self,cb, data=None) : set callback. data=data to pass to cb.
 
649
+    - openWindow(self,left, top, width, height, title): Open a window.
 
650
+    - pushHelpLine(self,text): put help line on screen. Returns current help line if text=None
 
651
+    """
 
652
     def __init__(self):
 
653
-       _snack.init()
 
654
-       (self.width, self.height) = _snack.size()
 
655
-       self.pushHelpLine(None)
 
656
+        _snack.init()
 
657
+        (self.width, self.height) = _snack.size()
 
658
+        self.pushHelpLine(None)
 
659
 
 
660
     def finish(self):
 
661
-       return _snack.finish()
 
662
+        return _snack.finish()
 
663
 
 
664
     def resume(self):
 
665
-       _snack.resume()
 
666
+        _snack.resume()
 
667
 
 
668
     def suspend(self):
 
669
-       _snack.suspend()
 
670
+        _snack.suspend()
 
671
 
 
672
     def doHelpCallback(self, arg):
 
673
-       self.helpCb(self, arg)
 
674
-
 
675
+        self.helpCb(self, arg)
 
676
+    
 
677
     def helpCallback(self, cb):
 
678
-       self.helpCb = cb
 
679
-       return _snack.helpcallback(self.doHelpCallback)
 
680
+       self.helpCb = cb
 
681
+        return _snack.helpcallback(self.doHelpCallback)
 
682
 
 
683
     def suspendCallback(self, cb, data = None):
 
684
         if data:
 
685
@@ -285,228 +437,289 @@
 
686
         return _snack.suspendcallback(cb)
 
687
 
 
688
     def openWindow(self, left, top, width, height, title):
 
689
-       return _snack.openwindow(left, top, width, height, title)
 
690
+        return _snack.openwindow(left, top, width, height, title)
 
691
 
 
692
     def pushHelpLine(self, text):
 
693
-       if (not text):
 
694
-           return _snack.pushhelpline("*default*")
 
695
-       else:
 
696
-           return _snack.pushhelpline(text)
 
697
+        if (not text):
 
698
+            return _snack.pushhelpline("*default*")
 
699
+        else:
 
700
+            return _snack.pushhelpline(text)
 
701
 
 
702
     def popHelpLine(self):
 
703
-       return _snack.pophelpline()
 
704
+        return _snack.pophelpline()
 
705
 
 
706
     def drawRootText(self, left, top, text):
 
707
-       return _snack.drawroottext(left, top, text)
 
708
+        return _snack.drawroottext(left, top, text)
 
709
 
 
710
     def centeredWindow(self, width, height, title):
 
711
-       return _snack.centeredwindow(width, height, title)
 
712
+        return _snack.centeredwindow(width, height, title)
 
713
 
 
714
     def gridWrappedWindow(self, grid, title, x = None, y = None):
 
715
-       if x and y:
 
716
-           return _snack.gridwrappedwindow(grid.g, title, x, y)
 
717
+        if x and y:
 
718
+            return _snack.gridwrappedwindow(grid.g, title, x, y)
 
719
 
 
720
-       return _snack.gridwrappedwindow(grid.g, title)
 
721
+        return _snack.gridwrappedwindow(grid.g, title)
 
722
 
 
723
     def popWindow(self):
 
724
-       return _snack.popwindow()
 
725
+        return _snack.popwindow()
 
726
 
 
727
     def refresh(self):
 
728
-       return _snack.refresh()
 
729
+        return _snack.refresh()
 
730
 
 
731
-# returns a tuple of the wrapped text, the actual width, and the actual height
 
732
 def reflow(text, width, flexDown = 5, flexUp = 5):
 
733
+    """ returns a tuple of the wrapped text, the actual width, and the actual height
 
734
+    """
 
735
     return _snack.reflow(text, width, flexDown, flexUp)
 
736
 
 
737
 # combo widgets
 
738
 
 
739
 class RadioGroup(Widget):
 
740
+    """ Combo widget: Group of Radio buttons
 
741
 
 
742
+    methods:
 
743
+
 
744
+     - RadioGroup(self): constructor.
 
745
+     - add(self,title, value, default = None): add a button. Returns button.
 
746
+     - getSelection(self) : returns value of selected button | None    
 
747
+    """
 
748
     def __init__(self):
 
749
-       self.prev = None
 
750
-       self.buttonlist = []
 
751
+        self.prev = None
 
752
+        self.buttonlist = []
 
753
 
 
754
     def add(self, title, value, default = None):
 
755
-       if not self.prev and default == None:
 
756
-           # If the first element is not explicitly set to
 
757
-           # not be the default, make it be the default
 
758
-           default = 1
 
759
-       b = SingleRadioButton(title, self.prev, default)
 
760
-       self.prev = b
 
761
-       self.buttonlist.append((b, value))
 
762
-       return b
 
763
+        if not self.prev and default == None:
 
764
+            # If the first element is not explicitly set to
 
765
+            # not be the default, make it be the default
 
766
+            default = 1
 
767
+        b = SingleRadioButton(title, self.prev, default)
 
768
+        self.prev = b
 
769
+        self.buttonlist.append((b, value))
 
770
+        return b
 
771
 
 
772
     def getSelection(self):
 
773
-       for (b, value) in self.buttonlist:
 
774
-           if b.selected(): return value
 
775
-       return None
 
776
+        for (b, value) in self.buttonlist:
 
777
+            if b.selected(): return value
 
778
+        return None
 
779
 
 
780
 
 
781
 class RadioBar(Grid):
 
782
+    """ Bar of Radio buttons, based on Grid.
 
783
+
 
784
+    methods:
 
785
+
 
786
+    - RadioBar(self, screen, buttonlist) : constructor.
 
787
+    - getSelection(self): return value of selected button 
 
788
+    """
 
789
 
 
790
     def __init__(self, screen, buttonlist):
 
791
-       self.list = []
 
792
-       self.item = 0
 
793
-       self.group = RadioGroup()
 
794
-       Grid.__init__(self, 1, len(buttonlist))
 
795
-       for (title, value, default) in buttonlist:
 
796
-           b = self.group.add(title, value, default)
 
797
-           self.list.append((b, value))
 
798
-           self.setField(b, 0, self.item, anchorLeft = 1)
 
799
-           self.item = self.item + 1
 
800
+        self.list = []
 
801
+        self.item = 0
 
802
+        self.group = RadioGroup()
 
803
+        Grid.__init__(self, 1, len(buttonlist))
 
804
+        for (title, value, default) in buttonlist:
 
805
+            b = self.group.add(title, value, default)
 
806
+            self.list.append((b, value))
 
807
+            self.setField(b, 0, self.item, anchorLeft = 1)
 
808
+            self.item = self.item + 1
 
809
 
 
810
     def getSelection(self):
 
811
-       return self.group.getSelection()
 
812
-       
 
813
+        return self.group.getSelection()
 
814
+    
 
815
 
 
816
 # you normally want to pack a ButtonBar with growx = 1
 
817
 
 
818
 class ButtonBar(Grid):
 
819
+    """ Bar of buttons, based on grid.
 
820
 
 
821
+    methods:
 
822
+
 
823
+     - ButtonBar(screen, buttonlist,buttonlist, compact = 0):
 
824
+     - buttonPressed(self, result):  Takes the widget returned by Form.run and looks to see
 
825
+                     if it was one of the widgets in the ButtonBar.
 
826
+    """
 
827
     def __init__(self, screen, buttonlist, compact = 0):
 
828
-       self.list = []
 
829
-       self.hotkeys = {}
 
830
-       self.item = 0
 
831
-       Grid.__init__(self, len(buttonlist), 1)
 
832
-       for blist in buttonlist:
 
833
-           if (type(blist) == types.StringType):
 
834
-               title = blist
 
835
-               value = string.lower(blist)
 
836
-           elif len(blist) == 2:
 
837
-               (title, value) = blist
 
838
-           else:
 
839
-               (title, value, hotkey) = blist
 
840
-               self.hotkeys[hotkey] = value
 
841
+        self.list = []
 
842
+        self.hotkeys = {}
 
843
+        self.item = 0
 
844
+        Grid.__init__(self, len(buttonlist), 1)
 
845
+        for blist in buttonlist:
 
846
+            if (type(blist) == types.StringType):
 
847
+                title = blist
 
848
+                value = string.lower(blist)
 
849
+            elif len(blist) == 2:
 
850
+                (title, value) = blist
 
851
+            else:
 
852
+                (title, value, hotkey) = blist
 
853
+                self.hotkeys[hotkey] = value
 
854
 
 
855
             if compact:
 
856
                 b = CompactButton(title)
 
857
             else:
 
858
                 b = Button(title)
 
859
-           self.list.append((b, value))
 
860
-           self.setField(b, self.item, 0, (1, 0, 1, 0))
 
861
-           self.item = self.item + 1
 
862
-
 
863
-    def buttonPressed(self, result):
 
864
-       """Takes the widget returned by Form.run and looks to see
 
865
-       if it was one of the widgets in the ButtonBar."""
 
866
-
 
867
-       if self.hotkeys.has_key(result):
 
868
-           return self.hotkeys[result]
 
869
-
 
870
-       for (button, value) in self.list:
 
871
-           if result == button:
 
872
-               return value
 
873
-       return None
 
874
+            self.list.append((b, value))
 
875
+            self.setField(b, self.item, 0, (1, 0, 1, 0))
 
876
+            self.item = self.item + 1
 
877
+
 
878
+    def buttonPressed(self, result):    
 
879
+        if self.hotkeys.has_key(result):
 
880
+            return self.hotkeys[result]
 
881
+
 
882
+        for (button, value) in self.list:
 
883
+            if result == button:
 
884
+               return value
 
885
+        return None
 
886
 
 
887
 
 
888
 class GridFormHelp(Grid):
 
889
+    """ Subclass of Grid, for the help form text.
 
890
+
 
891
+    methods:
 
892
 
 
893
+     - GridFormHelp(self, screen, title, help, *args) :
 
894
+     - add (self, widget, col, row, padding = (0, 0, 0, 0),
 
895
+            anchorLeft = 0, anchorTop = 0, anchorRight = 0,
 
896
+            anchorBottom = 0, growx = 0, growy = 0):
 
897
+     - runOnce(self, x = None, y = None):  pop up the help window
 
898
+     - addHotKey(self, keyname):
 
899
+     - setTimer(self, keyname):
 
900
+     - create(self, x = None, y = None):
 
901
+     - run(self, x = None, y = None):
 
902
+     - draw(self):
 
903
+     - runPopup(self):
 
904
+     - setCurrent (self, co):
 
905
+    """
 
906
     def __init__(self, screen, title, help, *args):
 
907
-       self.screen = screen
 
908
-       self.title = title
 
909
-       self.form = Form(help)
 
910
-       self.childList = []
 
911
-       self.form_created = 0
 
912
-       args = list(args)
 
913
-       args[:0] = [self]
 
914
-       apply(Grid.__init__, tuple(args))
 
915
+        self.screen = screen
 
916
+        self.title = title
 
917
+        self.form = Form(help)
 
918
+        self.childList = []
 
919
+        self.form_created = 0
 
920
+        args = list(args)
 
921
+        args[:0] = [self]
 
922
+        apply(Grid.__init__, tuple(args))
 
923
 
 
924
     def add(self, widget, col, row, padding = (0, 0, 0, 0),
 
925
             anchorLeft = 0, anchorTop = 0, anchorRight = 0,
 
926
             anchorBottom = 0, growx = 0, growy = 0):
 
927
-       self.setField(widget, col, row, padding, anchorLeft,
 
928
-                     anchorTop, anchorRight, anchorBottom,
 
929
-                     growx, growy);
 
930
-       self.childList.append(widget)
 
931
+        self.setField(widget, col, row, padding, anchorLeft,
 
932
+                      anchorTop, anchorRight, anchorBottom,
 
933
+                      growx, growy);
 
934
+        self.childList.append(widget)
 
935
 
 
936
     def runOnce(self, x = None, y = None):
 
937
-       result = self.run(x, y)
 
938
-       self.screen.popWindow()
 
939
-       return result
 
940
+        result = self.run(x, y)
 
941
+        self.screen.popWindow()
 
942
+        return result
 
943
 
 
944
     def addHotKey(self, keyname):
 
945
-       self.form.addHotKey(keyname)
 
946
+        self.form.addHotKey(keyname)
 
947
 
 
948
     def setTimer(self, keyname):
 
949
-       self.form.setTimer(keyname)
 
950
+        self.form.setTimer(keyname)
 
951
 
 
952
     def create(self, x = None, y = None):
 
953
-       if not self.form_created:
 
954
-           self.place(1,1)
 
955
-           for child in self.childList:
 
956
-               self.form.add(child)
 
957
-           self.screen.gridWrappedWindow(self, self.title, x, y)
 
958
-           self.form_created = 1
 
959
+        if not self.form_created:
 
960
+            self.place(1,1)
 
961
+            for child in self.childList:
 
962
+                self.form.add(child)
 
963
+            self.screen.gridWrappedWindow(self, self.title, x, y)
 
964
+            self.form_created = 1
 
965
 
 
966
     def run(self, x = None, y = None):
 
967
-       self.create(x, y)
 
968
-       return self.form.run()
 
969
+        self.create(x, y)
 
970
+        return self.form.run()
 
971
 
 
972
     def draw(self):
 
973
-       self.create()
 
974
-       return self.form.draw()
 
975
-       
 
976
+        self.create()
 
977
+        return self.form.draw()
 
978
+    
 
979
     def runPopup(self):
 
980
-       self.create()
 
981
-       self.screen.gridWrappedWindow(self, self.title)
 
982
-       result = self.form.run()
 
983
-       self.screen.popWindow()
 
984
-       return result
 
985
+        self.create()
 
986
+        self.screen.gridWrappedWindow(self, self.title)
 
987
+        result = self.form.run()
 
988
+        self.screen.popWindow()
 
989
+        return result
 
990
 
 
991
     def setCurrent (self, co):
 
992
         self.form.setCurrent (co)
 
993
 
 
994
 class GridForm(GridFormHelp):
 
995
+    """ GridForm class (extends GridFormHelp):
 
996
+
 
997
+    methods:
 
998
 
 
999
+     - GridForm(self, screen, title, *args):
 
1000
+    """
 
1001
     def __init__(self, screen, title, *args):
 
1002
-       myargs = (self, screen, title, None) + args
 
1003
-       apply(GridFormHelp.__init__, myargs)
 
1004
+        myargs = (self, screen, title, None) + args
 
1005
+        apply(GridFormHelp.__init__, myargs)
 
1006
 
 
1007
 class CheckboxTree(Widget):
 
1008
-    def append(self, text, item = None, selected = 0):
 
1009
-       self.addItem(text, (snackArgs['append'], ), item, selected)
 
1010
+    """ CheckboxTree combo widget,
 
1011
+
 
1012
+    methods:
 
1013
 
 
1014
+     - CheckboxTree(self, height, scroll = 0, width = None, hide_checkbox = 0, unselectable = 0)
 
1015
+                    constructor.
 
1016
+     - append(self, text, item = None, selected = 0):
 
1017
+     - addItem(self, text, path, item = None, selected = 0):
 
1018
+     - getCurrent(self):
 
1019
+     - getSelection(self):
 
1020
+     - setEntry(self, item, text):
 
1021
+     - setCurrent(self, item):
 
1022
+     - setEntryValue(self, item, selected = 1):
 
1023
+     - getEntryValue(self, item):
 
1024
+    """ 
 
1025
+    def append(self, text, item = None, selected = 0):
 
1026
+        self.addItem(text, (snackArgs['append'], ), item, selected)
 
1027
+    
 
1028
     def addItem(self, text, path, item = None, selected = 0):
 
1029
-       if item is None:
 
1030
-           item = text
 
1031
-       key = self.w.checkboxtreeAddItem(text, path, selected)
 
1032
-       self.key2item[key] = item
 
1033
-       self.item2key[item] = key
 
1034
+        if item is None:
 
1035
+            item = text
 
1036
+        key = self.w.checkboxtreeAddItem(text, path, selected)
 
1037
+        self.key2item[key] = item
 
1038
+        self.item2key[item] = key
 
1039
 
 
1040
     def getCurrent(self):
 
1041
-       curr = self.w.checkboxtreeGetCurrent()
 
1042
-       return self.key2item[curr]
 
1043
+        curr = self.w.checkboxtreeGetCurrent()
 
1044
+        return self.key2item[curr]
 
1045
 
 
1046
     def __init__(self, height, scroll = 0, width = None, hide_checkbox = 0, unselectable = 0):
 
1047
-       self.w = _snack.checkboxtree(height, scroll, hide_checkbox, unselectable)
 
1048
-       self.key2item = {}
 
1049
-       self.item2key = {}
 
1050
-       if (width):
 
1051
-           self.w.checkboxtreeSetWidth(width)
 
1052
+        self.w = _snack.checkboxtree(height, scroll, hide_checkbox, unselectable)
 
1053
+        self.key2item = {}
 
1054
+        self.item2key = {}
 
1055
+        if (width):
 
1056
+            self.w.checkboxtreeSetWidth(width)
 
1057
 
 
1058
     def getSelection(self):
 
1059
         selection = []
 
1060
         list = self.w.checkboxtreeGetSelection()
 
1061
         for key in list:
 
1062
             selection.append(self.key2item[key])
 
1063
-       return selection
 
1064
+        return selection
 
1065
 
 
1066
     def setEntry(self, item, text):
 
1067
-       self.w.checkboxtreeSetEntry(self.item2key[item], text)
 
1068
+        self.w.checkboxtreeSetEntry(self.item2key[item], text)
 
1069
 
 
1070
     def setCurrent(self, item):
 
1071
-       self.w.checkboxtreeSetCurrent(self.item2key[item])
 
1072
+        self.w.checkboxtreeSetCurrent(self.item2key[item])
 
1073
 
 
1074
     def setEntryValue(self, item, selected = 1):
 
1075
-       self.w.checkboxtreeSetEntryValue(self.item2key[item], selected)
 
1076
+        self.w.checkboxtreeSetEntryValue(self.item2key[item], selected)
 
1077
 
 
1078
     def getEntryValue(self, item):
 
1079
-       return self.w.checkboxtreeGetEntryValue(self.item2key[item])
 
1080
+        return self.w.checkboxtreeGetEntryValue(self.item2key[item])
 
1081
 
 
1082
 def ListboxChoiceWindow(screen, title, text, items, 
 
1083
-                       buttons = ('Ok', 'Cancel'), 
 
1084
-                       width = 40, scroll = 0, height = -1, default = None,
 
1085
-                       help = None):
 
1086
+            buttons = ('Ok', 'Cancel'), 
 
1087
+            width = 40, scroll = 0, height = -1, default = None,
 
1088
+            help = None):
 
1089
+    """
 
1090
+    - ListboxChoiceWindow(screen, title, text, items, 
 
1091
+            buttons = ('Ok', 'Cancel'), 
 
1092
+            width = 40, scroll = 0, height = -1, default = None,
 
1093
+            help = None):
 
1094
+    """
 
1095
     if (height == -1): height = len(items)
 
1096
 
 
1097
     bb = ButtonBar(screen, buttons)
 
1098
@@ -514,22 +727,22 @@
 
1099
     l = Listbox(height, scroll = scroll, returnExit = 1)
 
1100
     count = 0
 
1101
     for item in items:
 
1102
-       if (type(item) == types.TupleType):
 
1103
-           (text, key) = item
 
1104
-       else:
 
1105
-           text = item
 
1106
-           key = count
 
1107
-
 
1108
-       if (default == count):
 
1109
-           default = key
 
1110
-       elif (default == item):
 
1111
-           default = key
 
1112
+        if (type(item) == types.TupleType):
 
1113
+            (text, key) = item
 
1114
+        else:
 
1115
+            text = item
 
1116
+            key = count
 
1117
 
 
1118
-       l.append(text, key)
 
1119
-       count = count + 1
 
1120
+        if (default == count):
 
1121
+            default = key
 
1122
+        elif (default == item):
 
1123
+            default = key
 
1124
+
 
1125
+        l.append(text, key)
 
1126
+        count = count + 1
 
1127
 
 
1128
     if (default != None):
 
1129
-       l.setCurrent (default)
 
1130
+        l.setCurrent (default)
 
1131
 
 
1132
     g = GridFormHelp(screen, title, help, 1, 3)
 
1133
     g.add(t, 0, 0)
 
1134
@@ -541,8 +754,13 @@
 
1135
     return (bb.buttonPressed(rc), l.current())
 
1136
 
 
1137
 def ButtonChoiceWindow(screen, title, text, 
 
1138
-                      buttons = [ 'Ok', 'Cancel' ], 
 
1139
-                      width = 40, x = None, y = None, help = None):
 
1140
+               buttons = [ 'Ok', 'Cancel' ], 
 
1141
+               width = 40, x = None, y = None, help = None):
 
1142
+    """
 
1143
+     - ButtonChoiceWindow(screen, title, text, 
 
1144
+               buttons = [ 'Ok', 'Cancel' ], 
 
1145
+               width = 40, x = None, y = None, help = None):
 
1146
+    """
 
1147
     bb = ButtonBar(screen, buttons)
 
1148
     t = TextboxReflowed(width, text, maxHeight = screen.height - 12)
 
1149
 
 
1150
@@ -552,28 +770,32 @@
 
1151
     return bb.buttonPressed(g.runOnce(x, y))
 
1152
 
 
1153
 def EntryWindow(screen, title, text, prompts, allowCancel = 1, width = 40,
 
1154
-               entryWidth = 20, buttons = [ 'Ok', 'Cancel' ], help = None):
 
1155
+        entryWidth = 20, buttons = [ 'Ok', 'Cancel' ], help = None):
 
1156
+    """
 
1157
+    EntryWindow(screen, title, text, prompts, allowCancel = 1, width = 40,
 
1158
+        entryWidth = 20, buttons = [ 'Ok', 'Cancel' ], help = None):
 
1159
+    """
 
1160
     bb = ButtonBar(screen, buttons);
 
1161
     t = TextboxReflowed(width, text)
 
1162
 
 
1163
     count = 0
 
1164
     for n in prompts:
 
1165
-       count = count + 1
 
1166
+        count = count + 1
 
1167
 
 
1168
     sg = Grid(2, count)
 
1169
 
 
1170
     count = 0
 
1171
     entryList = []
 
1172
     for n in prompts:
 
1173
-       if (type(n) == types.TupleType):
 
1174
-           (n, e) = n
 
1175
-       else:
 
1176
-           e = Entry(entryWidth)
 
1177
-
 
1178
-       sg.setField(Label(n), 0, count, padding = (0, 0, 1, 0), anchorLeft = 1)
 
1179
-       sg.setField(e, 1, count, anchorLeft = 1)
 
1180
-       count = count + 1
 
1181
-       entryList.append(e)
 
1182
+        if (type(n) == types.TupleType):
 
1183
+            (n, e) = n
 
1184
+        else:
 
1185
+            e = Entry(entryWidth)
 
1186
+
 
1187
+        sg.setField(Label(n), 0, count, padding = (0, 0, 1, 0), anchorLeft = 1)
 
1188
+        sg.setField(e, 1, count, anchorLeft = 1)
 
1189
+        count = count + 1
 
1190
+        entryList.append(e)
 
1191
 
 
1192
     g = GridFormHelp(screen, title, help, 1, 3)
 
1193
 
 
1194
@@ -586,106 +808,122 @@
 
1195
     entryValues = []
 
1196
     count = 0
 
1197
     for n in prompts:
 
1198
-       entryValues.append(entryList[count].value())
 
1199
-       count = count + 1
 
1200
+        entryValues.append(entryList[count].value())
 
1201
+        count = count + 1
 
1202
 
 
1203
     return (bb.buttonPressed(result), tuple(entryValues))
 
1204
 
 
1205
 class CListbox(Grid):
 
1206
-        def __init__(self, height, cols, col_widths, scroll = 0,
 
1207
-                     returnExit = 0, width = 0, col_pad = 1,
 
1208
-                     col_text_align = None, col_labels = None,
 
1209
-                     col_label_align = None, adjust_width=0):
 
1210
-
 
1211
-               self.cols = cols
 
1212
-               self.col_widths = col_widths[:]
 
1213
-               self.col_pad = col_pad
 
1214
-               self.col_text_align = col_text_align
 
1215
-
 
1216
-               if col_labels != None:          
 
1217
-                       Grid.__init__(self, 1, 2)
 
1218
-                       box_y = 1
 
1219
+    """Clistbox convenience class.
 
1220
+
 
1221
+    methods:
 
1222
 
 
1223
-                       lstr = self.colFormText(col_labels, col_label_align,
 
1224
+     - Clistbox(self, height, cols, cols_widths, scroll = 0)       : constructor
 
1225
+     - colFormText(self, col_text, align = None, adjust_width = 0) : column text.
 
1226
+     - append(self, col_text, item, col_text_align = None)         :
 
1227
+     - insert(self, col_text, item, before, col_text_align = None)
 
1228
+     - delete(self, item)
 
1229
+     - replace(self, col_text, item, col_text_align = None)
 
1230
+     - current(self) : returns current item
 
1231
+     - setCurrent(self, item): sets an item as current
 
1232
+     - clear(self): clear the listbox
 
1233
+     
 
1234
+     Alignments may be LEFT, RIGHT, CENTER, None
 
1235
+    """
 
1236
+    def __init__(self, height, cols, col_widths, scroll = 0,
 
1237
+                 returnExit = 0, width = 0, col_pad = 1,
 
1238
+                 col_text_align = None, col_labels = None,
 
1239
+                 col_label_align = None, adjust_width=0):
 
1240
+
 
1241
+        self.cols = cols
 
1242
+        self.col_widths = col_widths[:]
 
1243
+        self.col_pad = col_pad
 
1244
+        self.col_text_align = col_text_align
 
1245
+
 
1246
+        if col_labels != None:        
 
1247
+            Grid.__init__(self, 1, 2)
 
1248
+            box_y = 1
 
1249
+
 
1250
+            lstr = self.colFormText(col_labels, col_label_align,
 
1251
                                                 adjust_width=adjust_width)
 
1252
-                       self.label = Label(lstr)
 
1253
-                       self.setField(self.label, 0, 0, anchorLeft=1)
 
1254
+            self.label = Label(lstr)
 
1255
+            self.setField(self.label, 0, 0, anchorLeft=1)
 
1256
+
 
1257
+        else:
 
1258
+            Grid.__init__(self, 1, 1)
 
1259
+            box_y = 0
 
1260
+            
 
1261
 
 
1262
-               else:
 
1263
-                       Grid.__init__(self, 1, 1)
 
1264
-                       box_y = 0
 
1265
-                       
 
1266
-
 
1267
-               self.listbox = Listbox(height, scroll, returnExit, width)
 
1268
-               self.setField(self.listbox, 0, box_y, anchorRight=1)
 
1269
-
 
1270
-       def colFormText(self, col_text, align = None, adjust_width=0):
 
1271
-               i = 0
 
1272
-               str = ""
 
1273
-               c_len = len(col_text)
 
1274
-               while (i < self.cols) and (i < c_len):
 
1275
-               
 
1276
-                       cstr = col_text[i]
 
1277
-                        cstrlen = _snack.wstrlen(cstr)
 
1278
-                        if self.col_widths[i] < cstrlen:
 
1279
-                            if adjust_width:
 
1280
-                                self.col_widths[i] = cstrlen
 
1281
-                            else:
 
1282
-                                cstr = cstr[:self.col_widths[i]]
 
1283
+        self.listbox = Listbox(height, scroll, returnExit, width)
 
1284
+        self.setField(self.listbox, 0, box_y, anchorRight=1)
 
1285
 
 
1286
-                       delta = self.col_widths[i] - _snack.wstrlen(cstr)
 
1287
+    def colFormText(self, col_text, align = None, adjust_width=0):
 
1288
+        i = 0
 
1289
+        str = ""
 
1290
+        c_len = len(col_text)
 
1291
+        while (i < self.cols) and (i < c_len):
 
1292
+        
 
1293
+            cstr = col_text[i]
 
1294
+            cstrlen = _snack.wstrlen(cstr)
 
1295
+            if self.col_widths[i] < cstrlen:
 
1296
+                if adjust_width:
 
1297
+                    self.col_widths[i] = cstrlen
 
1298
+                else:
 
1299
+                    cstr = cstr[:self.col_widths[i]]
 
1300
+
 
1301
+            delta = self.col_widths[i] - _snack.wstrlen(cstr)
 
1302
                         
 
1303
-                       if delta > 0:
 
1304
-                               if align == None:
 
1305
-                                    a = LEFT
 
1306
-                                else:
 
1307
-                                    a = align[i]
 
1308
-
 
1309
-                               if a == LEFT:
 
1310
-                                       cstr = cstr + (" " * delta)
 
1311
-                               if a == CENTER:
 
1312
-                                       cstr = (" " * (delta / 2)) + cstr + \
 
1313
-                                               (" " * ((delta + 1) / 2))
 
1314
-                               if a == RIGHT:
 
1315
-                                       cstr = (" " * delta) + cstr
 
1316
-
 
1317
-                       if i != c_len - 1:
 
1318
-                               pstr = (" " * self.col_pad)
 
1319
-                       else:
 
1320
-                               pstr = ""
 
1321
-
 
1322
-                       str = str + cstr + pstr
 
1323
-       
 
1324
-                       i = i + 1
 
1325
-       
 
1326
-               return str
 
1327
-
 
1328
-       def append(self, col_text, item, col_text_align = None):
 
1329
-               if col_text_align == None:
 
1330
-                       col_text_align = self.col_text_align
 
1331
-               text = self.colFormText(col_text, col_text_align)
 
1332
-               self.listbox.append(text, item)
 
1333
-
 
1334
-       def insert(self, col_text, item, before, col_text_align = None):
 
1335
-               if col_text_align == None:
 
1336
-                       col_text_align = self.col_text_align
 
1337
-               text = self.colFormText(col_text, col_text_align)
 
1338
-               self.listbox.insert(text, item, before)
 
1339
-
 
1340
-       def delete(self, item):
 
1341
-               self.listbox.delete(item)
 
1342
-
 
1343
-       def replace(self, col_text, item, col_text_align = None):
 
1344
-               if col_text_align == None:
 
1345
-                       col_text_align = self.col_text_align
 
1346
-               text = self.colFormText(col_text, col_text_align)
 
1347
-               self.listbox.replace(text, item)
 
1348
+            if delta > 0:
 
1349
+                if align == None:
 
1350
+                    a = LEFT
 
1351
+                else:
 
1352
+                    a = align[i]
 
1353
+
 
1354
+                if a == LEFT:
 
1355
+                    cstr = cstr + (" " * delta)
 
1356
+                if a == CENTER:
 
1357
+                    cstr = (" " * (delta / 2)) + cstr + \
 
1358
+                        (" " * ((delta + 1) / 2))
 
1359
+                if a == RIGHT:
 
1360
+                    cstr = (" " * delta) + cstr
 
1361
+
 
1362
+            if i != c_len - 1:
 
1363
+                pstr = (" " * self.col_pad)
 
1364
+            else:
 
1365
+                pstr = ""
 
1366
+
 
1367
+            str = str + cstr + pstr
 
1368
+    
 
1369
+            i = i + 1
 
1370
+    
 
1371
+        return str
 
1372
+
 
1373
+    def append(self, col_text, item, col_text_align = None):
 
1374
+        if col_text_align == None:
 
1375
+            col_text_align = self.col_text_align
 
1376
+        text = self.colFormText(col_text, col_text_align)
 
1377
+        self.listbox.append(text, item)
 
1378
+
 
1379
+    def insert(self, col_text, item, before, col_text_align = None):
 
1380
+        if col_text_align == None:
 
1381
+            col_text_align = self.col_text_align
 
1382
+        text = self.colFormText(col_text, col_text_align)
 
1383
+        self.listbox.insert(text, item, before)
 
1384
+
 
1385
+    def delete(self, item):
 
1386
+        self.listbox.delete(item)
 
1387
+
 
1388
+    def replace(self, col_text, item, col_text_align = None):
 
1389
+        if col_text_align == None:
 
1390
+            col_text_align = self.col_text_align
 
1391
+        text = self.colFormText(col_text, col_text_align)
 
1392
+        self.listbox.replace(text, item)
 
1393
 
 
1394
-       def current(self):
 
1395
-               return self.listbox.current()
 
1396
+    def current(self):
 
1397
+        return self.listbox.current()
 
1398
 
 
1399
-       def setCurrent(self, item):
 
1400
-               self.listbox.setCurrent(item)
 
1401
+    def setCurrent(self, item):
 
1402
+        self.listbox.setCurrent(item)
 
1403
 
 
1404
         def clear(self):
 
1405
             self.listbox.clear()
 
1406
diff -ruN newt-0.51.6-old/whiptail.1 newt-0.51.6/whiptail.1
 
1407
--- newt-0.51.6-old/whiptail.1  1970-01-01 01:00:00 +0100
 
1408
+++ newt-0.51.6/whiptail.1      2004-07-11 12:25:36 +0100
 
1409
@@ -0,0 +1,264 @@
 
1410
+.TH WHIPTAIL 1 "20 September 2003" "Whiptail Version 0.51"
 
1411
+.SH NAME
 
1412
+whiptail \- display dialog boxes from shell scripts
 
1413
+.SH SYNOPSIS
 
1414
+.B whiptail
 
1415
+[
 
1416
+.B \-\-title
 
1417
+.I title
 
1418
+]
 
1419
+[
 
1420
+.B \-\-backtitle
 
1421
+.I backtitle
 
1422
+]
 
1423
+[
 
1424
+.B \-\-clear
 
1425
+]
 
1426
+[
 
1427
+.B \-\-default\-item
 
1428
+.I string
 
1429
+]
 
1430
+[
 
1431
+.B \-\-defaultno
 
1432
+]
 
1433
+[
 
1434
+.B \-\-fb
 
1435
+]
 
1436
+[
 
1437
+.B \-\-nocancel
 
1438
+]
 
1439
+[
 
1440
+.B \-\-noitem
 
1441
+[
 
1442
+]
 
1443
+.B \-\-output\-fd
 
1444
+.I fd
 
1445
+]
 
1446
+[
 
1447
+.B \-\-separate\-output
 
1448
+]
 
1449
+[
 
1450
+.B \-\-scrolltext
 
1451
+]
 
1452
+.B box-options
 
1453
+.SH DESCRIPTION
 
1454
+.B whiptail
 
1455
+is a program that will let you to present a variety of questions or
 
1456
+display messages using dialog boxes from a shell script. Currently,
 
1457
+these types of dialog boxes are implemented: 
 
1458
+.LP
 
1459
+.BR yes/no " box," " menu" " box," " input" " box,"
 
1460
+.BR message " box," " text" " box," " info" " box,"
 
1461
+.BR checklist " box," " radiolist" " box" " gauge" " box, and"
 
1462
+.BR password " box."
 
1463
+.SH OPTIONS
 
1464
+.TP
 
1465
+.B \-\-clear
 
1466
+The screen will be cleared to the
 
1467
+.BR "screen attribute" " on exit."
 
1468
+This doesn't work in an xterm (and descendants) if alternate screen
 
1469
+switching is enabled, because in that case slang writes to (and clears)
 
1470
+an alternate screen.
 
1471
+.TP
 
1472
+.B \-\-defaultno
 
1473
+The dialog box will open with the cursor over the 
 
1474
+.BR No " button."
 
1475
+.TP
 
1476
+.B \-\-default\-item "string"
 
1477
+Set  the default item in a menu box.
 
1478
+Normally the first item in the box is the default.
 
1479
+.TP
 
1480
+.B \-\-fb
 
1481
+Use full buttons. (By default, 
 
1482
+.B whiptail
 
1483
+uses compact buttons). 
 
1484
+.TP
 
1485
+.B \-\-nocancel
 
1486
+The dialog box won't have a 
 
1487
+.BR Cancel " button".
 
1488
+.TP
 
1489
+.B \-\-noitem
 
1490
+The menu, checklist and radiolist widgets will display tags only, not
 
1491
+the item strings.
 
1492
+.TP
 
1493
+.BI \-\-separate\-output
 
1494
+For checklist widgets, output result one line at a time, with no
 
1495
+quoting.  This facilitates parsing by another program.
 
1496
+.TP
 
1497
+.BI \-\-output\-fd  " fd" 
 
1498
+Direct output to the given file descriptor.  Most 
 
1499
+.B whiptail
 
1500
+scripts
 
1501
+write to the standard error, but  error  messages  may  also  be
 
1502
+written there, depending on your script.
 
1503
+.TP
 
1504
+.BI \-\-title " title"
 
1505
+Specifies a
 
1506
+.I title
 
1507
+string to be displayed at the top of the dialog box.
 
1508
+.TP
 
1509
+.BI \-\-backtitle " backtitle"
 
1510
+Specifies a
 
1511
+.I backtitle
 
1512
+string to be displayed on the backdrop, at the top of the screen.
 
1513
+.TP
 
1514
+.BI \-\-scrolltext
 
1515
+Force the display of a vertical scrollbar.
 
1516
+.TP
 
1517
+.B Box Options
 
1518
+.TP
 
1519
+.BI \-\-yesno " text height width"
 
1520
+.RB A " yes/no" " dialog box of size"
 
1521
+.I height
 
1522
+rows by
 
1523
+.I width
 
1524
+columns will be displayed. The string specified by
 
1525
+.I text
 
1526
+is displayed inside the dialog box. If this string is too long to be fitted
 
1527
+in one line, it will be automatically divided into multiple lines at
 
1528
+appropriate places. The
 
1529
+.I text
 
1530
+string may also contain the sub-string
 
1531
+.I
 
1532
+"\en"
 
1533
+or newline characters
 
1534
+.I `\en'
 
1535
+to control line breaking explicitly.  This dialog box is useful for
 
1536
+asking questions that require the user to answer either yes or no.
 
1537
+.RB "The dialog box has a" " Yes" " button and a " No
 
1538
+button, in which the user can switch between by pressing the
 
1539
+.IR TAB " key."
 
1540
+.TP
 
1541
+.BI \-\-msgbox " text height width"
 
1542
+.RB A " message" " box is very similar to a" " yes/no" " box."
 
1543
+The only difference between a
 
1544
+.B message
 
1545
+box and a
 
1546
+.B yes/no
 
1547
+box is that a
 
1548
+.B message
 
1549
+box has only a single
 
1550
+.B OK
 
1551
+button. You can use this dialog box to display any message you like.
 
1552
+After reading the message, the user can press the
 
1553
+.I ENTER
 
1554
+key so that
 
1555
+.B whiptail
 
1556
+will exit and the calling shell script can continue its operation.
 
1557
+.TP
 
1558
+.BI \-\-infobox " text height width"
 
1559
+.RB An " info" " box is basically a" " message" " box."
 
1560
+However, in this case,
 
1561
+.B whiptail
 
1562
+will exit immediately after displaying the message to the user. The
 
1563
+screen is not cleared when
 
1564
+.B whiptail
 
1565
+exits, so that the message will remain on the screen until the calling
 
1566
+shell script clears it later. This is useful when you want to inform
 
1567
+the user that some operations are carrying on that may require some
 
1568
+time to finish.
 
1569
+.TP
 
1570
+.BI \-\-inputbox " text height width [init]"
 
1571
+.RB "An " input " box is useful when you want to ask questions that"
 
1572
+require the user to input a string as the answer. If init is supplied
 
1573
+it is used to initialize the input string.
 
1574
+When inputing the
 
1575
+string, the
 
1576
+.I BACKSPACE
 
1577
+key can be used to correct typing errors. If the input string is longer than
 
1578
+can be fitted in the dialog box, the input field will be scrolled. On exit,
 
1579
+the input string will be printed on
 
1580
+.IR stderr "."
 
1581
+.TP
 
1582
+.BI \-\-passwordbox " text height width [init]"
 
1583
+.RB "A " password " box is similar to an input box, except the text the user"
 
1584
+enters is not displayed. This is useful when prompting for passwords or other
 
1585
+sensative information. Be aware that if anything is passed in "init", it
 
1586
+will be visible in the system's process table to casual snoopers. Also, it
 
1587
+is very confusing to the user to provide them with a default password they
 
1588
+cannot see. For these reasons, using "init" is highly discouraged.
 
1589
+.TP
 
1590
+.BI \-\-textbox " file height width"
 
1591
+.RB A " text" " box lets you display the contents of a text file in a"
 
1592
+dialog box. It is like a simple text file viewer. The user can move
 
1593
+through the file by using the
 
1594
+.IR UP/DOWN ", " PGUP/PGDN
 
1595
+.RI and " HOME/END" " keys available on most keyboards."
 
1596
+If the lines are too long to be displayed in the box, the
 
1597
+.I LEFT/RIGHT
 
1598
+keys can be used to scroll the text region horizontally. For more
 
1599
+convenience, forward and backward searching functions are also provided.
 
1600
+.IP "\fB\-\-menu \fItext height width menu-height \fR[ \fItag item \fR] \fI..."
 
1601
+As its name suggests, a
 
1602
+.B menu
 
1603
+box is a dialog box that can be used to present a list of choices in
 
1604
+the form of a menu for the user to choose. Each menu entry consists of a
 
1605
+.IR tag " string and an " item " string. The"
 
1606
+.I tag
 
1607
+gives the entry a name to distinguish it from the other entries in the
 
1608
+menu. The
 
1609
+.I item
 
1610
+is a short description of the option that the entry represents. The
 
1611
+user can move between the menu entries by pressing the
 
1612
+.I UP/DOWN
 
1613
+keys, the first letter of the
 
1614
+.I tag
 
1615
+as a hot-key, or the number keys
 
1616
+.IR 1-9 ". There are"
 
1617
+.I menu-height
 
1618
+entries displayed in the menu at one time, but the menu will be
 
1619
+scrolled if there are more entries than that. When
 
1620
+.B whiptail
 
1621
+exits, the
 
1622
+.I tag
 
1623
+of the chosen menu entry will be printed on
 
1624
+.IR stderr "."
 
1625
+.IP "\fB\-\-checklist \fItext height width list-height \fR[ \fItag item status \fR] \fI..."
 
1626
+.RB "A " checklist " box is similar to a " menu " box in that there are"
 
1627
+multiple entries presented in the form of a menu.
 
1628
+You may select an item using the SPACEW key. Instead of choosing
 
1629
+one entry among the entries, each entry can be turned on or off by the
 
1630
+user. The initial on/off state of each entry is specified by
 
1631
+.IR status "."
 
1632
+On exit, a list of the
 
1633
+.I tag
 
1634
+strings of those entries that are turned on will be printed on
 
1635
+.IR stderr "."
 
1636
+
 
1637
+.IP "\fB\-\-radiolist \fItext height width list-height \fR [ \fItag item status \fR] \fI..."
 
1638
+.RB "A " radiolist " box is similar to a " menu " box.  The only difference is"
 
1639
+that you can indicate which entry is currently selected, by setting its
 
1640
+.IR status " to " on "."
 
1641
+
 
1642
+.IP "\fB\-\-gauge \fItext height width percent\fR"
 
1643
+.RB "A " gauge " box displays a meter along the bottom of the box.
 
1644
+The meter indicates the percentage.  New percentages are read from
 
1645
+standard input, one integer per line.  The meter is updated
 
1646
+to reflect each new percentage.  If stdin is XXX, then subsequent
 
1647
+lines up to another XXX are used for a new prompt.
 
1648
+The gauge exits when EOF is reached on stdin.
 
1649
+
 
1650
+.SH DIAGNOSTICS
 
1651
+Exit status is 0 if
 
1652
+.BR whiptail " is exited by pressing the " Yes " or " OK
 
1653
+button, and 1 if the
 
1654
+.BR No " or " Cancel
 
1655
+button is pressed. Otherwise, if errors occur inside
 
1656
+.B whiptail
 
1657
+or
 
1658
+.B whiptail
 
1659
+is exited by pressing the
 
1660
+.I ESC
 
1661
+key, the exit status is -1.
 
1662
+.SH AUTHOR
 
1663
+Based on the man page for dialog(1) by:
 
1664
+.LP
 
1665
+Savio Lam (lam836@cs.cuhk.hk) - version 0.3
 
1666
+.LP
 
1667
+Stuart Herbert (S.Herbert@sheffield.ac.uk) - patch for version 0.4
 
1668
+.LP
 
1669
+Modifications for whiptail by:
 
1670
+.LP
 
1671
+Enrique Zanardi (ezanard@debian.org)
 
1672
+.LP
 
1673
+Alastair McKinstry (mckinstry@debian.org)