Update of /cvsroot/jtoolkit/jToolkit/widgets
In directory sc8-pr-cvs1:/tmp/cvs-serv11292/widgets
Modified Files:
grid.py table.py widgets.py
Log Message:
hate to do this, but a simple update of all the files from sjsoft for the meantime...
Index: grid.py
===================================================================
RCS file: /cvsroot/jtoolkit/jToolkit/widgets/grid.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** grid.py 25 Aug 2003 12:16:45 -0000 1.2
--- grid.py 25 Sep 2003 17:36:55 -0000 1.3
***************
*** 68,72 ****
contents = text
else:
! contents = widgets.Link(href, text, {'target':hreftarget})
return table.TableCell(contents, newattribs={'valign':'top','style':style})
--- 68,72 ----
contents = text
else:
! contents = widgets.Link(href, widgets.Font(text, newattribs={'style':style}), {'target':hreftarget})
return table.TableCell(contents, newattribs={'valign':'top','style':style})
Index: table.py
===================================================================
RCS file: /cvsroot/jtoolkit/jToolkit/widgets/table.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** table.py 25 Aug 2003 12:16:45 -0000 1.2
--- table.py 25 Sep 2003 17:36:55 -0000 1.3
***************
*** 89,93 ****
def minrownum(self):
! return min(self.rowsdict.keys())
def maxrownum(self):
--- 89,93 ----
def minrownum(self):
! return min(self.rowsdict.iterkeys())
def maxrownum(self):
***************
*** 98,105 ****
def mincolnum(self):
! return min([min(row.keys()) for row in self.rowsdict.values()])
def maxcolnum(self):
! return max([self.rowmaxcolnum(row) for row in self.rowsdict.values()])
def colrange(self):
--- 98,105 ----
def mincolnum(self):
! return min([min(row.iterkeys()) for row in self.rowsdict.itervalues()])
def maxcolnum(self):
! return max([self.rowmaxcolnum(row) for row in self.rowsdict.itervalues()])
def colrange(self):
***************
*** 248,254 ****
def rowwidth(self, rownum):
width = 0
! for cell in self.getrow(rownum).values():
! if hasattr(cell,'width'):
! width += cell.width
return width
--- 248,253 ----
def rowwidth(self, rownum):
width = 0
! for cell in self.getrow(rownum).itervalues():
! width += getattr(cell, 'width', 0)
return width
***************
*** 258,266 ****
def calcweights(self):
# calculate column widths for all the cells
for rownum in self.rowrange():
for colnum in self.colrange():
cell = self.getcell(rownum, colnum)
if cell.width != 0:
! width=100.0*cell.width/self.maxwidth()
styleattribs = {'width':'%d%%' % int(width)}
cell.overrideattribs({'style':styleattribs})
--- 257,266 ----
def calcweights(self):
# calculate column widths for all the cells
+ maxwidth = self.maxwidth()
for rownum in self.rowrange():
for colnum in self.colrange():
cell = self.getcell(rownum, colnum)
if cell.width != 0:
! width=100.0*cell.width/maxwidth
styleattribs = {'width':'%d%%' % int(width)}
cell.overrideattribs({'style':styleattribs})
Index: widgets.py
===================================================================
RCS file: /cvsroot/jtoolkit/jToolkit/widgets/widgets.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** widgets.py 25 Aug 2003 12:16:45 -0000 1.2
--- widgets.py 25 Sep 2003 17:36:55 -0000 1.3
***************
*** 35,39 ****
def gethtml(self):
! return "<"+self.tagname+" "+self.gethtmlattribs()+">" + self.getcontents() + "</"+self.tagname+">\r"
def getcontents(self):
--- 35,39 ----
def gethtml(self):
! return "<%s %s>%s</%s>\r" % (self.tagname, self.gethtmlattribs(), self.getcontents(), self.tagname)
def getcontents(self):
***************
*** 43,48 ****
def gethtmlattribs(self):
#return a string representing all the attribs in this class
! htmlattribstrs = [self.gethtmlattrib(item) for item in self.attribs.items()]
! return " ".join(htmlattribstrs)
def escape(self, s, quote=None):
--- 43,47 ----
def gethtmlattribs(self):
#return a string representing all the attribs in this class
! return " ".join([self.gethtmlattrib(key, value) for key, value in self.attribs.iteritems()])
def escape(self, s, quote=None):
***************
*** 51,63 ****
s = s.replace("<", "<").replace(">", ">")
if quote:
! if '"' in s:
! if "'" in s: s = '"%s"' % s.replace('"', """)
! else: s = "'%s'" % s
! else: s = '"%s"' % s
return s
! def gethtmlattrib(self,item):
"""turns the key and value into something usable as an html attribute and value..."""
- key, value = item
valuetype = type(value)
if valuetype == str or valuetype == unicode:
--- 50,58 ----
s = s.replace("<", "<").replace(">", ">")
if quote:
! s = '"' + s.replace('"', """) + '"'
return s
! def gethtmlattrib(self, key, value):
"""turns the key and value into something usable as an html attribute and value..."""
valuetype = type(value)
if valuetype == str or valuetype == unicode:
***************
*** 93,100 ****
return contents
elif type(contents) in (tuple, list):
! contentslist = []
! for contentspart in contents:
! contentslist.append(self.getcontentshtml(contentspart))
! return "".join(contentslist)
elif hasattr(contents, "gethtml"):
return contents.gethtml()
--- 88,92 ----
return contents
elif type(contents) in (tuple, list):
! return "".join([self.getcontentshtml(contentspart) for contentspart in contents])
elif hasattr(contents, "gethtml"):
return contents.gethtml()
***************
*** 124,127 ****
--- 116,124 ----
return self.getcontents()
+
+ class Font(ContentWidget):
+ def __init__(self, contents, newattribs={}):
+ ContentWidget.__init__(self, "FONT", contents, newattribs)
+
class Button(ContentWidget):
# Represents a button widget.
***************
*** 154,165 ****
# Return the html for this combo. and store the result in the output string.
html = ""
! for option in self.options:
! value, description = option
if type(value) not in (str, unicode):
value = str(value)
selected = ""
! if value.lower() == self.attribs['value'].lower():
selected = " SELECTED"
! html += ' <OPTION VALUE="' + value + '"' + selected + '>' + description + ' </OPTION>\r'
return html
--- 151,162 ----
# 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
***************
*** 180,184 ****
self.attribs = {'href':href}
self.overrideattribs(newattribs)
- self.contents = contents
class Tooltip(ContentWidget):
--- 177,180 ----
***************
*** 187,191 ****
self.attribs = {'title':tooltip}
self.overrideattribs(newattribs)
- self.contents = contents
class TextArea(ContentWidget):
--- 183,186 ----
***************
*** 201,210 ****
class Paragraph(ContentWidget):
"""this is a simple widgetlist wrapping some widgets in a paragraph"""
! def __init__(self, contents=[]):
! ContentWidget.__init__(self, tagname="p", contents=contents)
class Page(ContentWidget):
! def __init__(self, title="", contents=[], newattribs={}):
self.title = title
ContentWidget.__init__(self, None, contents, newattribs)
--- 196,206 ----
class Paragraph(ContentWidget):
"""this is a simple widgetlist wrapping some widgets in a paragraph"""
! def __init__(self, contents=[], newattribs={}):
! ContentWidget.__init__(self, tagname="p", contents=contents, newattribs=newattribs)
class Page(ContentWidget):
! def __init__(self, title="", contents=[], newattribs={}, script=""):
self.title = title
+ self.script = script
ContentWidget.__init__(self, None, contents, newattribs)
***************
*** 212,216 ****
return self.getheader() + self.getbody() + self.getfooter()
! def getheader(self,script=""):
base=self.attribs.get('base','')
target=self.attribs.get('target','')
--- 208,212 ----
return self.getheader() + self.getbody() + self.getfooter()
! def getheader(self):
base=self.attribs.get('base','')
target=self.attribs.get('target','')
***************
*** 240,244 ****
<BASE href="%s" target="%s">""" % (base, target)
# any script required
! result += script
# finished the head
result += """
--- 236,240 ----
<BASE href="%s" target="%s">""" % (base, target)
# any script required
! result += self.script
# finished the head
result += """
|