def show_final_scores(self): self.final_line_score_resume = {"perfect": 0, "almost": 0, "ko": 0} for v in self.final_line_scores.values(): for k in self.final_line_score_resume: self.final_line_score_resume[k] += v[k] message = html.DIV() message <= html.DIV("Bravo ! Vous êtes allé jusqu'au bout !") message <= html.BR() message <= html.DIV("Voici votre progression :") message <= html.DIV( f"😁 (Parfait !!!) : {self.base_line_score_resume['perfect']} => {self.final_line_score_resume['perfect']}" ) message <= html.DIV( f"😊 (Presque !) : {self.base_line_score_resume['almost']} => {self.final_line_score_resume['almost']}" ) message <= html.DIV( f"😔 (À réviser) : {self.base_line_score_resume['ko']} => {self.final_line_score_resume['ko']}" ) message <= html.BR() message <= html.DIV( "Vous pouvez maintenant continuer à travailler sur cette scène ou revenir à l'écran de " "sélection.") button_contents = [ "Continuer avec cette scène", "Revenir à l'écran de sélection" ] def callback(button_index): if button_index == 0: self.random_focus(0, None) else: self.start_selection() document <= create_question_panel(message, button_contents, callback)
def input(ev): global user global chat global check global chat_rec if user: name = user else: name = 'Anonnymous' if checking_chat() is False and check is False: check = True if ev.target.value != '': print("bvbvbvbvv") text_chat = [name, ev.target.value, win.Date.now()] chat.append(text_chat) chat_rec = json.dumps(chat) storage['chat'] = chat_rec doc['controle'] <= html.B(name) + " : " + ev.target.value + html.BR() ev.target.value = "" else: if ev.target.value != '': doc['controle'] <= html.B(name) + " : " + ev.target.value + html.BR() print("zeazeazea") text_chat = [name, ev.target.value, win.Date.now()] ev.target.value = "" chat.append(text_chat) chat_rec = json.dumps(chat) storage['chat'] = chat_rec show_button()
def draw_contact_bigButton(): panel = document["main_panel"] p = html.P("Send an email to GeneXpresso:") p.style.textAlign = "center" p.style.fontSize = "large" p.style.font = "20px verdana" p.style.textAlign = "center" panel <= html.BR() panel <= html.BR() panel <= html.BR() panel <= html.BR() #panel <= p form = html.FORM() form.style.fontSize = "large" form.style.font = "20px verdana" form.action = "mailto:[email protected]" form.method = "POST" form.style.textAlign = "center" global buttonSendEmail buttonSendEmail = html.INPUT() buttonSendEmail.type = "submit" buttonSendEmail.value = "Send" button_style_default(buttonSendEmail) buttonSendEmail.bind('mouseout', mouse_out_send_email) buttonSendEmail.bind('mouseover', mouse_over_send_email) form <= buttonSendEmail panel <= form
def featureEdit(feature: str) -> dialog.Dialog: d = dialog.Dialog(feature, ok_cancel=True, default_css=False) def toggleNumeric(event): if event.target.checked: del d.select("#value")[0].attrs["readonly"] del d.select("#abilityModCheck")[0].attrs["disabled"] else: d.select("#value")[0].attrs["readonly"] = '' d.select("#abilityModCheck")[0].attrs["disabled"] = '' d.select("#abilityModCheck")[0].checked = False d.select("#abilityModCheck")[0].dispatchEvent( window.Event.new("change")) def toggleAbility(event): for a in abilities: if event.target.checked: del d.select('#' + a + "RB")[0].attrs["disabled"] else: d.select('#' + a + "RB")[0].attrs["disabled"] = '' if True not in [ r.checked for r in d.select("input[name=\"ability\"]") ]: d.select("#strengthRB")[0].checked = True d.panel <= html.LABEL("Feature Name:", For="name") d.panel <= html.INPUT(id="name", Class="dialogName") d.panel <= html.BR() d.panel <= html.LABEL("Feature Description:", For="desc") d.panel <= html.INPUT(id="description") d.panel <= html.BR() d.panel <= html.LABEL("Is Numeric?", For="numericCheck") numericCheck = html.INPUT(id="numericCheck", type="checkbox") numericCheck.bind("change", toggleNumeric) d.panel <= numericCheck d.panel <= html.LABEL("Modifies Ability Score?", For="abilityModCheck") abilityModCheck = html.INPUT(id="abilityModCheck", type="checkbox", disabled='') abilityModCheck.bind("change", toggleAbility) d.panel <= abilityModCheck d.panel <= html.BR() d.panel <= html.LABEL("Feature Value:", For="value") d.panel <= html.INPUT(id="value", Type="number", readonly='') d.panel <= html.BR() for a in abilities: d.panel <= html.INPUT(id=a + "RB", name="ability", value=a[:3], type="radio", disabled='') d.panel <= html.LABEL(a.capitalize(), For=a + "RB") d.panel <= html.BR() return d
def show_values(event): N = document["input1"].value k = document["input2"].value select = document["select"] long_display = select.options[select.selectedIndex].value output = run(N, k, long_display) document['zone'].clear() document['zone'] <= (f"Value in N field: {input1}", html.BR(), f"Value in k field: {input2}", html.BR(), f"Selected long display option: {long_display}", html.BR(), output)
def skillEdit(skill: str) -> dialog.Dialog: d = dialog.Dialog(skill, ok_cancel=True, default_css=False) d.panel <= html.LABEL("Skill Name:", For="name") d.panel <= html.INPUT(id="name", Class="dialogName") d.panel <= html.BR() for a in abilities: d.panel <= html.INPUT( id=a + "RB", name="ability", value=a[:3], type="radio") d.panel <= html.LABEL(a.capitalize(), For=a + "RB") d.panel <= html.BR() return d
def draw_param_selector(self): # param_name, default_value pairs for param in self.params: inp = html.INPUT(type="text", name=param, value=self.params[param]) self.inputs[param] = inp self.container <= html.BR() self.container <= param self.container <= html.BR() self.container <= inp self.container <= html.BR() butt = html.BUTTON("update simulation") butt.bind("click", self.change_params_callback) self.container <= butt
def show_base_scores(self): self.base_line_score_resume = {"perfect": 0, "almost": 0, "ko": 0} for v in self.base_line_scores.values(): for k in self.base_line_score_resume: self.base_line_score_resume[k] += v[k] # print("show_base_scores") # print(self.base_line_scores) # print(self.base_line_score_resume) message = html.DIV() message <= html.DIV("Voici votre score de base :") message <= html.DIV( f"😁 (Parfait !!!) : {self.base_line_score_resume['perfect']}") message <= html.DIV( f"😊 (Presque !) : {self.base_line_score_resume['almost']}") message <= html.DIV( f"😔 (À réviser) : {self.base_line_score_resume['ko']}") message <= html.BR() + html.DIV( "Maintenant, le programme va vous soumettre des répliques dans un ordre " "aléatoire, en privilégiant celles posant difficultés.") button_contents = ["Ok, c'est parti !"] def callback(button_index): self.random_focus(0, None) document <= create_question_panel(message, button_contents, callback)
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 classEdit() -> dialog.Dialog: d = dialog.Dialog("Class(es)", ok_cancel = True, default_css = False) def toggleLevels(event): if event.target.checked: del d.select("#levelList")[0].attrs["readonly"] else: d.select("#levelList")[0].attrs["readonly"] = '' d.panel <= html.P("Enter one or more classes and corresponding hit dice, separating multiple entries by a comma (,).") d.panel <= html.LABEL("Class List:", For = "classList") d.panel <= html.INPUT(id = "classList") d.panel <= html.P("For the hit dice, write each entry as the number of sides of the associated die (ex. \"6\" for a d6).") d.panel <= html.LABEL("Dice List:", For = "diceList") d.panel <= html.INPUT(id = "diceList") d.panel <= html.P("If you need to edit class levels, enter them here like the dice.") d.panel <= html.LABEL("Edit Level(s)?", For = "levelsCheck") levelsCheck = html.INPUT(id = "levelsCheck", type = "checkbox") levelsCheck.bind("change", toggleLevels) d.panel <= levelsCheck d.panel <= html.BR() d.panel <= html.LABEL("Level List:", For = "levelList") d.panel <= html.INPUT(id = "levelList", readonly = '') return d
def share_code(ev): src = editor.getValue() if len(src) > 2048: d = dialog.InfoDialog("Copy url", f"code length is {len(src)}, must be < 2048", style={"zIndex": 10}, ok=True) else: href = window.location.href.rsplit("?", 1)[0] query = doc.query query["code"] = src url = f"{href}{query}" url = url.replace("(", "%28").replace(")", "%29") d = dialog.Dialog("Copy url") area = html.TEXTAREA(rows=0, cols=0) d.panel <= area area.value = url # copy to clipboard area.focus() area.select() doc.execCommand("copy") d.remove() d = dialog.Dialog("Copy url") d.panel <= html.DIV("url copied in the clipboard<br>Send it to share the code") buttons = html.DIV() ok = html.BUTTON("Ok") buttons <= html.DIV(ok, style={"text-align": "center"}) d.panel <= html.BR() + buttons @bind(ok, "click") def click(evt): d.remove()
def setup(self, container): def _make_handler(building): def _handle(e): self.game.buildings[building].on_buy() return _handle self.divs = {} self.buybuttons = {} for key, value in self.game.buildings.items(): self.divs[key] = [] self.buybuttons[key] = [] for ele in container.get(selector=".building-holder-holder"): if value.in_world(ele.parent.parent.id.split("_")[1]): parent = html.DIV( html.SPAN(value.name), Class="building-holder building-holder_" + key) div = html.SPAN("Loading...", Class="building-count") parent <= div desc = html.DIV(value.desc + "\n" + value.buy_desc, Class="building-desc") button = html.BUTTON("Buy!", disabled=True) self.buybuttons[key].append(button) button.bind("click", _make_handler(key)) desc <= html.BR() desc <= button parent <= desc self.divs[key].append(div) ele <= parent
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 draw_file_browser(): filebrowser.clear() open_scripts.sort() filebrowser <= (html.SPAN(s) + html.BR() for s in open_scripts) for span in filebrowser.select("span"): span.bind("click", open_script) if span.text.strip() == current: span.style.backgroundColor = "#888"
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 get_scripts(evt): scripts = evt.target.result if not scripts: dialog_window.panel <= "No file" else: scripts.sort() for script in scripts: script_elt = html.SPAN(script, style=script_style) dialog_window.panel <= script_elt + html.BR() script_elt.bind("click", open_script)
def __init__(self, title="", message=None, style={}, top=0, left=0): Dialog.__init__(self, title, style, top, left, ok_cancel=True) if message is not None: self.panel <= message self.entry = html.INPUT() self.panel <= html.BR() + self.entry self.entry.focus() self.entry.bind("keypress", self.callback) self.ok_button.bind("click", self.callback)
def get_scripts(evt): res = evt.target.result if res: scripts.append(res.value.name) getattr(res, "continue")() else: scripts.sort() for script in scripts: dialog <= html.SPAN(script) + html.BR() for elt in dialog.childNodes: elt.bind("click", open_script)
def get_scripts(evt): res = evt.target.result if res: scripts.append(res.value.name) getattr(res, "continue")() else: scripts.sort() for script in scripts: script_elt = html.SPAN(script, style=script_style) dialog_window.panel <= script_elt + html.BR() script_elt.bind("click", open_script)
def get_ctp_all(ev): document['console'].clear() document['console'] <= "帐户信息获取成功..." cache['ctp'] = ev['data'] if 'zmq' not in cache: for one in cache['ctp'].values(): if 'zmqserver' in one and len(one['zmqserver'])>0: cache['zmq'] = one['zmqserver'] break for acc,one in ev['data'].items(): if one['usezmq']=='0': _text = "账号:%(userid)s 行情服务器:%(mdfront)s 交易服务器:%(tdfront)s 柜台ID:%(brokerid)s 订阅合约:%(instrument)s 自动交易服务器:%(zmqserver)s ○不使用"%one else: _text = "账号:%(userid)s 行情服务器:%(mdfront)s 交易服务器:%(tdfront)s 柜台ID:%(brokerid)s 订阅合约:%(instrument)s 自动交易服务器:%(zmqserver)s ●使用"%one _btn1 = html.BUTTON("更新",id=one['userid']) _btn1.bind('click',updatectp) _btn2 = html.BUTTON("删除",id=one['userid']) _btn2.bind('click',delctp) _div = html.DIV(id=one['userid']) _div <= _btn1+_btn2+_text+html.HR() document['ctp'] <= _div newer = html.DIV() nmd = html.INPUT(id="mdfront") nmd.value="" newer<= nmd+"行情前置服务器(mdfront)"+html.BR() nmd = html.INPUT(id="tdfront") nmd.value="" newer<= nmd+"交易前置服务器(tdfront)"+html.BR() nmd = html.INPUT(id="brokerid") nmd.value="" newer<= nmd+"柜台ID"+html.BR() nmd = html.INPUT(id="userid") nmd.value="" newer<= nmd+"账号"+html.BR() nmd = html.INPUT(id="password") nmd.value="" newer<= nmd+"密码"+html.BR() nmd = html.INPUT(id="instrument") nmd.value="" newer<= nmd+"订阅合约(多个合约中间用+分隔,使用主力合约加=,如IF=)"+html.BR() nmd = html.INPUT(id="usezmq") nmd.value="0" newer<= nmd+"使用自动交易信号(0:不使用 1:使用)"+html.BR() nmd = html.INPUT(id="zmqserver") nmd.value=cache.get('zmqserver','') newer<= nmd+"自动交易服务器地址"+html.BR() nbtn = html.BUTTON("添加",id="new") nbtn.bind('click',addnew) newer<= nbtn document['ctp'] <= newer
def wheightEdit(heightData, weightData) -> dialog.Dialog: d = dialog.Dialog("Edit Weight/Height", ok_cancel=True, default_css=False) def setMeasure(event): for r in d.select("input[name=\"measure\"]"): if r.checked: measure = r.value break if measure == "height": dataDict = heightData else: dataDict = weightData d.select("#measure")[0].value = dataDict["measure"] d.select("#unit")[0].value = dataDict["unit"] heightRadio = html.INPUT(id="editHeight", type="radio", name="measure", value="height") heightRadio.bind("change", setMeasure) d.panel <= heightRadio d.panel <= html.LABEL("Height", For="editHeight") weightRadio = html.INPUT(id="editWeight", type="radio", name="measure", value="weight") weightRadio.bind("change", setMeasure) d.panel <= weightRadio d.panel <= html.LABEL("Weight", For="editWeight") d.panel <= html.BR() d.panel <= html.LABEL("Measure:", For="measure") d.panel <= html.INPUT(id="measure", type="number", min=0, step=0.01) d.panel <= html.BR() d.panel <= html.LABEL("Unit:", For="unit") d.panel <= html.INPUT(id="unit") return d
def levelSet() -> dialog.Dialog: d = dialog.Dialog("Set Character Level", ok_cancel = True, default_css = False) d.panel <= html.LABEL("Enter your new Character Level (1 -> 20):", For = "newCharLevel") d.panel <= html.INPUT(id = "newCharLevel", type = "number", min = 1, max = 20) d.panel <= html.BR() d.panel <= html.B( "Please note that changing your level will set your experience to the minimum required to match." ) return d
def draw_home(): panel = document["main_panel"] panel <= "Use GeneXpresso search and analysis tools to analyze differences in gene expressions"\ " between DNA microarray datasets. Refer to the User Guide for detailed instructions,"\ " and feel free to contact us at [email protected] if you have any questions or feedback." panel <= html.BR() panel <= html.BR() draw_home1() draw_home2() draw_home_samples('', '') draw_home_title_description() draw_home3() panel <= html.BR() p = html.P("Powered by ") p.style.textAlign = "left" p.style.fontSize = "small" p.style.font = "12px verdana" panel <= p panel <= html.IMG(src="gcp.png", width="150")
def show_final_evaluation_message(self): message = html.DIV() message <= html.DIV("On y est presque !") message <= html.BR() message <= html.DIV( "La dernière étape reprend le texte dans l'ordre pour remettre les choses en place " "et évaluer la progression.") button_contents = ["Allons-y ! [Alonzo]"] def callback(button_index): self.final_evaluation() document <= create_question_panel(message, button_contents, callback)
def spellTableCreate() -> dialog.Dialog: d = dialog.Dialog("Create Spell Table", ok_cancel = True, default_css = False) d.panel <= html.P("Select an ability to be the source of magical power:") for a in ("intelligence", "wisdom", "charisma"): d.panel <= html.INPUT( id = a + "`spellTableAbilityRadio", name = "ability", value = a, type = "radio" ) d.panel <= html.LABEL(a.capitalize(), For = a + "`spellTableAbilityRadio") d.panel <= html.BR() d.panel <= html.P("Select a class that does not yet have a spell table:") return d
def checking_chat(): global chat_rec global chat global check if "chat" not in storage: return False else: if check is False: chat_rec = storage['chat'] chat_rec = json.loads(chat_rec) chat = chat_rec for x in chat_rec: doc['controle'] <= html.B(x[0]) + " : " + x[1] + html.BR() check = True
def trigger_ending_scene(): content = create_front_blank_page("THE END") # already added to html # content <= html.IFRAME(width="100%",height="100%",src="http://www.youtube.com/embed/5CdoyqsNdaE?&autoplay=1") content <= html.IMG( src="images/tenor.gif", width=498, alt="Finally awake...") # content <= html.DIV("End of Dynamic Entropy " + document['version'].text) # # img = html.IMG(src="images/dynamic_entropy_xkcd.png") # img_link = html.A(href="https://xkcd.com/2318/", target="_blank") # img_link <= img # content <= img_link content <= html.BR() content <= "Hey, you! You're finally awake." content <= html.BR() content <= "You were trying to cross the border, right? Walked right into that imperial ambush, same as us." content <= html.BR() content <= "To be continued..." content <= html.BR() btn = html.BUTTON("Thanks for playing") btn.bind("click", lambda e, content=content: remove_front_page(content)) content <= btn
def alerts(event): response = False name = '' window.alert('Isso é um alerta!!') while not (response and name): name = window.prompt('Digite seu nome') msg = 'Seu nome é vazio. Vamos refazer a operação' if name: msg = 'Esse é mesmo o seu nome?' response = window.confirm(msg) document.select_one('.body_b') <= html.H1(f'Olar {name}') document.select_one('.body_b') <= html.BR()
def addSubTest(self, test, subtest, err): TestResult.addSubTest(self, test, subtest, err) # special case, don't use ident() cell2 = (test._testMethodName + html.BR() + str(subtest._subDescription())) row = html.TR([html.TD(test.__class__.__name__), html.TD(cell2), html.TD(test.lineno, Class="number"), html.TD(round(1000*(time.time() - test.startTime)), Class="number")], Class="method") row <= html.TD('ok', colspan=2, Class="report_cell") # reset startTime test.startTime = time.time() document['report'] <= row
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