[jToolkit-cvs] jToolkit/widgets widgets.py,1.4,1.5
Brought to you by:
davidfraser,
friedelwolff
From: <dav...@us...> - 2004-02-09 12:29:36
|
Update of /cvsroot/jtoolkit/jToolkit/widgets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20884 Modified Files: widgets.py Log Message: modified Select object to be a ContentWidget Index: widgets.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/widgets/widgets.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** widgets.py 14 Oct 2003 09:39:48 -0000 1.4 --- widgets.py 9 Feb 2004 12:26:24 -0000 1.5 *************** *** 123,127 **** return self.getcontents() - class Font(ContentWidget): def __init__(self, contents, newattribs={}): --- 123,126 ---- *************** *** 142,146 **** self.overrideattribs(newattribs) ! class Select(Widget): # Represents a combo box or Select type. Parameters include a list of options which are made # available when the user clicks on the down arrow. The value of the selection --- 141,151 ---- self.overrideattribs(newattribs) ! class Option(ContentWidget): ! def __init__(self, value, description, selected=0): ! ContentWidget.__init__(self, "OPTION", description, {'VALUE': value}) ! if selected: ! self.attribs["selected"] = None ! ! class Select(ContentWidget): # Represents a combo box or Select type. Parameters include a list of options which are made # available when the user clicks on the down arrow. The value of the selection *************** *** 150,170 **** # the description as the second element. def __init__(self, newattribs = {}, options = []): ! Widget.__init__(self,"SELECT") ! self.attribs = {'name':'NewCombo', 'value':''} self.overrideattribs(newattribs) - self.options = options - - def getcontents(self): - # Return the html for this combo. and store the result in the output string. - html = "" selectedvalue = self.attribs['value'].lower() ! for value, description in self.options: if type(value) not in (str, unicode): value = str(value) selected = "" ! if value.lower() == selectedvalue: ! selected = " SELECTED" ! html += ' <OPTION VALUE="%s"%s>%s </OPTION>\r' % (value, selected, description) ! return html class Input(Widget): --- 155,168 ---- # the description as the second element. def __init__(self, newattribs = {}, options = []): ! ContentWidget.__init__(self, "SELECT", [], {'name':'NewCombo', 'value':''}) self.overrideattribs(newattribs) selectedvalue = self.attribs['value'].lower() ! for value, description in options: if type(value) not in (str, unicode): value = str(value) selected = "" ! selected = (value.lower() == selectedvalue) ! optionwidget = Option(value, description, selected) ! self.addcontents(optionwidget) class Input(Widget): |