Belle II Software light-2406-ragdoll
StatisticsViewer Class Reference
Inheritance diagram for StatisticsViewer:
Collaboration diagram for StatisticsViewer:

Public Member Functions

def __init__ (self, statistics)
 
def create (self)
 

Public Attributes

 statistics
 The statistics we want to show.
 
 table_column_html
 Template for a table cell.
 
 table_column_3_html
 Template for a table cell spanning 3 columns.
 
 table_cell_html
 Template for a table cell with left alignment.
 
 table_cell_3_html
 Template for a table cell with 3 columns.
 

Detailed Description

A viewer widget for displaying the
statistics in a nicer way in ipython

Definition at line 190 of file viewer.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  statistics 
)
 Init the widget with the statistics from the process.
The statistics must be an instance of Statistics. 

Definition at line 196 of file viewer.py.

196 def __init__(self, statistics):
197 """ Init the widget with the statistics from the process.
198 The statistics must be an instance of Statistics. """
199
200 self.statistics = statistics
201
202
203 self.table_column_html = """<td style="padding: 10px;">{content}</td>"""
204
205 self.table_column_3_html = """<td colspan="3" style="padding: 10px;">{content}</td>"""
206
207 self.table_cell_html = """<td style="padding: 10px; text-align: left">{content}</td>"""
208
209 self.table_cell_3_html = """<td style=\"text-align: right\">{content[0]}</td><td>{content[1]}</td><td>{content[2]}</td>"""
210

Member Function Documentation

◆ create()

def create (   self)
Create the widget

Reimplemented from IPythonWidget.

Definition at line 211 of file viewer.py.

211 def create(self):
212 """
213 Create the widget
214 """
215 import ipywidgets as widgets
216
217 if self.statistics is None:
218 return widgets.HTML("")
219
220 html = widgets.HTML()
221 html.value = """<table style="border-collapse: collapsed; border: 1px solid black;">
222 <thead><tr style="background: #AAA; font-weight: bold">"""
223
224 for column in self.statistics.columns:
225 if column.three_column_format:
226 html.value += self.table_column_3_html.format(content=column.display_name)
227 else:
228 html.value += self.table_column_html.format(content=column.display_name)
229 html.value += "</tr></thead><tbody>"
230
231 for n, module in enumerate(self.statistics.modules):
232 if n % 2 == 1:
233 html.value += """<tr style="background: #EEE;">"""
234 else:
235 html.value += """<tr>"""
236
237 for column in self.statistics.columns:
238 if column.three_column_format:
239 html.value += self.table_cell_3_html.format(content=module[column.name])
240 else:
241 html.value += self.table_cell_html.format(content=module[column.name])
242
243 html.value += "</tr>"
244
245 # SUMMARY html.value += """<tr style="border: 1px solid black; font-weight: bold">"""
246
247 html.value += "</tbody></table>"
248 html.margin = "10px"
249 return html
250
251

Member Data Documentation

◆ statistics

statistics

The statistics we want to show.

Definition at line 200 of file viewer.py.

◆ table_cell_3_html

table_cell_3_html

Template for a table cell with 3 columns.

Definition at line 209 of file viewer.py.

◆ table_cell_html

table_cell_html

Template for a table cell with left alignment.

Definition at line 207 of file viewer.py.

◆ table_column_3_html

table_column_3_html

Template for a table cell spanning 3 columns.

Definition at line 205 of file viewer.py.

◆ table_column_html

table_column_html

Template for a table cell.

Definition at line 203 of file viewer.py.


The documentation for this class was generated from the following file: