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 show_task(event, element): global data global idcheck global bind_list cla = "w3-tag w3-large w3-red" if len(data) != 0: doc['app-3'].style.display = "block" for x, q in data.items(): if x not in idcheck: idcheck.append(x) span = html.SPAN("×", id="id" + str(x), Class=cla, style={'margin-top': '4px'}) inputcheckbox = html.INPUT(Class="w3-check w3-left", id="c" + str(x), type="checkbox") container = html.DIV(Class="w3-container", id="k" + str(x)) input = html.INPUT(id="m" + str(x), Class="w3-left", value=q[0], readonly="true", style=styleinput) div1 = html.DIV(id=x) div1 <= inputcheckbox + input + span container <= div1 doc['app-3'] <= container for x in idcheck: if x not in bind_list: bind_list.append(x) doc["id" + str(x)].bind("click", remove_item) doc["c" + str(x)].bind("change", line) doc["m" + str(x)].bind("click", editing) doc["m" + str(x)].bind("blur", editing_focus)
def create_nav(): n = html.NAV(id='nav') n <= html.INPUT(id='insert') n <= html.BUTTON("Insert", id='insert-btn', Class='btn') n <= html.INPUT(id='delete') n <= html.BUTTON('Delete', id='delete-btn', Class='btn') n <= html.BUTTON('Min', id='min-btn', Class='btn') n <= html.BUTTON('Max', id='max-btn', Class='btn') n <= html.BUTTON('Inorder', id='inorder-btn', Class='btn') n <= html.BUTTON('Preorder', id='preorder-btn', Class='btn') n <= html.BUTTON('Postorder', id='postorder-btn', Class='btn') return n
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 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 keypress(callback, timeout=3000): """""" capture_key = html.INPUT(type="text", name="capture", value="", style={ 'position': 'absolute', 'opacity': 0 }) document <= capture_key capture_key.focus() def process(key=None): capture_key.unbind('keypress') capture_key.remove() callback(key) if timeout: timer.clear_timeout(t) def handle(evt): key = chr(evt.charCode) process(key) capture_key.bind('keypress', handle) if timeout: t = timer.set_timeout(process, timeout)
def build_speller(self) -> None: """""" self.speller = html.INPUT(Class="p300-speller", readonly=True, style={'display': 'none'}) self.speller.value = '_' self.stimuli_area <= self.speller
def _import(ev): title = _("Import Python script from disk") import_dialog = dialog.Dialog(title) file_selector = html.INPUT(type="file") import_dialog.panel <= file_selector @bind(file_selector, "change") def change(evt): files = evt.target.files file = files.item(0) import_dialog.remove() if not file.name.endswith(".py"): dialog.InfoDialog("Import file from disk", "Error - can only import Python scripts") else: reader = window.FileReader.new(file) @bind(reader, "load") def read_file(evt): content = reader.result if file.name in ScriptsFinder.scripts: alert("name conflict " + file.name) else: create_editor() open_files[file.name] = { "content": content, "cursor": [0, 0] } editor.setValue(content) update_filebrowser(file.name) current = filebrowser.select_one(".current") save_to_db(file.name, content, current) reader.readAsText(file)
def add_place(name, abb, default=False): place_label = HTML.LABEL(name, Class='am-checkbox') print(abb) print(default) if (default == True): print('Checked') place_ckbox = HTML.INPUT('', Type='checkbox', Value=abb, Name='cbx', Checked='') else: print('Unchecked') place_ckbox = HTML.INPUT('', Type='checkbox', Value=abb, Name='cbx') place_label <= place_ckbox return place_label
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 open_local(): """ Opens a file dialog which the user can use to pick a file. Returns: asyncio.Future: Returns a future which, upon reading the file, resolves to an `asyncio.fs.BrowserFile` object with the file contents. The method works by appending an input element to the document body, registering a change handler for it, programmatically clicking it, and then immediately deleting it from the document. """ i = html.INPUT(type='file') result = Future() @run_async() def change_handler(evt): ret = yield open(i.files[0]) result.set_result(ret) i.bind('change', change_handler) doc <= i i.click() doc.body.removeChild(i) return result
def searchbar(): div = html.DIV(html.INPUT(Class="w3-input w3-border", type="search", id='search'), Class="w3-panel w3-border w3-round-xxlarge", id="searchpanel", style={"padding": "1.01em 16px"}) return div
def save_as(ev): d = ui.Dialog("Save sheet as...") d.add_ok_cancel(ok=save_sheet, cancel=cancel_save_as) d.body <= html.SPAN('File name', style=dict(marginRight='10px')) d.body <= html.INPUT() document.unbind('keydown') document <= d
def __init__(self, title="", style={}, top=0, left=0): Dialog.__init__(self, title, style, top, left, ok_cancel=True) self.entry = html.INPUT() self.panel <= self.entry self.entry.focus() self.entry.bind("keypress", self.callback) self.ok_button.bind("clcik", self.callback)
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 __init__(self, title, returnaction=None, extlist=[], id=None): DialogBox.__init__(self, title, returnaction, id=id) self.path = None self.extlist = extlist self.fileinput = html.INPUT(id="fileinput") self <= self.fileinput self.filelistbox = html.UL(id="filelistbox") self <= self.filelistbox
def search_dialog(self, evt): self.dialog = dialog.Dialog(style={"font-family": "Arial"}, left=100, top=100, ok_cancel=True) entry = html.INPUT() self.dialog.ok_button.bind("click", self.make_search) self.dialog.content <= "Search" + entry entry.focus()
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 test_browser_widgets_dialog(): from browser.widgets.dialog import InfoDialog # Info box with customized "Ok" button d1 = InfoDialog("Test", "Information message", ok="Got it") from browser.widgets.dialog import InfoDialog # Info box that disappears after 3 seconds d1 = InfoDialog("Test", "Closing in 3 seconds", remove_after=3) from browser import bind from browser.widgets.dialog import InfoDialog, EntryDialog d = EntryDialog("Test", "Name") @bind(d, "entry") def entry(ev): value = d.value d.close() InfoDialog("Test", f"Hello, {value} !") ## added entry(evt) from browser import bind, html from browser.widgets.dialog import Dialog, EntryDialog, InfoDialog translations = {'Français': 'Salut', 'Español': 'Hola', 'Italiano': 'Ciao'} d = Dialog("Test", ok_cancel=True) style = dict(textAlign="center", paddingBottom="1em") d.panel <= html.DIV("Name " + html.INPUT(), style=style) d.panel <= html.DIV( "Language " + html.SELECT(html.OPTION(k) for k in translations), style=style) # Event handler for "Ok" button @bind(d.ok_button, "click") def ok(ev): """InfoDialog with text depending on user entry, at the same position as the original box.""" language = d.select_one("SELECT").value prompt = translations[language] name = d.select_one("INPUT").value left, top = d.scrolled_left, d.scrolled_top d.close() d3 = InfoDialog("Test", f"{prompt}, {name} !", left=left, top=top) ## added translations[0] = "test" # mockbrython hashes to 0, avoid KeyError ok(evt)
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 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 __init__(self, title, prompt, callback): Dialog.__init__(self, title) d_prompt = html.DIV(prompt, Class="ui-widget", style=dict(float="left", paddingRight="10px")) self.entry = html.INPUT() self.body <= html.DIV(d_prompt + self.entry, style={'padding': '15px'}) self.entry.focus() self.entry.bind('keydown', self.keydown) self.add_ok_cancel(ok=callback) self.callback = callback
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 spellTableSetMaxLevel(className : str, currentMaxLevel : int) -> dialog.Dialog: d = dialog.Dialog( "Maximum " + className + " Spell Level", ok_cancel = True, default_css = False ) d.panel <= html.P("Enter a new maximum spell level (1 to 9 inclusive):") d.panel <= html.INPUT( id = "newMaxSpellLevel", type = "number", min = 1, max = 9, value = currentMaxLevel ) return d
def __init__(self, title, message=None, *, top=None, left=None, default_css=True): Dialog.__init__(self, title, top=top, left=left, ok_cancel=True, default_css=default_css) self.message = html.SPAN(message or '', Class="brython-dialog-message") \ or "" self.entry = html.INPUT() self.panel <= self.message + self.entry self.entry.focus() self.entry.bind("keypress", self.callback) self.ok_button.bind("click", self.callback)
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
async def main(): input = html.INPUT() document <= input while True: ev = await aio.event(input, "blur") try: v = int(ev.target.value) input.remove() alert(f"Value: {v}") print(1) break except ValueError: input.value = ""
def render(self): app = html.DIV() aft = AffectedByTextField() input = html.INPUT(type="text") @bind(input, "keyup") def update(e): aft.setState({"text": e.target.value}) app = group(app, [html.H1(self.title), aft.render(), input]) # app <= aft.render() # app <= input return app
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 __init__(self, title, prompt, action, _id=None): Dialog.__init__(self, _id) self.set_title(title) self.action = action d_prompt = html.DIV(prompt, Class="ui-widget", style=dict(float="left", paddingRight="10px")) self.entry = html.INPUT() body = html.DIV(d_prompt + self.entry, style={'padding': '15px'}) b_ok = html.BUTTON("Ok") b_ok.bind('click', self.ok) b_cancel = html.BUTTON("Cancel") b_cancel.bind('click', self.cancel) body += html.DIV(b_ok + b_cancel, style={'padding': '15px'}) self._div_dialog <= body