def output_data(req): if document.select('#data_on_page'): document['xls_link'].clear() if document.select('#rt1'): document['output_txt'].clear() global _name _name = req.text link_xls = html.P( html.IMG(loading='lazy', src='/static/img/xlsx_logo.png', width='45px', height='49px', Class='mr-2') + html.A('Скачать данные в формате xlsx', href=f'/static/combs/{_name}.xlsx')) link_txt = html.P( html.IMG(loading='lazy', src='/static/img/txt_logo.png', width='45px', height='49px', Class='mr-2') + html.A('Скачать данные в формате txt', href=f'/static/combs/{_name}.txt')) document['xls_link'] <= link_xls document['xls_link'] <= link_txt document['xls_link'] <= html.P( html.IMG(loading='lazy', src='/static/img/arrow_b.png', width='45px', height='49px', Class='mr-2') + html.A('Вывести данные на странице ниже', id='data_on_page', href='#output-txt')) document["data_on_page"].bind('click', output_txt_data)
def add_link(self, label, href): """Add a link to the specified address.""" if self.parent is None: # First level item = html.A(label, Class="brython-menu-navbar-link", href=href) self.container <= item else: # Next levels item = html.TR(Class="brython-menu-submenu-row") self.parent.submenu <= item item <= html.TD( html.A(label, Class="brython-menu-submenu-link", href=href)) return item
def __init__(self, tela=DOC_PYDIV): self.tela = tela self.optou = "" self.foi = None self.popup = html.DIV(Id="__popup__", Class="overlay") self.div = div = html.DIV(Class="popup") self.tit = html.H2() self.a = html.A("×", Class="close", href="#") self.go = html.A(Id="txt_button", Class="button", href="#__popup__") self.go.onclick = self._open self.a.onclick = self._close self.alt = html.DIV(Class="content") self.popup <= div self.popup.style = {"visibility": "hidden", "opacity": 0} self.inicia()
def update_saves(): saves = json.loads(storage["saves"]) dropdown = doc["load-dropdown"] dropdown.innerHTML = "" for s in saves: link = html.A(s, href='#', onclick="load_buffer('{}')".format(s)) dropdown <= html.LI(link)
def drop(self, ev): """Function attached to the destination zone. Describes what happens when the object is dropped, ie when the mouse is released while the object is over the zone. """ # retrieve data stored in drag_start (the draggable element's id) src = ev.dataTransfer.getData("text") camera = document[src] camera_id, url = src.split("-") display = document[ev.target.id] display.attrs["drop-active"] = False try: document[f"img-{src}"].unbind("dragstart") document[f"img-{src}"].parent.clear() except Exception as e: pass img = html.IMG( id=f"img-{src}", src=url, ) btn = html.A( Class="clear-btn icon rightbottom ui inverted red button circular", ) trash_icon = html.I(Class="trash icon") btn <= trash_icon display.clear() display <= img display <= btn img.draggable = True btn.bind("click", self.clear_display) img.bind("dragstart", self.dragstart_img) ev.preventDefault()
def __init__(self, codigo="", topo="", cena=INVENTARIO, img="", vai=None, style=NS): style.update({"height": "550px"}) Code.__init__(self, codigo=codigo, topo=topo, cena=cena, img=img, vai=vai, style=style) a = html.A("×", href="#", style=dict(position="absolute", top="0px", right="10px", fontSize="30px", fontWeight="bold")) a.onclick = self._close self.elt <= a self._close() self._area.style.overflow = "scroll" self._area.style.height = "400px" self.elt.style.maxHeight = "550px"
def PassageToDiv(self, passage: Passage) -> DivPassage: output = html.DIV() allow_back = False for element in passage: is_allow_back = (type(element) is type) and element.__name__ == "Allow_Back" if is_allow_back: allow_back = True continue if isinstance(element, str): output <= html.SPAN(md_to_html(element)) continue if isinstance(element, TP): alink = html.A(f" {element.Text} ") output <= self.makeLink(element.Text, element.PassageFactory) continue if callable(element): function_name = element.__name__ text_link = f"{function_name.replace('_',' ')}" if text_link.startswith(" "): text_link = text_link[1:] output <= self.makeLink(text_link, element) continue else: print(element) raise Exception(f"Unknown element type {type(element)}") return DivPassage(output, allow_back)
def on_complete2(req): r_json = json.loads(req.text) # converts to JSON r_json = r_json['values'] # extracts values r_json = r_json[0] # get into the array # sheets API always sort by ROWS as the major dimension # ** prints stuff on screen ** # index is based on column oreder document['levelname'] <= r_json[0] + ' (' gdbrowser_url = 'https://gdbrowser.com/' + r_json[4] document['levelname'] <= html.A( r_json[4], href=gdbrowser_url, target="_blank") document['levelname'] <= ')' document['levelcreator'] <= r_json[1] document['levelsong'] <= r_json[2] document['leveldiff'] <= r_json[3] if r_json[5] != "unrated": document['leveltier'] <= 'Tier ' + r_json[5] + ' (' + r_json[ 6] + ' corr to 2 d.p.)' # document['levelratings'] <= 'Submitted ratings:' # document['levelratings'] <= html.BR() i = 7 try: while r_json[i] != '': levelratings = '' levelratings = ''.join([levelratings, '- Tier ', r_json[i]]) i = i + 1 levelratings = ''.join([levelratings, ' by ', r_json[i]]) i = i + 1 document['levelratings'] <= levelratings document['levelratings'] <= html.BR() except: pass else: document['leveltier'] <= 'Not rated with a tier (yet)'
def opta(letra, texto): div = html.DIV(Class="content") optou = html.A(chr(ABOXED + ord(letra) - ord("A")), Class="option", href="#") optou.onclick = lambda *_: opcao(letra) or self._close() texto_opcao = html.SPAN(texto) div <= optou div <= texto_opcao return div
def call_worker(message, data): global worker global active_future if not worker: document["vitrine-progress-label"].textContent = "Starting worker..." def progress_handler(message_name, message, src): data = message.data.to_dict() print("Progress update:", data) document["vitrine-progress-label"].textContent = data['desc'] if 'value' in data: document["vitrine-progress"].max = data['max'] document["vitrine-progress"].value = data['value'] else: document["vitrine-progress"].removeAttribute('max') document["vitrine-progress"].removeAttribute('value') # Ugly hack to get an absolute URL from a relative one # https://stackoverflow.com/a/34020609/3991344 url = html.A(href='worker.py').href worker = webworker.WorkerParent( url, sys.path, {"BURGER_DATA_PREFIX": BURGER_DATA_PREFIX}) worker.bind_message('progress', progress_handler) if active_future is not None: active_future.cancel() active_future = None active_future = worker.post_message(webworker.Message(message, data), want_reply=True) def callback(future): if active_future is not active_future: return active_future = None try: document.getElementById( "vitrine").innerHTML = future.result().data.to_dict()['result'] attach_tooltip_handlers() except CancelledError: pass except webworker.WorkerError as e: document.getElementById( "vitrine" ).innerHTML = '<div class="entry"><h3>Error callback</h3><pre>' + escape( str(e)) + '</pre></div>' except: traceback.print_exc() document.getElementById( "vitrine" ).innerHTML = '<div class="entry"><h3>Error callback</h3><pre>' + escape( traceback.format_exc()) + '</pre></div>' active_future.add_done_callback(callback)
def draw_contact(): panel = document["main_panel"] panel <= "We appreciate feedback and ideas for making GeneXpresso.com more useful for your research."\ " If you have suggestions, comments, or requests for specific datasets (microarray or other types) "\ "that you would like to be able to analyze using GeneXpresso, or if you would like to schedule "\ "a demonstration / tutorial on how to use GeneXpresso analysis tools, feel free to contact us at " panel <= html.A("[email protected].", href="mailto:[email protected]")
def save(self): """ Saves the file locally. It works by silently appending a link element to the body. The link element has an appropriate download attribute (the name of the file) and href attribute (the data-uri with the contents of the file). This element is then programmatically clicked and removed from the body. """ link = html.A(href=self.as_data_url(), download=self._name) doc <= link link.click() doc.body.removeChild(link)
def cabinet_editing(e): room = document['room'].text email = document['email'].text tel = document['tel'].text document['room'].clear() document['email'].clear() document['tel'].clear() document['room'] <= html.INPUT(value=room) document['email'] <= html.INPUT(value=email) document['tel'] <= html.INPUT(value=tel) document['edit'].clear() document['edit'] <= html.SMALL(html.A('(сохранить)', href='#', id='save')) document['save'].bind('click', edit_user)
def draw_guide(): panel = document["main_panel"] guide = html.OBJECT(width="1000", height="1000", data="GeneXpressoUserGuide.pdf") download = html.A( '<img src="download_icon.jpg" height=20 width=20> Download User Guide', target="_blank") download.style.font = "16px verdana" download.style.color = "#303030" download.href = "GeneXpressoUserGuide.pdf" panel <= download panel <= html.BR() panel <= html.BR() panel <= guide
def refresh_UI(new_app_info): global app_info, current_activity, data_hub, user_info user, session_code, app, app_secret = user_info window.set_user_name(user) window.user_info = '' if app in ('me', 'ui', 'elt') and user != '': window.user_info = JSON.stringify({ 'user': user, 'session_code': session_code, 'app': app, 'app_secret': app_secret }) document["login"].hidden = (user == '') document["logout"].hidden = (user != '') for activity in app_info['activities']: document['nav-' + activity['id']].unbind('click') document["main-nav"].clear() app_info.update(new_app_info) for activity in app_info['activities']: a = html.A(activity['name'], **{ 'id': 'nav-' + activity['id'], 'class': 'nav-link' }) li = html.LI(a, **{'class': 'nav-item'}) document["main-nav"] <= li a.bind('click', lambda ev: show_activity(ev.target.id)) document["main"].clear() client = user_info[0] data_hub = DataHub(client if app_info['app'] == 'db' else '', True) for i, activity in enumerate(app_info['activities']): page = html.DIV(**{'id': 'page-' + activity['id']}) document["main"] <= page if activity['ui_json'] == '': pass else: make_ui(JSON.parse(activity['ui_json']), page, data_hub) page.style.display = 'none' if len(app_info['activities']) > 0: current_activity = None show_activity('nav-' + app_info['activities'][0]['id']) data_hub.onevent('', '', '') else: window.hide_spinner_modal()
def gen_li(item, level=''): item_title = HTML.A(item['show'], href=item['url']) item_text1 = HTML.DIV('展馆:{}'.format(item['name']), Class='am-list-item-text') time_text = HTML.SPAN('时间:{}-{}'.format(item['start'], item['end']), Class=level) item_text2 = HTML.DIV('', Class='am-list-item-text') item_text2 <= time_text item_text3 = HTML.DIV('展厅:{}'.format(item['hall']), Class='am-list-item-text') item_text4 = HTML.DIV('地址:{}'.format(item['addr']), Class='am-list-item-text') list_item = HTML.LI('', Class='am-g am-list-item-desced') list_item <= item_title list_item <= item_text1 list_item <= item_text2 list_item <= item_text3 list_item <= item_text4 return list_item
def employee_list(): global response try: response = urllib.request.urlopen("http://127.0.0.1:8001/employee/default/liste_employee.json") response = response.read() response = json.loads(response) li = html.UL(id="id01", Class="w3-ul w3-card-4") for x in response['employee']: ul = html.LI(Class="w3-bar",style={'display': "none"}) img = html.IMG(Class="w3-bar-item w3-circle", src="img/img_avatar2.png", style={"width":"85px"}) divbar = html.DIV(Class="w3-bar-item") a = html.A(x['full_name'],id=str(x['id']), href="#employee" + str(x['id'])) divbar <=a ul <= img + divbar li <= ul return li except: return html.DIV("We're sorry, server is busy", Class="w3-center w3-xxlarge w3-text-blue")
def __init__(self, codigo="", topo="", cena=INVENTARIO, img="", vai=None, style=NS): Code.__init__(self, codigo=codigo, topo=topo, cena=cena, img=img, vai=vai, style=style) a = html.A("×", href="#", style=dict(position="absolute", top="0px", right="10px", fontSize="30px", fontWeight="bold")) a.onclick = self._close self.elt <= a
def prg(pg, ct, er, ln, tt="Videos da Flávia"): from browser import html #alert(f"{pg} {len(ct)} {len(er)}") shuffle(er) rt = choice(ct) an = [rt] + er[:4] shuffle(an) #alert(an) self.correto = chr(ord("A") + an.index(rt)) opt = {k: v for k, v in zip(list("EDCBA"), an[::-1])} #alert(opt) texto = Texto(self.scene, pg, foi=self.resposta, **opt) ''' pp = texto.POP.popup.html alert(pp) alert(html.A(tt, href=ln).html + pp) texto.POP.popup.html = html.A(tt, href=ln).html + pp #texto.POP.popup <= html.A(tt, href=ln) ''' TheHero.YOUTUBE.y = 200 TheHero.YOUTUBE.elt.html = "" TheHero.YOUTUBE.elt <= html.A(tt, href=ln, target="_blank") #TheHero.YOUTUBE.entra(self.scene) texto.vai()
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 makeLink(self, text, passage_functor): span = html.A(f" {text} ") span.href = "#" span.bind("click", self.on_game_link_factory(passage_functor)) return span
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()
def detail_employee(ev): global response if response is not None: test = eval(ev.target.id) if isinstance(test, int): div = html.DIV(Class="w3-animate-left") div1 = html.DIV(Class="w3-border-bottom w3-bar w3-animate-left") i = html.I(Class="fa fa-angle-left w3-xxxlarge w3-text-cyan", id="back1") a = html.A(Class="w3-bar-item",id="back", style={"width": "10%"}) a <= i h1 = html.H1("Employee Details", Class="w3-wide w3-myfont w3-xlarge w3-bar-item w3-center", style={"width": "90%"}) div1 <= a + h1 for x in response['employee']: ul = html.UL(Class="w3-ul w3-border w3-animate-left") if x['id'] == int(ev.target.id): li = html.LI(Class="w3-bar") img = html.IMG(Class="w3-bar-item w3-circle", src="img/img_avatar2.png", style={"width":"85px"}) #first li div2 = html.DIV(Class="w3-bar-item") span1 = html.SPAN(x['full_name']) + html.BR() span2 = html.SPAN(x['job']) div2 <= span1 + span2 li <= img + div2 #second li li2= html.LI(Class="w3-bar w3-button w3-hover-cyan",id="office") div3 = html.DIV(Class="w3-bar-item") span3 = html.SPAN("Call Office") + html.BR() span4 = html.SPAN("781-000-002") a1 = html.A(href="tel:781-000-002",id="number" ,style={"display":"none"}) span = html.SPAN(html.I(Class="fa fa-angle-right w3-xxlarge"), Class="w3-right w3-bar-item") div3 <= span3 + span4 + a1 li2 <= span + div3 #third li li3 = html.LI(Class="w3-bar w3-button w3-hover-cyan", id="call") div4 = html.DIV(Class="w3-bar-item") span5 = html.SPAN("Call Mobile") + html.BR() span6 = html.SPAN("615-000-002", href="tel:615-000-002") a2 = html.A(href="tel:615-000-002",id="mobile" ,style={"display":"none"} ) spanbis = html.SPAN(html.I(Class="fa fa-angle-right w3-xxlarge"), Class="w3-right w3-bar-item") div4 <= span5 + span6 + a2 li3 <= spanbis + div4 # fourth li li4 = html.LI(Class="w3-bar w3-button w3-hover-cyan", id="sms") div5 = html.DIV(Class="w3-bar-item") span7 = html.SPAN("Number Sms") + html.BR() span8 = html.SPAN("615-000-002", href="tel:615-000-002") a3 = html.A(href="sms:615-000-002", id="sendsms", style={"display": "none"}) spanbis1 = html.SPAN(html.I(Class="fa fa-angle-right w3-xxlarge"), Class="w3-right w3-bar-item") div5 <= span7 + span8 + a3 li4 <= spanbis1 + div5 #five li li5 = html.LI(Class="w3-bar w3-button w3-hover-cyan", id="email") div6 = html.DIV(Class="w3-bar-item") span9 = html.SPAN("Email Professional") + html.BR() span10 = html.SPAN("*****@*****.**",href="mailto:[email protected]") a4 = html.A(href="mailto:[email protected]", id="sendemail",style={"display": "none"}) spanbis1 = html.SPAN(html.I(Class="fa fa-angle-right w3-xxlarge"), Class="w3-right w3-bar-item") div6 <= span9 + span10 + a4 li5 <= spanbis1 + div6 #end ul <= li + li2 + li3 + li4 +li5 retail <= div1 + html.BR() + ul doc['detail'].bind("click", direction) return retail
def __init__(self, id=None, document=doc, label=False): self._div_shell = html.DIV( Class= "ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all" ) Widget.Widget.__init__(self, self._div_shell, 'slider', id) self._handle = html.A( Class="ui-slider-handle ui-state-default ui-corner-all", Href='#', style={'left': '0px'}) self._value = 0 self._isMouseDown = False def startSlide(e): self._isMouseDown = True self._upperBound = self._div_shell.offsetWidth - self._handle.offsetWidth pos = Widget.getMousePosition(e) self._startMouseX = pos['x'] self._lastElementLeft = parseInt( self._handle.elt.style.left ) #- parseInt(self._div_shell.elt.style.left) #print(self._upperBound) updatePosition(e) def updatePosition(e): pos = Widget.getMousePosition(e) _newPos = self._lastElementLeft + pos['x'] - self._startMouseX _newPos = max(0, _newPos) _newPos = min(_newPos, self._upperBound) #print(_newPos) self._handle.elt.style.left = '%spx' % _newPos self._lastElementLeft = _newPos def moving(e): if self._isMouseDown: updatePosition(e) def dropCallback(e): self._isMouseDown = False self._handle.unbind('mousemove', moving) self._handle.bind('mousemove', moving) self._handle.bind('mouseup', dropCallback) #self._handle.bind('mouseout', dropCallback) self._handle.bind('mousedown', startSlide) def mouseover(e): _class = self._handle.getAttribute('class') self._handle.setAttribute('class', '%s %s' % (_class, 'ui-state-hover')) def mouseout(e): self._isMouseDown = False _class = self._handle.getAttribute('class') self._handle.setAttribute('class', _class.replace('ui-state-hover', '')) self._handle.bind('mouseover', mouseover) self._handle.bind('mouseout', mouseout) self._div_shell <= self._handle
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
self._playSounds = True def storePlaySoundsSetting(self): self._storage['playSounds'] = str(self._playSounds) # Use brython to create the canvas. real_canvas = html.CANVAS(width=CANVAS_WIDTH, height=CANVAS_HEIGHT, id='c') document <= real_canvas def windowChange(ev): print(window.innerWidth, window.innerHeight) window.bind('resize', windowChange) # Use the canvas in fabric canvas = fabric.Canvas.new('c', { 'width': CANVAS_WIDTH, 'height': CANVAS_HEIGHT, 'selectable': False, 'backgroundColor': 'darkgreen' }) app = App(document, canvas) document <= html.H2( html.A("Instructions", href="instructions.html", Class="right-edge")) document <= html.H5('Version: 1.1', Class="right-edge")
from browser import document, window, markdown, html from browser.widgets.dialog import InfoDialog from pysrc import snjb def startgame(_=0): runner.HtmlRenderer("gamediv", snjb.header).run(snjb.start_game) from pysrc import snjb import pysrc.brython_runner_passage as runner document['reset-game'].innerHTML = "" reset_link = html.A("Restart SNJB") reset_link.href = "#" reset_link.bind('click', startgame) document['reset-game'] <= reset_link startgame()
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 makeBackLink(self, text): span = html.A(text) span.href = "#" span.bind("click", self.on_back_button_factory()) return span