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 display_map() -> None: 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 make_numbers(): t = html.TABLE() tb = html.TBODY() t <= tb i = 1 val = "" for row in range(5): line = html.TR() tb <= line for column in range(10): b = html.BUTTON(str(i), id="x%s" % i, Class="nobutton") cell = html.TD(b) b.bind("click", on_number_button_pressed) line <= cell i += 1 return t
def setup_top_panel(): top_panel = document["about_panel"] table = html.TABLE() tableBody = html.TBODY() row = html.TR() # html style properties: # http://www.w3schools.com/jsref/dom_obj_style.asp global buttonHome buttonHome = html.BUTTON('Data Analysis') button_style_default(buttonHome) buttonHome.bind('click', click_home) buttonHome.bind('mouseout', mouse_out_home) buttonHome.bind('mouseover', mouse_over_home) global buttonAbout buttonAbout = html.BUTTON('About') button_style_default(buttonAbout) buttonAbout.bind('click', click_about) buttonAbout.bind('mouseout', mouse_out_about) buttonAbout.bind('mouseover', mouse_over_about) global buttonGuide buttonGuide = html.BUTTON('User Guide') button_style_default(buttonGuide) buttonGuide.bind('click', click_guide) buttonGuide.bind('mouseout', mouse_out_guide) buttonGuide.bind('mouseover', mouse_over_guide) global buttonContact buttonContact = html.BUTTON('Contact') button_style_default(buttonContact) buttonContact.bind('click', click_contact) buttonContact.bind('mouseout', mouse_out_contact) buttonContact.bind('mouseover', mouse_over_contact) row <= html.IMG(src="genexpresso.png", width="100") row <= buttonHome row <= buttonGuide row <= buttonAbout row <= buttonContact tableBody <= row table <= tableBody top_panel <= table
def draw(self, parent_node): self.node = html.DIV(Class="task", Id=self.id, draggable=True) self.node.style.backgroundColor = DB["TASKS_COLORS"][self.color] parent_node <= self.node self.zprogress = html.DIV(Class="task_progress") self.progress_text = html.P("%d" % self.progress + "%", Class="task_progress_text") self.zprogress <= self.progress_text self.progress_bar = html.DIV(Class="task_progress_bar") self.progress_bar.style.width = percent(self.progress) self.zprogress <= self.progress_bar self.command_delete = html.DIV("X", Class="task_command_delete") self.command = html.TABLE(html.TR( html.TD(self.zprogress, Class="task_command") + html.TD(self.command_delete)), Class="task_command") self.node <= self.command self.zdesc = html.P(Class="task_desc") self.node <= self.zdesc self.node.drop_id = self.id self.node.task = self self.node.bind('dragstart', self.drag_start) self.node.bind('dragover', self.drag_over) self.node.bind('drop', self.drag_drop) self.node.bind('click', self.color_change) self.zprogress.task = self self.zprogress.bind('click', self.make_progress) self.command_delete.task = self self.command_delete.bind('click', self.task_delete) self.zdesc.task = self self.zdesc.desc = self.desc self.zdesc.bind('click', self.task_edit) self.set_text() for task in self.tasks: task.draw(self.node)
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 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)] col_heads = html.TR() col_heads <= html.TH() for i in range(cols): col_name = chr(65 + i) col_heads <= ColumnHead(col_name, Class="col-head", style={'min-width': '%spx' % col_widths[i]}) t <= col_heads 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 line <= Cell(col_heads.children[column + 1]) panel <= html.DIV(t, style=dict(float='left')) t.get(selector='TD')[0].dispatchEvent(window.MouseEvent.new("click"))
def create_root(self): root = html.DIV() root <= html.DIV( html.B( f"Replicator - Un Ennemi du peuple ({version})")) + html.BR() table = html.TABLE() table <= html.TR( html.TD("1. Sélectionner le personnage", Id="char_sel_panel_title") + html.TD("2. Sélectionner la scène", Id="scene_sel_panel_title")) table <= html.TR( html.TD(self.create_character_selection_panel(), Id="char_sel_panel_td") + html. TD(self.create_scene_selection_panel(), Id="scene_sel_panel_td")) root <= table root <= html.HR() root <= html.DIV("3. Jouer", Id="start_game_panel_title") root <= html.DIV(self.create_start_game_panel(), Id="start_game_panel") return root
def make_grid(grid): # returns an HTML table with 9 rows and 9 columns global current_cell, gridDict t = html.TABLE(Class="grid") for i in range(grid_step): cg = html.COLGROUP() for j in range(grid_step): cg <= html.COL() t <= cg srow = -1 # for i,val in enumerate(grid): # row, column = divmod(i, boardSize) val = " " for row in range(board_size): for column in range(board_size): if row > srow: if row % grid_step == 0: tb = html.TBODY() t <= tb line = html.TR() tb <= line srow = row id = initCell(row + 1, column + 1) cell = html.DIV(val, id=id, Class="unused") cell.bind("mouseenter", on_mouse_enter) cell.bind("mouseleave", on_mouse_leave) cell.bind("click", on_grid_button_pressed) cell.style.contentEditable = True td = html.TD(id="td"+id) td <= cell if column % grid_step == 0: td.style.borderLeftWidth = "1px" if column == board_size - 1: td.style.borderRightWidth = "1px" line <= td current_cell = None print(t) return t
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 draw_task(self, task, parent_node): node = html.DIV(Class="task", Id=task.id, draggable=True) node.style.backgroundColor = self.kanban.tasks_colors[task.color_id] parent_node <= node progress = html.DIV(Class="task_progress") progress_text = html.P("%d%%" % task.progress, Class="task_progress_text") progress <= progress_text progress_bar = html.DIV(Class="task_progress_bar") progress_bar.style.width = percent(task.progress) progress <= progress_bar command_delete = html.DIV("X", Class="task_command_delete") command = html.TABLE(html.TR( html.TD(progress, Class="task_command") + html.TD(command_delete)), Class="task_command") node <= command desc = html.P(Id="desc %s" % task.id, Class="task_desc") desc.html = task.desc node <= desc node.bind('dragstart', ev_callback(self.drag_start, task)) node.bind('dragover', self.drag_over) node.bind('drop', ev_callback(self.drag_drop, task)) node.bind('click', ev_callback(self.change_task_color, task, node)) progress.progress_bar = progress_bar progress.progress_text = progress_text progress.bind('click', ev_callback(self.make_task_progress, task, progress)) command_delete.bind('click', ev_callback(self.remove_task, task)) desc.bind('click', ev_callback(self.edit_task, task)) self.draw_tasks(task, node)
def process_inventory(event): global inventory try: inventory = JSON.parse(event.target.result) fusedict = {} mooglelist = [u['tmrId'] for u in inventory if u['id'] == moogleid] containerlist = [u['tmrId'] for u in inventory if u['id'] == containerid if u['tmr'] <1000] ownedunits = [u['id'][:-1] for u in inventory if u['id'][0] != '9' if u['tmr'] <1000 ] for tmrId in mooglelist: tmrName = weapondict[tmrId]['name'] tmrUnit = weapondict[tmrId]['tmrUnit'] unitName = unitdict[tmrUnit]['name'] if tmrUnit[:-1] in ownedunits: if tmrId in fusedict.keys(): fusedict[tmrId]['count'] += 1 else: fusedict.update({tmrId:{'tmr':tmrName, 'unit':unitName, 'count':1, 'unitid':tmrUnit}}) if tmrId in containerlist: if tmrId in fusedict.keys(): fusedict[tmrId]['count'] += 1 else: fusedict.update({tmrId:{'tmr':tmrName, 'unit':containername[code], 'count':1, 'unitid':containerid}}) fusesort = sorted(fusedict.items(), key = lambda item: item[1]['tmr']) document['results'].clear() table = html.TABLE(Class='table table-hover') tbody = html.TBODY() table <= tbody for l in fusesort: tbody <= html.TR([html.TD(l[1]['tmr']), html.TD('\tx' + str(l[1]['count']) + '\t'), html.TD(l[1]['unit']), html.TD(html.IMG(src='https://ffbeequip.com/img/units/unit_icon_' + l[1]['unitid'] + '.png' ) )] ) document['results'] <= table except: alert('Error: Invalid file!') if 'ion-md-checkmark-circle' in filestatus.classList: filestatus.classList.remove('ion-md-checkmark-circle') filestatus.classList.add('ion-md-close-circle') elif 'ion-md-hourglass' in filestatus.classList: filestatus.classList.remove('ion-md-hourglass') filestatus.classList.add('ion-md-close-circle')
def make_grid(w, grid_size): t = html.TABLE(Class="ws") tb = html.TBODY() t <= tb for row in range(grid_size): wordline = w.grid[row] line = html.TR() tb <= line for column in range(grid_size): val = wordline[column] id = initCell(row + 1, column + 1) cell = html.TD(val, id=id, Class="ws") line <= cell cell.bind("mouseenter", on_mouse_enter) cell.bind("mouseleave", on_mouse_leave) cell.bind("click", on_grid_button_pressed) cell.bind("dblclick", dblclick) cell.style.contentEditable = True return t
def draw_home_title_description(): panel = document["main_panel"] table = html.TABLE() table.style.fontSize = "large" table.style.font = "16px verdana" tableBody = html.TBODY() row = html.TR() tableBody.style.verticalAlign = "center" row.style.verticalAlign = "center" table.style.background = "#F7F7F7" table.style.padding = "10px 10px 10px 10px" label = html.LABEL("Details for dataset:", id="label_details_for_dataset") label.style.verticalAlign = "center" label.style.marginRight = "10px" td1 = html.TD() td1 <= label td1.style.width = "200px" row <= td1 div2 = html.DIV() div2.style.overflow = "scroll" div2.height = 100 div2.width = 250 title_text_area = html.TEXTAREA("Title:", id="dataset_title") title_text_area.readOnly = True #title_text_area.disabled = True title_text_area.style.font = "14px verdana" title_text_area.rows = 10 title_text_area.cols = 26 div2 <= title_text_area td2 = html.TD() td2 <= div2 row <= td2 div3 = html.DIV() div3.style.overflow = "scroll" div3.height = 100 div3.width = 450 description_text_area = html.TEXTAREA("Description:", id="dataset_description") description_text_area.readOnly = True #description_text_area.disabled = True description_text_area.style.font = "14px verdana" description_text_area.rows = 10 description_text_area.cols = 51 div3 <= description_text_area td3 = html.TD() td3 <= div3 row <= td3 tableBody <= row table <= tableBody panel <= table panel <= html.BR()
def test_browser_html(): # First of all, the import of some libraries from browser import document from browser import html # All the elements will be inserted in the div with the "container" id container = document['container'] # We create a new div element newdiv = html.DIV(id="new-div") # Now we add some style newdiv.style = {"padding": "5px", "backgroundColor": "#ADD8E6"} # Now, lets add a table with a column with numbers and a # column with a word on each cell text = "Brython is really cool" textlist = text.split() table = html.TABLE() for i, word in enumerate(textlist): table <= html.TR(html.TD(i + 1) + html.TD(word)) # Now we add some style to the table table.style = { "padding": "5px", "backgroundColor": "#aaaaaa", "width": "100%" } # Now we add the table to the new div previously created newdiv <= table + html.BR() # a form? why not? form = html.FORM() input1 = html.INPUT(type="text", name="firstname", value="First name") input2 = html.INPUT(type="text", name="lastname", value="Last name") input3 = html.BUTTON("Button with no action!") form <= input1 + html.BR() + input2 + html.BR() + input3 newdiv <= form + html.BR() # Finally, we will add something more 'HTML5istic', a canvas with # a color gradient in the newdiv previously created and below the form canvas = html.CANVAS(width=300, height=300) canvas.style = {"width": "100%"} ctx = canvas.getContext('2d') ctx.rect(0, 0, 300, 300) grd = ctx.createRadialGradient(150, 150, 10, 150, 150, 150) grd.addColorStop(0, '#8ED6FF') grd.addColorStop(1, '#004CB3') ctx.fillStyle = grd ctx.fill() newdiv <= canvas # And finally we append the newdiv element # to the parent, in this case the div with the "container" id container <= newdiv """ browser.local_storage """ from browser.local_storage import storage storage['foo'] = 'bar' print(storage['foo']) del storage['foo'] with pytest.raises(KeyError): print(storage['foo']) # raises KeyError ## added exception handler
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'
def draw_home_samples(sample1, sample2): panel = document["main_panel"] table = html.TABLE() table.style.fontSize = "large" table.style.font = "16px verdana" tableBody = html.TBODY() row = html.TR() tableBody.style.verticalAlign = "center" row.style.verticalAlign = "center" table.style.background = "#F7F7F7" table.style.padding = "10px 25px 10px 10px" label = html.LABEL("Select samples to search:") label.style.verticalAlign = "center" label.style.marginRight = "10px" td1 = html.TD() td1 <= label row <= td1 #op11 = html.OPTION(sample1) #op12 = html.OPTION(sample2) #op21 = html.OPTION(sample1) #op22 = html.OPTION(sample2) sel1 = html.SELECT([], id="selector_samples_1", font_size=16) sel1.style.fontSize = "large" sel1.style.verticalAlign = "center" sel1.style.marginRight = "20px" sel1.style.width = "300px" td2 = html.TD() td2 <= sel1 row <= td2 sel2 = html.SELECT([], id="selector_samples_2", font_size=16) sel2.style.fontSize = "large" sel2.style.verticalAlign = "center" sel2.style.marginRight = "0px" sel2.style.width = "300px" td3 = html.TD() td3 <= sel2 row <= td3 b = html.BUTTON('Search', id="search_subsets") button_style_default(b) b.bind('click', click_search_subsets) b.bind('mouseout', mouse_out_search_subsets) b.bind('mouseover', mouse_over_search_subsets) b.style.verticalAlign = "center" b.style.marginTop = "0px" b.style.marginBottom = "0px" td4 = html.TD() td4.style.verticalAlign = "center" td4 <= b row <= td4 tableBody <= row table <= tableBody panel <= table panel <= html.BR()
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
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
# 自行建立 cont 區域 doc <= html.DIV(Id="cont") # All the elements will be inserted in the div with the "container" id container = doc['cont'] # We create a new div element newdiv = html.DIV(Id="new-div") # Now we add some style newdiv.style = {"padding": "5px", "backgroundColor": "#ADD8E6"} # Now, lets add a table with a column with numbers and a # column with a word on each cell text = "Brython is really cool" textlist = text.split() table = html.TABLE() for i, word in enumerate(textlist): table <= html.TR(html.TD(i + 1) + html.TD(word)) # Now we add some style to the table table.style = {"padding": "5px", "backgroundColor": "#aaaaaa", "width": "100%"} # Now we add the table to the new div previously created newdiv <= table + html.BR() # a form? why not? form = html.FORM() input1 = html.INPUT(type="text", name="firstname", value="First name") input2 = html.INPUT(type="text", name="lastname", value="Last name") input3 = html.BUTTON("Button with no action!") form <= input1 + html.BR() + input2 + html.BR() + input3 newdiv <= form + html.BR()
def draw_home2(): panel = document["main_panel"] table21 = html.TABLE() table21.style.fontSize = "large" table21.style.font = "16px verdana" tableBody21 = html.TBODY() #table22 = html.TABLE() #tableBody22 = html.TBODY() row21_1 = html.TR() #row21_2 = html.TR() table21.style.background = "#F7F7F7" table21.style.padding = "10px 25px 10px 10px" #table22.style.background = "#F7F7F7" #table22.style.padding = "10px 15px 10px 10px" label21 = html.LABEL("Search gene expressions by:") label21.style.verticalAlign = "center" label21.style.marginRight = "10px" td_1 = html.TD() td_1 <= label21 row21_1 <= td_1 op1 = html.OPTION("probe name") op2 = html.OPTION("gene name") sel2 = html.SELECT([op2, op1], id="select_probe_or_gene", font_size=16) sel2.style.fontSize = "large" sel2.style.verticalAlign = "center" sel2.style.marginRight = "20px" td_2 = html.TD() td_2 <= sel2 row21_1 <= td_2 inp21 = html.INPUT(id="input_probe_or_gene") inp21.style.verticalAlign = "center" inp21.style.marginRight = "0px" td_3 = html.TD() td_3 <= inp21 row21_1 <= td_3 global bSearch2 bSearch2 = html.BUTTON('Search') button_style_default(bSearch2) bSearch2.bind('click', click_search2) bSearch2.bind('mouseout', mouse_out_search2) bSearch2.bind('mouseover', mouse_over_search2) bSearch2.style.verticalAlign = "center" td_4 = html.TD() td_4 <= bSearch2 row21_1 <= td_4 #label22 = html.LABEL("Search gene expressions by gene name:") #label22.style.verticalAlign = "bottom" #label22.style.marginRight = "10px" #row21_2 <= label22 #inp22 = html.INPUT() #inp22.style.verticalAlign = "bottom" #inp22.style.marginRight = "0px" #row21_2 <= inp22 #global bSearch3 #bSearch3 = html.BUTTON('Search') #button_style_default(bSearch3) #bSearch3.bind('click', click_search3) #bSearch3.bind('mouseout', mouse_out_search3) #bSearch3.bind('mouseover', mouse_over_search3) #bSearch3.style.verticalAlign = "top" #row21_2 <= bSearch3 tableBody21 <= row21_1 #tableBody22 <= row21_2 table21 <= tableBody21 #table22 <= tableBody22 panel <= table21 panel <= html.BR() #panel <= table22 ############################################# table23 = html.TABLE() table23.style.font = "16px verdana" table23.style.background = "#F7F7F7" table23.style.padding = "20px 25px 20px 10px" tableBody23 = html.TBODY() row23_1 = html.TR() row23_2 = html.TR() row23_3 = html.TR() label23_1 = html.LABEL("Min sample size:") #label23_1.style.verticalAlign = "bottom" label23_1.style.marginRight = "10px" row23_1 <= label23_1 op21 = html.OPTION("5") op22 = html.OPTION("10") op23 = html.OPTION("15") op24 = html.OPTION("20") op25 = html.OPTION("25") sel23_1 = html.SELECT([op21, op22, op23, op24, op25], id="selector_min_sample_size", font_size=16) sel23_1.style.fontSize = "large" #sel23_1.style.verticalAlign = "bottom" sel23_1.style.marginRight = "50px" row23_1 <= sel23_1 #inp23_1 = html.INPUT() #inp23_1.style.verticalAlign = "bottom" #inp23_1.style.marginRight = "0px" #row23_1 <= inp23_1 label23_2 = html.LABEL("Max p-value:") label23_2.style.verticalAlign = "bottom" label23_2.style.marginRight = "10px" row23_1 <= label23_2 op31 = html.OPTION("1E-6") op32 = html.OPTION("1E-5") op33 = html.OPTION("1E-4") op34 = html.OPTION("1E-3") op35 = html.OPTION("0.005") op36 = html.OPTION("0.01") op37 = html.OPTION("0.02") op38 = html.OPTION("0.05") sel23_2 = html.SELECT([op38, op37, op36, op35, op34, op33, op32, op31], id="selector_max_pvalue", font_size=16) sel23_2.style.fontSize = "large" #sel23_1.style.verticalAlign = "bottom" sel23_2.style.marginRight = "50px" row23_1 <= sel23_2 #inp23_2 = html.INPUT() #inp23_2.style.verticalAlign = "bottom" #inp23_2.style.marginRight = "0px" #row23_1 <= inp23_2 label23_3 = html.LABEL("Max # results:") label23_3.style.verticalAlign = "bottom" label23_3.style.marginRight = "10px" row23_1 <= label23_3 op44 = html.OPTION("1000") op45 = html.OPTION("500") op46 = html.OPTION("300") op47 = html.OPTION("200") op48 = html.OPTION("100") sel23_3 = html.SELECT([op48, op47, op46, op45, op44], id="selector_max_num_results", font_size=16) sel23_3.style.fontSize = "large" #sel23_3.style.verticalAlign = "bottom" sel23_3.style.marginRight = "0px" row23_1 <= sel23_3 #inp23_3 = html.INPUT() #inp23_3.style.verticalAlign = "bottom" #inp23_3.style.marginRight = "0px" #row23_1 <= inp23_3 tableBody23 <= row23_1 #tableBody23 <= row23_2 #tableBody23 <= row23_3 table23 <= tableBody23 panel <= table23 panel <= html.BR()
def draw_home1(): panel = document["main_panel"] table0 = html.TABLE() tableBody0 = html.TBODY() row0 = html.TR() b21 = html.P(id="status_indicator") #b21.text = "READY" #b21.style.verticalAlign = "bottom" #b21.style.marginRight = "40px" #g21.style.background = "#3366FF" #g21.style.color = "#FFEE00" #b21.style.background = "#55FF55" #b21.style.width = "120px" #b21.style.textAlign = "center" #b21.style.padding = "10px 0px 10px 0px" #b21.style.font = "16px verdana" #b21.style.border = "thin solid green" td01 = html.TD() td01 <= b21 row0 <= td01 head = html.LABEL("GeneXpresso - analyze DNA microarray datasets") head.style.font = "30px verdana" head.style.textAlign = "center" td02 = html.TD() td02 <= head row0 <= td02 tableBody0 <= row0 table0 <= tableBody0 panel <= table0 panel <= html.BR() status_indicator_ready(0) table1 = html.TABLE() table1.style.border = "none" table1.style.fontSize = "large" table1.style.background = "#F7F7F7" #table1.style.marginLeft = "50px" #b.style.marginTop = "30px" # table1.style.padding = "10px 20px 10px 10px" table1.style.font = "16px verdana" tableBody1 = html.TBODY() g1 = html.TR() g11 = html.LABEL("Search datasets by keyword:") g11.style.verticalAlign = "bottom" g11.style.marginRight = "10px" td_1 = html.TD() td_1 <= g11 g1 <= td_1 g12 = html.INPUT(id="g12") g12.style.verticalAlign = "bottom" g12.style.marginRight = "20px" td_2 = html.TD() td_2 <= g12 g1 <= td_2 g13 = html.LABEL("Search in:") g13.style.verticalAlign = "bottom" g13.style.marginRight = "10px" td_3 = html.TD() td_3 <= g13 g1 <= td_3 op1 = html.OPTION("title") op2 = html.OPTION("description") op3 = html.OPTION("dataset ID") op4 = html.OPTION("pubmed ID") op5 = html.OPTION("gene") op6 = html.OPTION("probe") sel1 = html.SELECT([op1, op2, op3, op4, op5, op6], id="selector1", font_size=12) sel1.style.fontSize = "large" sel1.style.verticalAlign = "bottom" td_4 = html.TD() td_4 <= sel1 g1 <= td_4 global bSearch1 bSearch1 = html.BUTTON('Search') button_style_default(bSearch1) #bSearch1.bind('click', click_search1) bSearch1.bind('mouseout', mouse_out_search1) bSearch1.bind('mouseover', mouse_over_search1) bSearch1.style.verticalAlign = "top" bSearch1.bind('click', datasets_by_keyword_search) td_5 = html.TD() td_5 <= bSearch1 g1 <= td_5 tableBody1 <= g1 table1 <= tableBody1 panel <= table1 panel <= html.BR()
grid.pendown() 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('寶貝圖鑑輸入表'),
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 draw_about(): panel = document["main_panel"] panel.style.fontSize = "large" panel.style.font = "20px verdana" panel <= html.BR() panel <= "GeneXpresso enables researchers to search and analyze large DNA microarray datasets " \ "without having to write a single line of code. The users can download results of the analysis " \ "for further exploration. We use a public DNA microarray database at the " panel <= html.A("National Center for Biotechnology Information", href='http://www.ncbi.nlm.nih.gov/gds/') panel <= " as our source of raw gene expression data. " \ "The current version of GeneXpresso includes " \ "data for H**o sapiens only, however we can add datasets for other species as well upon request." panel <= html.BR() panel <= html.BR() panel <= "Watch " panel <= html.A("GeneXpresso instructional video on YouTube.", href='https://www.youtube.com/watch?v=vSKzyA4y614', target='_blank') panel <= html.BR() panel <= html.BR() panel <= "If your lab is in the New York City area, please contact us at [email protected] to schedule " \ " a tutorial. We can come to your lab to do a demonstration on how to use the GeneXpresso "\ "analysis tools for your research." panel <= html.BR() panel <= html.BR() panel <= html.BR() about_sean = html.TABLE() row = html.TR() left = html.TD(width=270) right = html.TD() about_sean.style.verticalAlign = "top" row.style.verticalAlign = "top" right.style.verticalAlign = "top" left.style.textAlign = "center" left.style.padding = "0px 30px 0px 0px" left <= html.IMG(src="sean-portrait-small.png", width="150") left <= html.BR() left <= html.STRONG("Sean Vaysburd") left <= html.BR() left <= "Founder, Head of " left <= html.BR() left <= "Research and Technology" left <= html.BR() left <= html.A("Sean's Resumé", href='SeanVaysburdResume2017.pdf', target='_blank') right <= "Sean Vaysburd founded GeneXpresso to make it easy for genetics researchers " \ "to quickly analyze large DNA microarray gene expression datasets without " \ "having to write any computer software. " right <= html.BR() right <= html.BR() right <= "Over the summer of 2015, Sean did a project aiming to " \ "analyze the statistical significance of gene expression numbers for groups of people with " \ "different disease states, based on over 70 DNA microarray data files with 50,000+ gene expression " \ "probes in each dataset. While working on this project, Sean found several disease groups with " \ " similar gene expression clusters. " \ "Some of those findings were quite unexpected and could indicate previously unknown relationships " \ "between different diseases at the gene-expression level. Inspired by these results, " \ "Sean set a goal of making DNA microarray search and analysis tools that he wrote " \ "available to biomedical researchers everywhere. GeneXpresso is a result of this pursuit." right <= html.BR() right <= html.BR() right <= "Sean is currently a senior at Stuyvesant High School in New York City. " \ "He works as a research volunteer at Dr. Pei's Microbiome Lab at the NYU School of Medicine. " row <= [left, right] about_sean <= row about_sean <= html.BR() # Sam row = html.TR() left = html.TD(width=270) right = html.TD() about_sean.style.verticalAlign = "top" row.style.verticalAlign = "top" right.style.verticalAlign = "top" left.style.textAlign = "center" left.style.padding = "0px 30px 0px 0px" left <= html.IMG(src="sam-portrait-small.png", width="150") left <= html.BR() left <= html.STRONG("Samuel Ramos") left <= html.BR() left <= "Team member," left <= html.BR() left <= "Head of Marketing" left <= html.BR() right <= html.BR() right <= html.BR() right <= "Samuel Ramos is a senior at Stuyvesant High School. In 2016, he studied at Brooklyn’s Genspace community laboratory learning how to use CRISPr +cas9 technology. During the summer of 2017 he developed a cell breast cancer culture study with Dr. Harry Ostrer and Dr. John Loke at Albert Einstein School of Medicine." row <= [left, right] about_sean <= row about_sean <= html.BR() about_sean <= html.BR() # Max row = html.TR() left = html.TD(width=270) right = html.TD() about_sean.style.verticalAlign = "top" row.style.verticalAlign = "top" right.style.verticalAlign = "top" left.style.textAlign = "center" left.style.padding = "0px 30px 0px 0px" left <= html.IMG(src="max-portrait-small.png", width="150") left <= html.BR() left <= html.STRONG("Max Vaysburd") left <= html.BR() left <= "Team Member," left <= html.BR() left <= "Head of Operations" left <= html.BR() right <= html.BR() right <= html.BR() right <= "Max Vaysburd is a freshman at Stuyvesant High School. " \ "He has participated in AMC-10, AMC-12, AIME, and ARML competitions " \ "and is currently on the Stuyvesant Math Team. Max has completed the " \ "online Machine Learning class on Coursera." row <= [left, right] about_sean <= row panel <= about_sean panel <= html.P() #panel <= "Sean enjoys studying and researching biology, genetics, and computer programming. " \ # "In his spare time he likes painting pictures of nature and animals on seashells and ceramic tiles." #center = html.CENTER() #panel <= center panel <= html.BR() panel <= html.BR() panel <= html.BR()