Work on CSS management

This commit is contained in:
2014-11-27 21:40:23 +01:00
parent d2b0d0dae6
commit 3858127a6d
8 changed files with 69 additions and 22 deletions

View File

@@ -60,45 +60,78 @@ class DisplayHTMLBlockTable(DisplayHTMLBlock):
self.rows.append(listToStr(row))
self.rows_cssclasses.append(['' for e in row])
def getCellValue(row, col):
def getCellValue(self, row, col):
if row < 0 or col < 0 or\
row >= len(self.rows) or col >= len(self.cols):
raise ValueError('Invalid indices')
raise ValueError('Invalid indices %d,%d' % (row, col))
return self.rows[row][col]
def setCellValue(row, col, value):
def setCellValue(self, row, col, value):
if row < 0 or col < 0 or\
row >= len(self.rows) or col >= len(self.cols):
raise ValueError('Invalid indices')
raise ValueError('Invalid indices %d,%d' % (row, col))
return self.rows[row][col]
def setCellCSSClass(row, col, value):
def setCellCSSClass(self, row, col, value):
if row < 0 or col < 0 or\
row >= len(self.rows) or col >= len(self.cols):
raise ValueError('Invalid indices')
raise ValueError('Invalid indices %d,%d' % (row, col))
self.rows_cssclasses[row][col] = value
def setRowCSSClass(row, value):
def getCellCSSClass(self, row, col):
if row < 0 or col < 0 or\
row >= len(self.rows) or col >= len(self.cols):
raise ValueError('Invalid indices %d,%d' % (row, col))
return self.rows_cssclasses[row][col]
def getColCSSClass(self, col):
if col < 0 or col >= len(self.cols):
raise ValueError('Invalid indice %d' % (col))
return self.cols_cssclasses[col]
def setRowCSSClass(self, row, value):
if row < 0 or row >= len(self.rows):
raise ValueError('Invalid indice')
raise ValueError('Invalid indice %d' % (row))
for i in range(0, self.rows_cssclasses[row]):
self.rows_cssclasses[row][i] = value
def setColCSSClass(self, col, value):
if col < 0 or col >= len(self.cols):
raise ValueError('Invalid indice %d' % (col))
self.cols_cssclasses[col] = value
def setColsCSSClass(self, values):
if len(values) != len(self.cols):
raise ValueError('Invalid values size')
self.cols_cssclasses = values
def build(self, f):
if not self.html:
html = '<table>'
html += '<tr>'
for title in self.cols:
html += '<th>%s</th>' % (title)
html += '</tr>'
for row in self.rows:
if self.cols:
html += '<tr>'
for v in row:
html += '<td>%s</td>' % (v)
for i in range (0, len(self.cols)):
title = self.cols[i]
style = self.getColCSSClass(i)
if style: style = ' class="%s"' % (style)
html += '<th%s>%s</th>' % (style, title)
html += '</tr>'
for i in range(0, len(self.rows)):
row = self.rows[i]
html += '<tr>'
for j in range(0, len(row)):
v = row[j]
style = self.getCellCSSClass(i, j)
if style: style = ' class="%s"' % (style)
html += '<td%s>%s</td>' % (style, v)
html += '</tr>'
html += '</table>'
self.html = html