def display_map() -> None: table = html.TABLE(style={"border": "1 solid grey"}) table <= html.TR(html.TH("Text") + html.TH("Base64")) table <= (html.TR(html.TD(key) + html.TD(b64_map[key])) for key in b64_map) base64_display = document["b64-display"] base64_display.clear() base64_display <= table
def display_map(): table = html.TABLE(Class="pure-table") table <= html.THEAD(html.TR(html.TH("Text") + html.TH("Base64"))) table <= (html.TR(html.TD(key) + html.TD(b64_map[key])) for key in b64_map) base64_display = document["b64-display"] base64_display.clear() base64_display <= table document["text-src"].value = ""
def load(sheet_name=None): global current_cell_info, menu_file if sheet_name is None: sheet_name = 'New document' panel = document['panel'] title = html.DIV(style=dict(width='auto')) title <= html.H2(sheet_name, id="sheet_name") panel <= title menu = ui.Menu() menu_file = menu.add('File') menu_file.add('New', None) menu_file.add('Open...', select_sheet) menu_file.add('Save as...', save_as) panel <= html.SPAN(menu) panel <= html.BR() cell_editor = html.INPUT(style=dict(width="200px"), Id="current") cell_editor.bind('click', enter_editor) cell_editor.bind('keydown', editor_keydown) cell_editor.bind('keyup', update_from_editor) panel <= cell_editor t = html.TABLE(Id="sheet_table") srow = -1 rows, cols = 20, 20 col_widths = [100 for i in range(rows)] line = html.TR() line <= html.TH() for i in range(cols): col_name = chr(65 + i) line <= html.TH(col_name, style={'min-width': '%spx' % col_widths[i]}) t <= line for i in range(rows * cols): row, column = divmod(i, cols) if row > srow: line = html.TR() line <= html.TH(row + 1) t <= line srow = row cell = html.TD('', id='c%s_%s' % (row, column), style=dict(padding='2px')) cell.bind('click', select) cell.bind('dblclick', entry) cell.info = {'entry': ''} line <= cell panel <= html.DIV(t, style=dict(float='left')) mark_selected(t.get(selector='TD')[0])
def display_map(): if not hash_map: return table = html.TABLE(Class="pure-table") table <= html.THEAD(html.TR(html.TH("Text") + html.TH("SHA-256"))) table <= (html.TR(html.TD(key) + html.TD(hash_map[key])) for key in hash_map) hash_display = document["hash-display"] hash_display.clear() hash_display <= table document["text-src"].value = ""
def __init__(self): super().__init__("Data Table", "#fbd0d0", tabwidth="12%", id="datatable") lines = open("cost-of-living-2018.csv").readlines() data = [line.strip().split(",") for line in lines[:26]] self.attach(html.TABLE( html.TR(html.TH(header) for header in data[0]) + (html.TR(html.TD(field) for field in row) for row in data[1:]) ))
def on_complete(*args): doc['container'] <= html.PRE('Results are in milliseconds (ms)') doc['container'] <= html.PRE( 'Browser Version:%s' % window.navigator.userAgent) _v = sys.implementation.version doc['container'] <= html.PRE('Brython Version:%s.%s.%s' % (_v.major, _v.minor, _v.micro)) _table = html.TABLE() _tr = html.TR() _tr <= html.TH('Benchmark') _tr <= html.TH('Brython') _tr <= html.TH('CPython') _tr <= html.TH('Difference') _tr <= html.TH('X Faster') _table <= _tr for _filename in self._timings.keys(): _tr = html.TR() _tr <= html.TD(_filename) for _platform in ('brython', 'cpython'): _tr <= html.TD( '%5.0f' % self._timings[_filename][_platform], style={'text-align': 'right'}) _diff = self._timings[_filename]['cpython'] - self._timings[ _filename]['brython'] _x = self._timings[_filename]['cpython'] / self._timings[ _filename]['brython'] if _x > 1: _bg = "green" elif _x < 0.5: _bg = "red" else: _bg = "yellow" _tr <= html.TD('%5.0f' % _diff, style={'text-align': 'right'}) _tr <= html.TD('%4.2f' % _x, style={ 'background': _bg, 'text-align': 'right' }) _table <= _tr doc['container'] <= _table doc['container'] <= html.PRE("results uploaded...")
def run(self, test): "Run the given test case or test suite." t = html.TABLE(Id="report") t <= html.TR(html.TH(x, Class="header") for x in ('Test class', 'Method', 'Line', 'Duration (ms)', 'Result', 'Error message')) document["container"] <= t result = _TestResult(self.verbosity) test(result) self.stopTime = datetime.datetime.now()
def load(sheet_name=None): global current_cell_info, menu_file panel = document['panel'] cell_editor = html.DIV("A", style=dict(width="25%", padding="5px", marginBottom="20px", height="1.5em"), Id="current", contentEditable="true", Class="selected") cell_editor.bind('click', enter_editor) cell_editor.bind('keydown', editor_keydown) cell_editor.bind('keyup', update_from_editor) panel <= cell_editor t = html.TABLE(Id="sheet_table") srow = -1 rows, cols = 20, 20 col_widths = [100 for i in range(rows)] line = html.TR() line <= html.TH() for i in range(cols): col_name = chr(65 + i) line <= ColumnHead(col_name, Class="col-head", style={'min-width': '%spx' % col_widths[i]}) t <= line for i in range(rows * cols): row, column = divmod(i, cols) if row > srow: line = html.TR() line <= RowHead(row + 1, Class="row-head") t <= line srow = row cell = html.TD(contentEditable="true", style=dict(padding='2px')) cell.bind("click", select) cell.bind("focus", focus) cell.bind("keyup", keyup) cell.bind("blur", blur) cell.info = {'entry': ''} line <= cell panel <= html.DIV(t, style=dict(float='left')) for cell in document.get(selector="th.row-head"): cell.bind("mousedown", select_row) t.get(selector='TD')[0].dispatchEvent(window.MouseEvent.new("click"))
def run(self, test): "Run the given test case or test suite." b = html.BUTTON("Clique para voltar para o editor", Id="editor") b.onclick = self.back_editor t = html.TABLE(Id="report") t <= html.TR( html.TH(x, Class="header", style={"backgroundColor": "lightgrey"}) for x in ('Test class', 'Method', 'Line', 'T(ms)', 'Result', 'Error message')) document["container"].html = "" document["container"] <= b document["container"] <= t result = _TestResult(self.verbosity) test(result) self.stopTime = datetime.datetime.now()
def show_results(self): """ show table of results""" doc['container'].clear() doc['container'] <= html.DIV( 'Browser Version: %s' % window.navigator.userAgent) _v = sys.implementation.version doc['container'] <= html.DIV('Brython Version: %s.%s.%s' % (_v.major, _v.minor, _v.micro)) doc['container'] <= html.DIV( 'Brython debug mode: %s' % sys.brython_debug_mode) doc['container'] <= html.DIV( 'CPython Version: %s' % self.cpython_version) doc['container'] <= html.P(html.I('Results are in milliseconds (ms)')) _table = html.TABLE() _tr = html.TR() _tr <= html.TH('Benchmark') _tr <= html.TH('Code') _tr <= html.TH('Brython') _tr <= html.TH('CPython') _tr <= html.TH('Difference') _tr <= html.TH('X Faster') _table <= _tr for _filename in self._timings.keys(): _tr = html.TR() _tr <= html.TD(_filename) _tr <= html.TD( highlight.highlight(self._timings[_filename]['code'])) for _platform in ('brython', 'cpython'): _tr <= html.TD('%5.0f' % self._timings[_filename][_platform], style={'text-align': 'right'}) _diff = self._timings[_filename]['cpython'] - self._timings[ _filename]['brython'] _x = self._timings[_filename]['cpython'] / self._timings[ _filename]['brython'] if _x > 1: _color = "green" elif _x < 0.5: _color = "red" else: _color = "black" _tr <= html.TD('%5.0f' % _diff, style={'text-align': 'right'}) _tr <= html.TD('%4.2f' % _x, style={ 'color': _color, 'text-align': 'right' }) _table <= _tr doc['container'] <= _table
def code(): from browser import document, html # Construction de la calculatrice calc = html.TABLE() calc <= html.TR( html.TH(html.DIV("0", id="result"), colspan=3) + html.TD("C")) lines = ["789/", "456*", "123-", "0.=+"] calc <= (html.TR(html.TD(x) for x in line) for line in lines) document <= calc result = document["result"] # direct acces to an element by its id def action(event): """Handles the "click" event on a button of the calculator.""" # The element the user clicked on is the attribute "target" of the # event object element = event.target # The text printed on the button is the element's "text" attribute value = element.text if value not in "=C": # update the result zone if result.text in ["0", "error"]: result.text = value else: result.text = result.text + value elif value == "C": # reset result.text = "0" elif value == "=": # execute the formula in result zone try: result.text = eval(result.text) except: result.text = "error" # Associate function action() to the event "click" on all buttons for button in document.select("td"): button.bind("click", action)
def on_complete(req): r_json = json.loads(req.text) r_json = r_json['values'] # ** Filter for unrated levels ** # * setup list * result = [] i = 1 while i < len(r_json[4]): result.append(i) i += 1 # * filter for unrated demons * list = [] try: while True: check_list = result.pop(0) check_try = str(r_json[5][check_list]) if check_try == "unrated": list.append(check_list) # comparison check except: pass try: while True: result.append(list.pop(0)) except: pass # ** Listing results ** # * setup * table = html.TABLE('', id='unratedtable') recent = -1 try: i = -10 * int(page) except: i = 0 noresults = True totalresults = len(result) totalpages = ceiling(totalresults / 10) # * first row * table <= html.TR( html.TH("Name", Class="filtersth", colspan="2") + html.TH("Creator", Class="filtersth", colspan="2") + html.TH("ID", Class="filtersth", colspan="2")) # * item rows * try: while True: resultpop = result.pop(recent) entryname = (r_json[0][resultpop]) entrycreator = (r_json[1][resultpop]) id_url = "https://gdladder.tk/levels.html?id=" + r_json[4][ resultpop] entryid = html.A(r_json[4][resultpop], href=id_url) table <= html.TR( html.TD(entryname, Class="filterstd", colspan="2") + html.TD(entrycreator, Class="filterstd", colspan="2") + html.TD(entryid, Class="filterstd", colspan="2")) i += 1 noresults = False except: pass document['unratedresults'] <= table if noresults: document['unratedstats'] <= 'No unrated demons, yay!' else: document['unratedstats'] <= str(totalresults) + ' levels unrated'
def on_complete(req): r_json = json.loads(req.text) r_json = r_json['values'] errorcount = 0 # ** 'Ask' for filters ** try: tiermin = str(document.query['tiermin']) except: tiermin = '' errorcount += 1 try: tiermax = str(document.query['tiermax']) except: tiermax = '' errorcount += 1 try: official_diff = str(document.query['official_diff']) except: official_diff = '' errorcount += 1 try: name = str(document.query['name']) name = changeWord(name) except: name = '' errorcount += 1 try: if str(document.query['sort']) == 'recent': sort = "recent" recent = 1 elif str(document.query['sort']) == 'byid': sort = "byid" recent = 0 elif str(document.query['sort']) == 'random': sort = "random" recent = 0 else: raise Exception("Unknown parameter") except: sort = "byid" recent = 0 errorcount += 1 try: page = str(document.query['page']) except: page = 0 errorcount += 1 try: if str(document.query['reference']) == 'on': reference = 1 else: reference = 0 except: reference = 0 errorcount += 1 if errorcount == filterno: return # * querystring construction * querystring = "?" if tiermin != '': querystring += ("tiermin=" + tiermin + "&") if tiermax != '': querystring += ("tiermax=" + tiermax + "&") if official_diff != '': querystring += ("official_diff=" + official_diff + "&") if name != '': querystring += ("name=" + name + "&") if sort != '': querystring += ("sort=" + sort + "&") if reference == 1: querystring += ("reference=on&") querystring = querystring[0:-1] if querystring == "": querystring = "?" # ** Filter for levels ** # * setup list * result = [] i = 1 while i < len(r_json[4]): result.append(i) i += 1 # * Minimum tier * if tiermin != '': try: tiermin = int(tiermin) except: tiermin = float(tiermin) list = [] try: while True: check_list = result.pop(0) if isinstance(tiermin, int): try: check_try = int(r_json[5][check_list]) except: check_try = 0 elif isinstance(tiermin, float): try: check_try = float(r_json[6][check_list]) except: check_try = 0.0 if tiermin <= check_try: list.append(check_list) # comparison check except: pass try: while True: result.append(list.pop(0)) except: pass # * Maximum tier * if tiermax != '': try: tiermax = int(tiermax) except: tiermax = float(tiermax) list = [] try: while True: check_list = result.pop(0) if isinstance(tiermax, int): try: check_try = int(r_json[5][check_list]) except: check_try = 0 elif isinstance(tiermax, float): try: check_try = float(r_json[6][check_list]) except: check_try = 0.0 if tiermax >= check_try: list.append(check_list) # comparison check except: pass try: while True: result.append(list.pop(0)) except: pass # * Official difficulty * if official_diff != '': official_diff = int(official_diff) list = [] try: while True: check_list = result.pop(0) try: check_try = (r_json[3][check_list]) if check_try == 'Official Level': check_try = 0 elif check_try == 'Easy Demon': check_try = 1 elif check_try == 'Medium Demon': check_try = 2 elif check_try == 'Hard Demon': check_try = 3 elif check_try == 'Insane Demon': check_try = 4 elif check_try == 'Extreme Demon': check_try = 5 except: check_try = -1 if official_diff == check_try: list.append(check_list) # comparison check except: pass try: while True: result.append(list.pop(0)) except: pass # * Level name * if name != '': name = name.lower() list = [] try: while True: check_list = result.pop(0) try: check_try = r_json[0][check_list].lower() except: check_try = '' if name in check_try: list.append(check_list) # comparison check except: pass try: while True: result.append(list.pop(0)) except: pass # ** Listing results ** # * shuffle list if needed * if sort == "random": random.shuffle(result) # * setup * table = html.TABLE('', id='centertable') try: recent = -1 * int(recent) except: recent = 0 try: i = -10 * int(page) except: i = 0 noresults = True totalresults = len(result) totalpages = ceiling(totalresults / 10) # * first row * table <= html.TR( html.TH("Name", Class="filtersth", colspan="2") + html.TH("Creator", Class="filtersth", colspan="2") + html.TH("ID", Class="filtersth", colspan="2") + html.TH("Tier", Class="filtersth", colspan="2")) # * item rows * try: while True: resultpop = result.pop(recent) if i >= 10: break elif i >= 0: noresults = False entryname = (r_json[0][resultpop]) entrycreator = (r_json[1][resultpop]) id_url = "https://gdladder.tk/levels.html?id=" + r_json[4][ resultpop] entryid = html.A(r_json[4][resultpop], href=id_url) if str(r_json[5][resultpop]) == "unrated": entrytier = "N/A" else: entrytier = str(r_json[5][resultpop]) + " (" + str( r_json[6][resultpop]) + ")" table <= html.TR( html.TD(entryname, Class="filterstd", colspan="2") + html.TD(entrycreator, Class="filterstd", colspan="2") + html.TD(entryid, Class="filterstd", colspan="2") + html.TD(entrytier, Class="filterstd", colspan="2")) i += 1 except: pass document['filtersresults'] <= table # * last row * lastpage = int(page) - 1 lastpageurl = "filters.html" + querystring + "&page=" + str(lastpage) nextpage = int(page) + 1 nextpageurl = "filters.html" + querystring + "&page=" + str(nextpage) if (int(page) != 0) and (sort != "random"): lastpage = html.A(html.BUTTON("Last page", Class="fillcell"), href=lastpageurl) else: lastpage = "" if (int(page) != (int(totalpages) - 1)) and (sort != "random"): nextpage = html.A(html.BUTTON("Next page", Class="fillcell"), href=nextpageurl) else: nextpage = "" table <= html.TR( html.TD(lastpage, Class="filtersth", colspan=colno) + html.TD(nextpage, Class="filtersth", colspan=colno)) if noresults: document['searchstats'] <= 'No results.' elif sort == "random": document['searchstats'] <= str( totalresults ) + ' levels found but only 10 random results are shown.' else: document['searchstats'] <= str( totalresults) + ' levels found shown in ' + str( totalpages) + ' pages'
grid.setpos((-LENGTH / 2 + i) - OFFSET, -LENGTH / 2 - OFFSET) grid.penup() turtle.update() # turtle.exitonclick() t = turtle.Turtle() t.shape("turtle") t.pendown() myTurtle.drawTurtle() container <= turtleDiv # 寶貝圖鑑列表 container <= html.DIV( html.H2('寶貝圖鑑列表'), Class="w3-container w3-blue w3-margin-top") table = html.TABLE(Class="w3-table-all") table <= html.TR(html.TH('序號') + html.TH('中文名') + html.TH('最大CP') + html.TH('屬性')) lines = [ [1, '妙蛙種子', '1115', '草、毒'], [2, '妙蛙草', '1699', '草、毒'], [3, '妙蛙花', '2720', '草、毒'], [4, '小火龍', '980', '火'], ] for line in lines: table <= html.TR( html.TD(line[0]) + html.TD(line[1]) + html.TD(line[2]) + html.TD(line[3])) container <= table # 寶貝圖鑑輸入表 container <= html.DIV(html.H2('寶貝圖鑑輸入表'), Class="w3-container w3-blue w3-margin-top")
from browser import document, alert, html calc = html.TABLE() calc <= html.TR(html.TH(html.DIV("0", id="result"), colspan=3) + html.TD("C")) lines = ["789/", "456*", "123-", "0.=+"] calc <= (html.TR(html.TD(x) for x in line) for line in lines) document <= calc result = document["result"] # direct acces to an element by its id def action(event): """Handles the "click" event on a button of the calculator.""" # The element the user clicked on is the attribute "target" of the # event object element = event.target # The text printed on the button is the element's "text" attribute value = element.text print("11") if value not in "=C": # update the result zone if result.text in ["0", "error"]: result.text = value else: result.text = result.text + value elif value == "C": # reset result.text = "0" elif value == "=": # execute the formula in result zone
def draw_home3(): dataset_list_table = html.TABLE(cellspacing=0, border=1, bordercolor="lightgray", id="dataset_list_table") tableBody = html.TBODY() headers = html.TR() tableBody.style.border = "thin solid lightgray" # to clear list, do this: del left_table_rows [:] dataset_list_table_rows = [] link = html.A('\u2191\u2193', href="#", Class="sort_link") link.bind( 'click', lambda ev: sort_by_col(ev, headers, dataset_list_table_rows, tableBody, False)) link_num = html.A('\u2191\u2193', href="#", Class="sort_link") link_num.bind( 'click', lambda ev: sort_by_col(ev, headers, dataset_list_table_rows, tableBody, True)) hD = html.TH('Dataset ID' + link) hP = html.TH('PubMed ID' + link.clone()) hList = [hD, hP] for h in hList: h.style.background = "#E0E0E0" h.style.font = "16px verdana" h = None headers <= hList for i in range(0): row = html.TR() button = html.BUTTON("GDS123" + str(i), row=str(i), gds="GDS123") button.style.font = "16px verdana" #button.style.textAlign = "center" button.value = "GDS123" + str(i) button.bind('mouseout', mouse_out_button) button.bind('mouseover', mouse_over_button) button.bind('click', click_dataset_id_button) button.style.border = "thin solid gray" button.style.background = "#EEEEEE" button.style.color = "#505050" td1 = html.TD(button) td1.style.textAlign = "center" td2 = html.TD( html.A("7896544" + str(10 - i), href="http://www.ncbi.nlm.nih.gov/pubmed/?term=17262812", target="_blank")) td2.style.textAlign = "center" tdList = [td1, td2] if (i % 2 == 1): for td in tdList: td.style.background = "#F7F7F7" row <= tdList dataset_list_table_rows.append(row) tableBody <= headers tableBody <= dataset_list_table_rows dataset_list_table <= tableBody dataset_list_table.style.font = "16px verdana" dataset_list_table.style.color = "#303030" panel = document["main_panel"] #panel <= dataset_list_table ################################### pvaluesTable = html.TABLE(cellspacing=0, border=1, bordercolor="lightgray", id="pvalue_list_table") pvaluesTable.width = 985 pvaluesTableBody = html.TBODY() pvaluesTableHeaders = html.TR() pvaluesTableBody.style.border = "thin solid lightgray" # to clear list, do this: del left_table_rows [:] pvaluesTableRows = [] pvaluesLink = html.A('\u2191\u2193', href="#", Class="sort_link") pvaluesLink.bind( 'click', lambda ev: sort_by_col(ev, pvaluesTableHeaders, pvaluesTableRows, pvaluesTableBody, False)) pvaluesLinkNum = html.A('\u2191\u2193', href="#", Class="sort_link") pvaluesLinkNum.bind( 'click', lambda ev: sort_by_col( ev, pvaluesTableHeaders, pvaluesTableRows, pvaluesTableBody, True)) h1 = html.TH('Dataset ID' + pvaluesLink) h2 = html.TH('Sample1' + pvaluesLink.clone()) h3 = html.TH('Size1' + pvaluesLinkNum) h4 = html.TH('Sample2' + pvaluesLink.clone()) h5 = html.TH('Size2' + pvaluesLinkNum.clone()) h6 = html.TH('Gene' + pvaluesLink.clone()) h7 = html.TH('Probe' + pvaluesLink.clone()) h8 = html.TH('P-value x1E6' + pvaluesLinkNum.clone()) h9 = html.TH('T-stat' + pvaluesLinkNum.clone()) pvaluesHeadersList = [h1, h2, h3, h4, h5, h6, h7, h8, h9] for h in pvaluesHeadersList: h.style.background = "#E0E0E0" h.style.font = "16px verdana" pvaluesTableHeaders <= pvaluesHeadersList pvaluesTableBody <= pvaluesTableHeaders pvaluesTableBody <= pvaluesTableRows pvaluesTable <= pvaluesTableBody pvaluesTable.style.font = "16px verdana" pvaluesTable.style.color = "#303030" div1 = html.DIV() div1.style.overflow = "scroll" div1.height = 300 div1.width = 250 div1 <= dataset_list_table div2 = html.DIV() div2.style.overflow = "scroll" div2.height = 300 div2.width = 1000 div2 <= pvaluesTable doubleTable = html.TABLE() doubleTableBody = html.TBODY() downloadFilesRow = html.TR() doubleTableRow = html.TR() tdLeft = html.TD() tdLeft <= div1 tdLeft.style.padding = "0px 20px 0px 0px" tdRight = html.TD() tdRight <= div2 tdDownloadLeft = html.TD() tdDownloadRight = html.TD() aLeft = html.A('<img src="download_icon.jpg" height=20 width=20> Download', id='aLeft') aLeft.style.font = "16px verdana" aLeft.style.color = "#303030" tdDownloadLeft <= aLeft aRight = html.A( '<img src="download_icon.jpg" height=20 width=20> Download', id='aRight') aRight.style.font = "16px verdana" aRight.style.color = "#303030" tdDownloadRight <= aRight downloadFilesRow <= [tdDownloadLeft, tdDownloadRight] doubleTableRow <= [tdLeft, tdRight] doubleTableBody <= downloadFilesRow doubleTableBody <= doubleTableRow doubleTable <= doubleTableBody panel <= doubleTable
def setup_dataset_list_table(dataPairs, output_file): aLeft = document["aLeft"] aLeft.href = output_file table = document["dataset_list_table"] for child in table: table.remove(child) tableBody = html.TBODY() headers = html.TR() tableBody.style.border = "thin solid lightgray" # to clear list, do this: del left_table_rows [:] dataset_list_table_rows = [] link = html.A('\u2191\u2193', href="#", Class="sort_link") link.bind( 'click', lambda ev: sort_by_col(ev, headers, dataset_list_table_rows, tableBody, False)) link_num = html.A('\u2191\u2193', href="#", Class="sort_link") link_num.bind( 'click', lambda ev: sort_by_col(ev, headers, dataset_list_table_rows, tableBody, True)) hD = html.TH('Dataset ID' + link) hP = html.TH('PubMed ID' + link.clone()) hList = [hD, hP] for h in hList: h.style.background = "#E0E0E0" h.style.font = "16px verdana" h = None headers <= hList for i in range(len(dataPairs)): pair = dataPairs[i] datasetId = pair['dataset_id'] pubmedId = pair['pubmed_id'] row = html.TR() button = html.BUTTON(datasetId, gds=datasetId) button.style.font = "16px verdana" button.value = datasetId button.bind('mouseout', mouse_out_button) button.bind('mouseover', mouse_over_button) button.bind('click', click_dataset_id_button) button.style.border = "thin solid gray" button.style.background = "#EEEEEE" button.style.color = "#505050" td1 = html.TD(button) td1.style.textAlign = "center" button.style.width = "100px" td2 = html.TD( html.A(pubmedId, href="http://www.ncbi.nlm.nih.gov/pubmed/?term=" + pubmedId, target="_blank")) td2.style.textAlign = "center" tdList = [td1, td2] if (i % 2 == 1): for td in tdList: td.style.background = "#F7F7F7" row <= tdList dataset_list_table_rows.append(row) tableBody <= headers tableBody <= dataset_list_table_rows table <= tableBody
def setup_pvalue_list_table(dataPairs, output_file): aRight = document["aRight"] aRight.href = output_file pvaluesTable = document["pvalue_list_table"] for child in pvaluesTable: pvaluesTable.remove(child) pvaluesTableBody = html.TBODY() pvaluesTableHeaders = html.TR() pvaluesTableBody.style.border = "thin solid lightgray" # to clear list, do this: del left_table_rows [:] pvaluesTableRows = [] pvaluesLink = html.A('\u2191\u2193', href="#", Class="sort_link") pvaluesLink.bind( 'click', lambda ev: sort_by_col(ev, pvaluesTableHeaders, pvaluesTableRows, pvaluesTableBody, False)) pvaluesLinkNum = html.A('\u2191\u2193', href="#", Class="sort_link") pvaluesLinkNum.bind( 'click', lambda ev: sort_by_col( ev, pvaluesTableHeaders, pvaluesTableRows, pvaluesTableBody, True)) h1 = html.TH('Dataset ID' + pvaluesLink) h2 = html.TH('Sample1' + pvaluesLink.clone()) h3 = html.TH('Size1' + pvaluesLinkNum) h4 = html.TH('Sample2' + pvaluesLink.clone()) h5 = html.TH('Size2' + pvaluesLinkNum.clone()) h6 = html.TH('Gene' + pvaluesLink.clone()) h7 = html.TH('Probe' + pvaluesLink.clone()) h8 = html.TH('P-value x1E6' + pvaluesLinkNum.clone()) h9 = html.TH('T-stat' + pvaluesLinkNum.clone()) pvaluesHeadersList = [h1, h2, h3, h4, h5, h6, h7, h8, h9] for h in pvaluesHeadersList: h.style.background = "#E0E0E0" h.style.font = "16px verdana" pvaluesTableHeaders <= pvaluesHeadersList for i in range(len(dataPairs)): pair = dataPairs[i] td1 = html.TD(pair["dataset_id"]) td2 = html.TD(pair["sample_1"]) td3 = html.TD(pair["sample_1_size"]) td4 = html.TD(pair["sample_2"]) td5 = html.TD(pair["sample_2_size"]) td6 = html.TD(pair["gene"]) td7 = html.TD(pair["probe"]) td8 = html.TD(str(round(float(pair["pvalue"]), 2))) td9 = html.TD(str(round(float(pair["tstat"]), 2))) tdList = [td1, td2, td3, td4, td5, td6, td7, td8, td9] if (i % 2 == 1): for td in tdList: td.style.background = "#F7F7F7" row = html.TR() row <= tdList pvaluesTableRows.append(row) pvaluesTableBody <= pvaluesTableHeaders pvaluesTableBody <= pvaluesTableRows pvaluesTable <= pvaluesTableBody