[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r9038 - trunk/gnue-forms/src/uidrivers/curses
From: |
johannes |
Subject: |
[gnue] r9038 - trunk/gnue-forms/src/uidrivers/curses |
Date: |
Tue, 14 Nov 2006 02:24:44 -0600 (CST) |
Author: johannes
Date: 2006-11-14 02:24:43 -0600 (Tue, 14 Nov 2006)
New Revision: 9038
Modified:
trunk/gnue-forms/src/uidrivers/curses/dialogs.py
Log:
Pep8-ification (using reindent.py :)
Modified: trunk/gnue-forms/src/uidrivers/curses/dialogs.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/dialogs.py 2006-11-14 02:00:04 UTC
(rev 9037)
+++ trunk/gnue-forms/src/uidrivers/curses/dialogs.py 2006-11-14 08:24:43 UTC
(rev 9038)
@@ -27,403 +27,405 @@
from gnue.common.apps import i18n
+__all__ = ['OptionsDialog', 'InputDialog']
+
# =============================================================================
# Dialog box for selection an option from a given options dictionary
# =============================================================================
class OptionsDialog:
- # ---------------------------------------------------------------------------
- # Constructor
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Constructor
+ # ------------------------------------------------------------------------
- def __init__ (self, title, options, attrs, quit = None, left = 0, top = 0,
- right = 80, bottom = 24, returnKeys = False):
-
- curses.noecho ()
- curses.cbreak ()
+ def __init__(self, title, options, attrs, quit=None, left=0, top=0,
+ right=80, bottom=24, returnKeys=False):
- try:
- self.__oldcursor = curses.curs_set (0)
- except:
- self.__oldcursor = 1
+ curses.noecho()
+ curses.cbreak()
- self.__data = [("%s" % val, key) for (key, val) in options.items ()]
- self.__data.sort ()
+ try:
+ self.__oldcursor = curses.curs_set(0)
+ except:
+ self.__oldcursor = 1
- maxString = max ([len (item) for (item, key) in self.__data])
+ self.__data = [("%s" % val, key) for (key, val) in options.items()]
+ self.__data.sort()
- width = min (right - left, max ((maxString + 4), len (title) + 4))
- height = min (bottom - top, len (options) + 4)
- left = max (left, (right - left - width) / 2)
- top = max (top, (bottom - top - height) / 2)
+ maxString = max ([len (item) for (item, key) in self.__data])
- width = min (left + width, right) - left
- height = min (top + height, bottom) - top
+ width = min(right - left, max((maxString + 4), len(title) + 4))
+ height = min(bottom - top, len(options) + 4)
+ left = max(left, (right - left - width) / 2)
+ top = max(top, (bottom - top - height) / 2)
- self.__window = curses.newwin (height, width, top, left)
- self.__window.keypad (1)
- self.__window.box ()
+ width = min(left + width, right) - left
+ height = min(top + height, bottom) - top
- self.__normal = attrs.get ('window 1', attrs ['background'])
- self.__reverse = attrs ['focusentry']
- self.__quit = quit
+ self.__window = curses.newwin(height, width, top, left)
+ self.__window.keypad(1)
+ self.__window.box()
+ self.__normal = attrs.get('window 1', attrs['background'])
+ self.__reverse = attrs['focusentry']
+ self.__quit = quit
- self.__dwidth = width - 4
- self.__window.bkgd (' ', self.__normal)
- self.__window.addstr (1, 2, o(title.center (self.__dwidth)))
- self.__window.hline (2, 1, curses.ACS_HLINE, width - 2)
- self.__offset = 0
- self.__index = 0
- self.__pIndex = 1
- self.__page = height - 4
- self.__returnKeys = returnKeys
+ self.__dwidth = width - 4
+ self.__window.bkgd(' ', self.__normal)
+ self.__window.addstr(1, 2, o(title.center(self.__dwidth)))
+ self.__window.hline(2, 1, curses.ACS_HLINE, width - 2)
- self.__refresh ()
+ self.__offset = 0
+ self.__index = 0
+ self.__pIndex = 1
+ self.__page = height - 4
+ self.__returnKeys = returnKeys
+ self.__refresh()
- # ---------------------------------------------------------------------------
- # Start the selection
- # ---------------------------------------------------------------------------
- def run (self):
- """
- Start the selection dialog.
+ # -------------------------------------------------------------------------
+ # Start the selection
+ # -------------------------------------------------------------------------
- @return: selected item or None if canceled
- """
+ def run(self):
+ """
+ Start the selection dialog.
- self.__window.refresh ()
+ @return: selected item or None if canceled
+ """
- try:
- while 1:
- key = self.__window.getch ()
+ self.__window.refresh()
- if key == 27 or key == self.__quit:
- return None
+ try:
+ while 1:
+ key = self.__window.getch()
- elif key == curses.KEY_UP:
- self.__move (-1)
+ if key == 27 or key == self.__quit:
+ return None
- elif key == curses.KEY_DOWN:
- self.__move (+1)
+ elif key == curses.KEY_UP:
+ self.__move(-1)
- elif key == 10:
- return self.__data [self.__index][self.__returnKeys]
+ elif key == curses.KEY_DOWN:
+ self.__move(+1)
- finally:
- try:
- curses.curs_set (self.__oldcursor)
- except:
- pass
+ elif key == 10:
+ return self.__data[self.__index][self.__returnKeys]
+ finally:
+ try:
+ curses.curs_set(self.__oldcursor)
+ except:
+ pass
- # ---------------------------------------------------------------------------
- # Move the selection in a given direction
- # ---------------------------------------------------------------------------
- def __move (self, direction):
+ # -------------------------------------------------------------------------
+ # Move the selection in a given direction
+ # -------------------------------------------------------------------------
- self.__pIndex += direction
- self.__index += direction
+ def __move(self, direction):
- if self.__pIndex > self.__page:
- if self.__index < len (self.__data):
- self.__offset += direction
+ self.__pIndex += direction
+ self.__index += direction
- elif self.__pIndex < 1:
- self.__offset = max (0, self.__offset - 1)
+ if self.__pIndex > self.__page:
+ if self.__index < len(self.__data):
+ self.__offset += direction
- # Make sure to stay in bounds
- self.__index = max (0, self.__index)
- self.__index = min (len (self.__data) - 1, self.__index)
+ elif self.__pIndex < 1:
+ self.__offset = max(0, self.__offset - 1)
- self.__pIndex = max (1, self.__pIndex)
- self.__pIndex = min (self.__page, self.__pIndex)
+ # Make sure to stay in bounds
+ self.__index = max(0, self.__index)
+ self.__index = min(len(self.__data) - 1, self.__index)
- self.__refresh ()
+ self.__pIndex = max(1, self.__pIndex)
+ self.__pIndex = min(self.__page, self.__pIndex)
+ self.__refresh()
- # ---------------------------------------------------------------------------
- # Refresh the dialog's window
- # ---------------------------------------------------------------------------
- def __refresh (self):
+ # -------------------------------------------------------------------------
+ # Refresh the dialog's window
+ # -------------------------------------------------------------------------
- lines = self.__data [self.__offset:self.__offset + self.__page]
- for (line, (value, key)) in enumerate (lines):
- text = " %s " % value.ljust (self.__dwidth) [:self.__dwidth]
- if line == self.__pIndex - 1:
- attr = self.__reverse
- else:
- attr = self.__normal
+ def __refresh(self):
- self.__window.addnstr (3 + line, 1, text, self.__dwidth + 2, attr)
+ lines = self.__data[self.__offset:self.__offset + self.__page]
+ for (line, (value, key)) in enumerate(lines):
+ text = " %s " % value.ljust(self.__dwidth)[:self.__dwidth]
+ if line == self.__pIndex - 1:
+ attr = self.__reverse
+ else:
+ attr = self.__normal
- self.__window.move (3 + self.__pIndex - 1, 1)
+ self.__window.addnstr(3 + line, 1, text, self.__dwidth + 2, attr)
+ self.__window.move(3 + self.__pIndex - 1, 1)
+
# =============================================================================
# Class implementing a versatile input dialog
# =============================================================================
class InputDialog:
- # ---------------------------------------------------------------------------
- # Create a new input dialog
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Create a new input dialog
+ # -------------------------------------------------------------------------
- def __init__ (self, title, fields, attrs, cancel = True, left = 0, top = 0,
- right = 80, bottom = 24):
+ def __init__(self, title, fields, attrs, cancel = True, left = 0, top = 0,
+ right = 80, bottom = 24):
- curses.noecho ()
- curses.cbreak ()
+ curses.noecho()
+ curses.cbreak()
- self.attrs = attrs
- self.fields = fields
- self.cancel = cancel
- self.__buildWindow (title, left, top, right, bottom)
+ self.attrs = attrs
+ self.fields = fields
+ self.cancel = cancel
+ self.__buildWindow(title, left, top, right, bottom)
- self.inputData = {}
+ self.inputData = {}
- # A dictionary with the fieldname as key and a triple (master, allowed,
- # current) as data items
- self.lookups = {}
+ # A dictionary with the fieldname as key and a triple (master, allowed,
+ # current) as data items
+ self.lookups = {}
- y = 2
- self.__entries = []
+ y = 2
+ self.__entries = []
- for (label, name, ftype, default, master, elements) in fields:
- if ftype == 'image':
- continue
+ for (label, name, ftype, default, master, elements) in fields:
+ if ftype == 'image':
+ continue
- y += 1
+ y += 1
- if ftype in ['label', 'warning']:
- attr = [attrs ['background'], attrs ['warnmsg']][ftype == 'warning']
- cw = self.__width - 2
- lh = label.count ('\n') + 1
+ if ftype in ['label', 'warning']:
+ attr = [attrs['background'], attrs['warnmsg']][ftype ==
'warning']
+ cw = self.__width - 2
+ lh = label.count('\n') + 1
- for item in label.splitlines ():
- self.__window.addnstr (y, 1, o(item.center (cw)), cw, attr)
- y += 1
+ for item in label.splitlines():
+ self.__window.addnstr(y, 1, o(item.center(cw)), cw, attr)
+ y += 1
- if lh > 1: y -= 1
+ if lh > 1: y -= 1
- elif ftype in ['string', 'password', 'dropdown']:
- self.__window.addnstr (y, 2, o(label), self.__leftcol)
+ elif ftype in ['string', 'password', 'dropdown']:
+ self.__window.addnstr(y, 2, o(label), self.__leftcol)
- win = curses.newwin (1, self.__rightcol,
- self.__wtop + y, self.__wleft + self.__leftcol + 2)
- self.__entries.append ((win, name, default, ftype == 'password'))
+ win = curses.newwin(1, self.__rightcol,
+ self.__wtop + y, self.__wleft + self.__leftcol +
2)
+ self.__entries.append((win, name, default, ftype ==
'password'))
- if ftype == 'dropdown':
- values = elements [0][1]
- self.lookups [name] = (master, values,
- self.__getCurrent (master, values))
- dispValue = self.lookups [name][2].get (default, '')
- else:
- dispValue = default
+ if ftype == 'dropdown':
+ values = elements[0][1]
+ self.lookups[name] = (master, values,
+ self.__getCurrent(master, values))
+ dispValue = self.lookups[name][2].get(default, '')
+ else:
+ dispValue = default
- self.__display (win, dispValue, ftype == 'password')
+ self.__display(win, dispValue, ftype == 'password')
- # ---------------------------------------------------------------------------
- # Run the dialog
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Run the dialog
+ # -------------------------------------------------------------------------
- def run (self):
+ def run(self):
- self.__window.refresh ()
+ self.__window.refresh()
- index = 0
- while index < len (self.__entries):
- (win, name, default, hidden) = self.__entries [index]
- cvalue = self.inputData.get (name, default)
- (value, code) = self.__accept (win, cvalue, name, hidden)
- if value is None:
- if name in self.inputData:
- del self.inputData [name]
- else:
- self.inputData [name] = value
+ index = 0
+ while index < len(self.__entries):
+ (win, name, default, hidden) = self.__entries[index]
+ cvalue = self.inputData.get(name, default)
+ (value, code) = self.__accept(win, cvalue, name, hidden)
+ if value is None:
+ if name in self.inputData:
+ del self.inputData[name]
+ else:
+ self.inputData[name] = value
- if code == 27 and self.cancel:
- self.inputData = None
- break
+ if code == 27 and self.cancel:
+ self.inputData = None
+ break
- elif code == curses.KEY_UP:
- index = max (0, index - 1)
+ elif code == curses.KEY_UP:
+ index = max(0, index - 1)
- else:
- index += 1
+ else:
+ index += 1
- # ---------------------------------------------------------------------------
- # Calculate and build the window
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Calculate and build the window
+ # -------------------------------------------------------------------------
- def __buildWindow (self, title, left, top, right, bottom):
+ def __buildWindow(self, title, left, top, right, bottom):
- leftcol = 0
- rightcol = 0
- width = 0
- height = 5 # box + title + spacer + bottom
+ leftcol = 0
+ rightcol = 0
+ width = 0
+ height = 5 # box + title + spacer + bottom
- for (label, name, ftype, default, master, elements) in self.fields:
- if ftype in ['label', 'warning']:
- arr = ([width] + [len (part) + 2 for part in label.splitlines ()])
- width = max ([width] + [len (part) + 2 for part in label.splitlines
()])
- height += label.count ('\n') + 1
+ for (label, name, ftype, default, master, elements) in self.fields:
+ if ftype in ['label', 'warning']:
+ arr = ([width] + [len(part) + 2 for part in
label.splitlines()])
+ width = max([width] + [len(part) + 2 for part in
label.splitlines()])
+ height += label.count('\n') + 1
- elif ftype in ['string', 'password']:
- leftcol = max (leftcol, len (label) + 1)
- rightcol = max (rightcol, 20)
- height += 1
+ elif ftype in ['string', 'password']:
+ leftcol = max(leftcol, len(label) + 1)
+ rightcol = max(rightcol, 20)
+ height += 1
- elif ftype == 'dropdown':
- leftcol = max (leftcol, len (label) + 1)
- height += 1
+ elif ftype == 'dropdown':
+ leftcol = max(leftcol, len(label) + 1)
+ height += 1
- # We introspect only the first control since we do not provide them all
- # for input
- (label, allowed) = elements [0]
- widest = 0
- if master is None:
- data = [allowed]
- else:
- data = allowed.values ()
+ # We introspect only the first control since we do not provide
them all
+ # for input
+ (label, allowed) = elements[0]
+ widest = 0
+ if master is None:
+ data = [allowed]
+ else:
+ data = allowed.values()
- for vdict in data:
- widest = max ([widest] + [len (i) for i in vdict.values ()])
+ for vdict in data:
+ widest = max([widest] + [len(i) for i in vdict.values()])
- rightcol = max (rightcol, widest)
+ rightcol = max(rightcol, widest)
- self.__width = min (max (leftcol + rightcol + 4, width), right - left)
- self.__height = min (height, bottom - top)
- self.__wtop = (bottom - top - self.__height) / 2
- self.__wleft = (right - left - self.__width) / 2
+ self.__width = min(max(leftcol + rightcol + 4, width), right - left)
+ self.__height = min(height, bottom - top)
+ self.__wtop = (bottom - top - self.__height) / 2
+ self.__wleft = (right - left - self.__width) / 2
- self.__window = curses.newwin (self.__height, self.__width,
- self.__wtop, self.__wleft)
- self.__window.bkgd (' ', self.attrs ['background'])
- self.__window.box ()
- self.__window.keypad (1)
+ self.__window = curses.newwin(self.__height, self.__width,
+ self.__wtop, self.__wleft)
+ self.__window.bkgd(' ', self.attrs['background'])
+ self.__window.box()
+ self.__window.keypad(1)
- self.__window.addstr (1, 1, o(title.center (self.__width - 2)))
+ self.__window.addstr(1, 1, o(title.center(self.__width - 2)))
- self.__leftcol = leftcol
- self.__rightcol = rightcol
+ self.__leftcol = leftcol
+ self.__rightcol = rightcol
- # ---------------------------------------------------------------------------
- # Get input for a given field
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Get input for a given field
+ # -------------------------------------------------------------------------
- def __accept (self, win, default, name, hidden = False):
+ def __accept(self, win, default, name, hidden = False):
- if name in self.lookups:
- (master, allowed, current) = self.lookups [name]
- current = self.__getCurrent (master, allowed)
- self.lookups [name] = (master, allowed, current)
+ if name in self.lookups:
+ (master, allowed, current) = self.lookups[name]
+ current = self.__getCurrent(master, allowed)
+ self.lookups[name] = (master, allowed, current)
- reverse = {}
- for (k, v) in current.items ():
- reverse [v] = k
+ reverse = {}
+ for (k, v) in current.items():
+ reverse[v] = k
- value = current.get (default, '')
- else:
- value = default or ''
- current = None
- revese = None
+ value = current.get(default, '')
+ else:
+ value = default or ''
+ current = None
+ revese = None
- win.keypad (1)
+ win.keypad(1)
- while True:
- self.__display (win, value, hidden, True)
+ while True:
+ self.__display(win, value, hidden, True)
- code = self.__window.getch ()
+ code = self.__window.getch()
- if code in [9, 10, 27, curses.KEY_DOWN, curses.KEY_UP]:
- if code == 27:
- rvalue = None
+ if code in [9, 10, 27, curses.KEY_DOWN, curses.KEY_UP]:
+ if code == 27:
+ rvalue = None
- elif code == 9:
- code = curses.KEY_DOWN
+ elif code == 9:
+ code = curses.KEY_DOWN
- if code != 27 and name in self.lookups:
- if reverse and not value in reverse:
- curses.beep ()
- continue
- else:
- rvalue = reverse.get (value)
- else:
- rvalue = value
+ if code != 27 and name in self.lookups:
+ if reverse and not value in reverse:
+ curses.beep()
+ continue
+ else:
+ rvalue = reverse.get(value)
+ else:
+ rvalue = value
- break
+ break
- elif code == curses.KEY_BACKSPACE:
- value = value [:-1]
+ elif code == curses.KEY_BACKSPACE:
+ value = value[:-1]
- elif current and code == 23:
- op = OptionsDialog ('Select Option', current, self.attrs, 23)
- v = op.run ()
- self.__window.redrawwin ()
- curses.doupdate ()
+ elif current and code == 23:
+ op = OptionsDialog('Select Option', current, self.attrs, 23)
+ v = op.run()
+ self.__window.redrawwin()
+ curses.doupdate()
- if v is not None:
- value = v
- curses.ungetch (10)
+ if v is not None:
+ value = v
+ curses.ungetch(10)
- elif curses.ascii.isprint (code):
- value += chr (code)
+ elif curses.ascii.isprint(code):
+ value += chr(code)
- self.__display (win, value, hidden, False)
+ self.__display(win, value, hidden, False)
- return (rvalue, code)
+ return (rvalue, code)
- # ---------------------------------------------------------------------------
- # Display the visible portion of a given value within a window
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Display the visible portion of a given value within a window
+ # -----------------------------------------------------------------------
- def __display (self, win, value, hidden = False, edit = False):
+ def __display(self, win, value, hidden = False, edit = False):
- data = value or ''
- attr = self.attrs [edit and 'focusentry' or 'entry']
- win.bkgd (' ', attr)
+ data = value or ''
+ attr = self.attrs[edit and 'focusentry' or 'entry']
+ win.bkgd(' ', attr)
- length = win.getmaxyx () [1] - 1
- (top, left) = win.getbegyx ()
- (mtop, mleft) = self.__window.getbegyx ()
- top -= mtop
- left -= mleft
+ length = win.getmaxyx()[1] - 1
+ (top, left) = win.getbegyx()
+ (mtop, mleft) = self.__window.getbegyx()
+ top -= mtop
+ left -= mleft
- dvalue = [data, '*' * len (data)] [hidden]
- offset = max (0, len (dvalue) - length)
- pos = min (len (dvalue) - offset, length)
+ dvalue = [data, '*' * len(data)][hidden]
+ offset = max(0, len(dvalue) - length)
+ pos = min(len(dvalue) - offset, length)
- out = dvalue [offset:offset + length].ljust (length + 1)
- self.__window.addnstr (top, left, out, length + 1, attr)
+ out = dvalue[offset:offset + length].ljust(length + 1)
+ self.__window.addnstr(top, left, out, length + 1, attr)
- self.__window.move (top, (pos + left))
+ self.__window.move(top, (pos + left))
- # ---------------------------------------------------------------------------
- # Get the current value dictionary for a given dropdown
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Get the current value dictionary for a given dropdown
+ # -------------------------------------------------------------------------
- def __getCurrent (self, master, values):
+ def __getCurrent(self, master, values):
- if master is None:
- return values
- else:
- return values.get (self.inputData.get (master), {})
+ if master is None:
+ return values
+ else:
+ return values.get(self.inputData.get(master), {})
# =============================================================================
@@ -431,77 +433,77 @@
# =============================================================================
if __name__ == '__main__':
- curses.initscr ()
- curses.cbreak ()
- curses.raw ()
- curses.start_color ()
+ curses.initscr()
+ curses.cbreak()
+ curses.raw()
+ curses.start_color()
- curses.init_pair (3, curses.COLOR_BLACK, curses.COLOR_CYAN)
- curses.init_pair (4, curses.COLOR_BLUE, curses.COLOR_WHITE)
- curses.init_pair (5, curses.COLOR_WHITE, curses.COLOR_RED)
- curses.init_pair (6, curses.COLOR_BLACK, curses.COLOR_CYAN)
- curses.init_pair (9, curses.COLOR_WHITE, curses.COLOR_RED)
+ curses.init_pair(3, curses.COLOR_BLACK, curses.COLOR_CYAN)
+ curses.init_pair(4, curses.COLOR_BLUE, curses.COLOR_WHITE)
+ curses.init_pair(5, curses.COLOR_WHITE, curses.COLOR_RED)
+ curses.init_pair(6, curses.COLOR_BLACK, curses.COLOR_CYAN)
+ curses.init_pair(9, curses.COLOR_WHITE, curses.COLOR_RED)
- attrs = {'background': curses.color_pair (4),
- 'focusentry': curses.color_pair (5),
- 'entry' : curses.color_pair (6),
- 'window 1' : curses.color_pair (3),
- 'warnmsg' : curses.color_pair (9) + curses.A_BOLD}
+ attrs = {'background': curses.color_pair(4),
+ 'focusentry': curses.color_pair(5),
+ 'entry' : curses.color_pair(6),
+ 'window 1' : curses.color_pair(3),
+ 'warnmsg' : curses.color_pair(9) + curses.A_BOLD}
- opts = {'foo': 'Foobar', 'baz': 'Barbaz and the Gang!',
- 2: 'something', 3: 'quite', 4: 'interesting stuff', 5: 'hey ho',
- 7: 'number 7'}
+ opts = {'foo': 'Foobar', 'baz': 'Barbaz and the Gang!',
+ 2: 'something', 3: 'quite', 4: 'interesting stuff', 5: 'hey ho',
+ 7: 'number 7'}
- opts = {1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:10, 11:11, 12:12,
- 13:13, 14:14, "k15":15, 16:16, 17:17, 18:18, 19:19, 20:20}
- #d = OptionsDialog ('Foos', opts, attrs, quit = 23, top = 2, bottom = 22,
- #returnKeys = True)
- #r = d.run ()
+ opts = {1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:10, 11:11, 12:12,
+ 13:13, 14:14, "k15":15, 16:16, 17:17, 18:18, 19:19, 20:20}
+ #d = OptionsDialog('Foos', opts, attrs, quit = 23, top = 2, bottom = 22,
+ #returnKeys = True)
+ #r = d.run()
- #curses.endwin ()
+ #curses.endwin()
- #print "RESULT:", r
+ #print "RESULT:", r
- #sys.exit ()
+ #sys.exit()
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
- cname = {'c1': 'demoa', 'c2': 'demob'}
- ckey = {'c1': 'ck-A', 'c2': 'ck-B'}
+ cname = {'c1': 'demoa', 'c2': 'demob'}
+ ckey = {'c1': 'ck-A', 'c2': 'ck-B'}
- wija = {'c1': {'04': '2004', '05': '2005'},
- 'c2': {'24': '2024', '25': '2025', '26': '2026'}}
+ wija = {'c1': {'04': '2004', '05': '2005'},
+ 'c2': {'24': '2024', '25': '2025', '26': '2026'}}
- codes = {'24': {'241': 'c-24-1', '242': 'c-24-2'},
- '25': {'251': 'c-25-1'}}
+ codes = {'24': {'241': 'c-24-1', '242': 'c-24-2'},
+ '25': {'251': 'c-25-1'}}
- descr = 'Hier ist ein langer Text\nMit einem Zeilenumbruch'
- fields = [('Foo!', '/home/johannes/gnue/share/gnue/images/gnue.png', 'image',
- None, None, []),
- ('Username', '_username', 'string', 'frodo', None, \
- [('Name of the user', None)]),
- ('', None, 'label', None, None, []),
- ('Password', '_password', 'password', 'foo', None, [('yeah',1)]),
- ('Foobar', '_foobar', 'dropdown', 'frob', None, \
- [('single', {'trash': 'Da Trash', 'frob': 'Frob'})]),
- ('Multi', '_multi', 'dropdown', '100', None, \
- [('name', {'50': 'A 50', '100': 'B 100', '9': 'C 9'}),
- ('sepp', {'50': 'se 50', '100': 'se 100', '9': 'se 9'})]),
- (descr, '_depp', 'label', 'furz', None, []),
- ('Das ist jetzt ein Fehler', None, 'warning', None, None, []),
- ('Firma', 'company', 'dropdown', 'c1', None,
- [('Name', cname), ('Code', ckey)]),
- ('Wirtschaftsjahr', 'wija', 'dropdown', '05', 'company',
- [('Jahr', wija)]),
- ('Codes', 'codes', 'dropdown', None, 'wija',
- [('Code', codes)]),
- (u"Dre\xf6ksau 'bl\xf6sepp'", None, 'warning', None, None, [])]
+ descr = 'Hier ist ein langer Text\nMit einem Zeilenumbruch'
+ fields = [('Foo!', '/home/johannes/gnue/share/gnue/images/gnue.png',
'image',
+ None, None, []),
+ ('Username', '_username', 'string', 'frodo', None, \
+ [('Name of the user', None)]),
+ ('', None, 'label', None, None, []),
+ ('Password', '_password', 'password', 'foo', None, [('yeah',1)]),
+ ('Foobar', '_foobar', 'dropdown', 'frob', None, \
+ [('single', {'trash': 'Da Trash', 'frob': 'Frob'})]),
+ ('Multi', '_multi', 'dropdown', '100', None, \
+ [('name', {'50': 'A 50', '100': 'B 100', '9': 'C 9'}),
+ ('sepp', {'50': 'se 50', '100': 'se 100', '9': 'se 9'})]),
+ (descr, '_depp', 'label', 'furz', None, []),
+ ('Das ist jetzt ein Fehler', None, 'warning', None, None, []),
+ ('Firma', 'company', 'dropdown', 'c1', None,
+ [('Name', cname), ('Code', ckey)]),
+ ('Wirtschaftsjahr', 'wija', 'dropdown', '05', 'company',
+ [('Jahr', wija)]),
+ ('Codes', 'codes', 'dropdown', None, 'wija',
+ [('Code', codes)]),
+ (u"Dre\xf6ksau 'bl\xf6sepp'", None, 'warning', None, None, [])]
- dlg = InputDialog ('foobar', fields, attrs)
- dlg.run ()
+ dlg = InputDialog('foobar', fields, attrs)
+ dlg.run()
- curses.endwin ()
+ curses.endwin()
- print "RES:", dlg.inputData
+ print "RES:", dlg.inputData
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r9038 - trunk/gnue-forms/src/uidrivers/curses,
johannes <=