Introduce _buildHTML() and DisplayHTMLBlockTableWithGraph class in display.py
This commit is contained in:
parent
5d6362105b
commit
2846394dad
66
display.py
66
display.py
|
@ -8,11 +8,15 @@ class DisplayHTMLRaw(object):
|
||||||
def setRawHTML(self, html):
|
def setRawHTML(self, html):
|
||||||
self.html = html
|
self.html = html
|
||||||
|
|
||||||
|
def _buildHTML(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def _build(self, f, html):
|
def _build(self, f, html):
|
||||||
if html: f.write(html)
|
if html: f.write(html)
|
||||||
|
|
||||||
def build(self, f):
|
def build(self, f):
|
||||||
self._build(self.html)
|
self._buildHTML()
|
||||||
|
self._build(f, self.html)
|
||||||
|
|
||||||
class DisplayHTMLBlock(DisplayHTMLRaw):
|
class DisplayHTMLBlock(DisplayHTMLRaw):
|
||||||
|
|
||||||
|
@ -38,14 +42,14 @@ class DisplayHTMLBlock(DisplayHTMLRaw):
|
||||||
def setValueCSSClass(self, cssclass):
|
def setValueCSSClass(self, cssclass):
|
||||||
self.value_cssclass = cssclass
|
self.value_cssclass = cssclass
|
||||||
|
|
||||||
def build(self, f):
|
def _buildHTML(self):
|
||||||
html = '<div class="%s">' % (self.cssclass)
|
html = '<div class="%s">' % (self.cssclass)
|
||||||
if self.title:
|
if self.title:
|
||||||
html += '<div class="%s">%s</div>' % (self.title_cssclass, self.title)
|
html += '<div class="%s">%s</div>' % (self.title_cssclass, self.title)
|
||||||
html += '<div class="%s">%s</div>' % (self.value_cssclass, self.html)
|
html += '<div class="%s">%s</div>' % (self.value_cssclass, self.html)
|
||||||
html += '</div>'
|
html += '</div>'
|
||||||
|
|
||||||
self._build(f, html)
|
self.html = html
|
||||||
|
|
||||||
class DisplayHTMLBlockTable(DisplayHTMLBlock):
|
class DisplayHTMLBlockTable(DisplayHTMLBlock):
|
||||||
|
|
||||||
|
@ -113,30 +117,40 @@ class DisplayHTMLBlockTable(DisplayHTMLBlock):
|
||||||
|
|
||||||
self.cols_cssclasses = values
|
self.cols_cssclasses = values
|
||||||
|
|
||||||
def build(self, f):
|
def _buildHTML(self):
|
||||||
if not self.html:
|
html = '<table>'
|
||||||
html = '<table>'
|
if self.cols:
|
||||||
if self.cols:
|
html += '<tr>'
|
||||||
html += '<tr>'
|
for i in range (0, len(self.cols)):
|
||||||
for i in range (0, len(self.cols)):
|
title = self.cols[i]
|
||||||
title = self.cols[i]
|
style = self.getColCSSClass(i)
|
||||||
style = self.getColCSSClass(i)
|
if style: style = ' class="%s"' % (style)
|
||||||
if style: style = ' class="%s"' % (style)
|
html += '<th%s>%s</th>' % (style, title)
|
||||||
html += '<th%s>%s</th>' % (style, title)
|
html += '</tr>'
|
||||||
html += '</tr>'
|
for i in range(0, len(self.rows)):
|
||||||
for i in range(0, len(self.rows)):
|
row = self.rows[i]
|
||||||
row = self.rows[i]
|
html += '<tr>'
|
||||||
html += '<tr>'
|
for j in range(0, len(row)):
|
||||||
for j in range(0, len(row)):
|
v = row[j]
|
||||||
v = row[j]
|
style = self.getCellCSSClass(i, j)
|
||||||
style = self.getCellCSSClass(i, j)
|
if style: style = ' class="%s"' % (style)
|
||||||
if style: style = ' class="%s"' % (style)
|
html += '<td%s>%s</td>' % (style, v)
|
||||||
html += '<td%s>%s</td>' % (style, v)
|
html += '</tr>'
|
||||||
html += '</tr>'
|
html += '</table>'
|
||||||
html += '</table>'
|
|
||||||
self.html = html
|
|
||||||
|
|
||||||
super(DisplayHTMLBlockTable, self).build(f)
|
self.html = html
|
||||||
|
|
||||||
|
super(DisplayHTMLBlockTable, self)._buildHTML()
|
||||||
|
|
||||||
|
class DisplayHTMLBlockTableWithGraph(DisplayHTMLBlockTable):
|
||||||
|
|
||||||
|
def __init__(self, title, cols, short_title, nb_valid_rows=0):
|
||||||
|
super(DisplayHTMLBlockTableWithGraph, self).__init__(title=title, cols=cols)
|
||||||
|
self.short_title = short_title
|
||||||
|
self.nb_valid_rows = nb_valid_rows
|
||||||
|
|
||||||
|
def setNbValidRows(self, nb_valid_rows):
|
||||||
|
self.nb_valid_rows = nb_valid_rows
|
||||||
|
|
||||||
class DisplayHTMLPage(object):
|
class DisplayHTMLPage(object):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user