def exit(self): if self._on_exit: self._on_exit(self) window.open('','_self','') window.close() #__pragma__('nokwargs')
def email_kaya(self, ev): stringk = self.uenc('Hi Kaya,\nHere are the results from ' + self.subjects[0].name + ':\n') stringk += self.uenc(self.results()) #print('sk',stringk) window.open( 'mailto:[email protected]?subject=Results&body=' + stringk, 'Sending to Kaya') self.web_email('Kaya: [email protected]')
def email_sophie(self, ev): strings = self.uenc('Hi Sophie,\nHere are the results from ' + self.subjects[0].name + ':\n') strings += self.uenc(self.results()) #print('ss',stringk) window.open( 'mailto:[email protected]?subject=Results&body=' + strings, 'Sending to Sophie') self.web_email('Sophie: [email protected]')
def __init__(self, width, height, onclose): self._w = window.open("", "") self._stage = JSConstructor(GFX.Container)() self._renderer = GFX.autoDetectRenderer(width, height, {'transparent': True}) self._w.document.body.appendChild(self._renderer.view) self._w.onunload = onclose
def __init__(self, width, height, onclose): canvas = window.document.getElementById('ggame-canvas') if canvas: self._w = window window.bsUI.graphicsmode() options = { 'transparent': True, 'antialias': True, 'view': canvas } attachpoint = window.document.getElementById('graphics-column') w, h = attachpoint.clientWidth, attachpoint.clientHeight else: self._w = window.open("", "") w, h = self._w.innerWidth * 0.9, self._w.innerHeight * 0.9 options = {'transparent': True, 'antialias': True} attachpoint = self._w.document.body GFX.utils._saidHello = True # ugly hack to block pixi banner self._stage = GFX_NewStage() self.width = width if width != 0 else int(w) self.height = height if height != 0 else int(h) self._renderer = GFX.autoDetectRenderer(self.width, self.height, options) attachpoint.appendChild(self._renderer.view) self._w.onunload = onclose
def __init__(self, width, height, onclose): self._w = window.open("", "") self._stage = JSConstructor(GFX.Container)() self.width = width if width != 0 else int(window.innerWidth * 0.9) self.height = height if height != 0 else int(window.innerHeight * 0.9) self._renderer = GFX.autoDetectRenderer(self.width, self.height, {'transparent': True}) self._w.document.body.appendChild(self._renderer.view) consoleArea = self._w.document.createElement('DIV') self.consoleText = self._w.document.createElement('TEXTAREA') self.consoleText.id = "textarea" consoleArea.id = "consoleArea" self.consoleText.readonly = True consoleArea.appendChild(self.consoleText) style = self._w.document.createElement('STYLE') css = '#consoleArea {width: 70px; height: 100%; background-color: black; position: fixed; right: 0; top: 0;} #textarea {color: white; opacity: 0; background-color: rgba(0,0,0,0); width: 260px; height: 810px; position: absolute; top: 50px; margin: 0px; left: 20px; resize: none; border: none; outline: none;} .switch {position: relative; display: inline-block; width: 30px; height: 17px; top: 15px; margin-left: 20px;} .switch input {display:none;} .slider {position: absolute;cursor: pointer;top: 0;left: 0;right: 0;bottom: 0;background-color: #ccc;-webkit-transition: .4s;transition: .4s;} .slider:before {position: absolute;content: "";height: 13px;width: 13px;left: 2px;bottom: 2px;background-color: white;-webkit-transition: .4s;transition: .4s;} input:checked + .slider {background-color: #2196F3;} input:focus + .slider {box-shadow: 0 0 1px #2196F3;} input:checked + .slider:before {-webkit-transform: translateX(13px);-ms-transform: translateX(13px);transform: translateX(13px);} .slider.round {border-radius: 17px;} .slider.round:before {border-radius: 50%;} body{-webkit-touch-callout: none;-webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;}' style.type = 'text/css' style.appendChild(document.createTextNode(css)) self._w.document.head.appendChild(style) script = self._w.document.createElement('SCRIPT') js = 'function animateIt(dir, max, min) {var elem = document.getElementById("consoleArea"); var elem2 = document.getElementById("textarea"); var pos = max;var target = min;var id = setInterval(frame, 3);function frame() {var opa = Math.round((Math.abs(pos - target) / Math.abs(max - min)) * 100)/100;if (dir > 0) {opa = 1 - opa;} if (pos == target) {clearInterval(id);} else {pos = pos + dir; elem.style.width = pos + "px"; elem2.style.opacity = opa; }}}sessionStorage.switch = sessionStorage.switch ? sessionStorage.switch : "off";function switched() {if (sessionStorage.switch == "on") {sessionStorage.switch = "off";animateIt(-5, 300, 70);} else {sessionStorage.switch = "on";animateIt(5, 70, 300);}}' script.type = 'text/javascript' script.appendChild(document.createTextNode(js)) self._w.document.body.appendChild(script) self._w.onunload = onclose #if didLoadPyinput: # winput_init() consoleArea.insertAdjacentHTML( 'afterbegin', '<label class="switch"><input type="checkbox" onclick = "switched();"><div class="slider round"></div></label>' ) #self._w.document.body.innerHTML += '<div id = "inputScreen" style = "display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.2); z-index: 50;"><div style = "position: fixed; left: calc(50% - 150px); top: calc(50% - 75px); background-color: white;"><p id = "toPrompt"></p><input type = "text" id = "toInput"><input type = "submit" id = "toSubmit"></div></div>' self._w.document.body.appendChild(consoleArea)
def open(url, new=0, autoraise=True): """ new window or tab is not controllable on the client side. autoraise not available. """ if window.open(url, _target[new]): return True return False
def __init__(self, width, height, onclose): self._w = window.open("", "") self._stage = JSConstructor(GFX.Container)() self.width = width if width != 0 else int(window.innerWidth * 0.9) self.height = height if height != 0 else int(window.innerHeight * 0.9) self._renderer = GFX.autoDetectRenderer(self.width, self.height, {'transparent':True}) self._w.document.body.appendChild(self._renderer.view) self._w.onunload = onclose
def __init__(self, width, height, onclose): self._w = window.open("", "") self._stage = JSConstructor(GFX.Container)() self.width = width if width != 0 else int(window.innerWidth * 0.9) self.height = height if height != 0 else int(window.innerHeight * 0.9) self._renderer = GFX.autoDetectRenderer(self.width, self.height, {'transparent': True}) self._w.document.body.appendChild(self._renderer.view) self._w.onunload = onclose
def test_next(): global script_num, failed script_num += 1 options = doc['files'].options if script_num < len(options): option = doc['files'].options[script_num] script_name = option.value doc["console"].value = script_name + "\n" src = open(option.value).read() doc['files'].selectedIndex = script_num editor.setValue(src) execute(script_name, src, forward) else: doc['console'].value = '' print('completed all tests in %.2f s' % (time.time() - t_start)) print('failed : %s' % failed) w = window.open() head = w.document.get(selector="head") head[0] <= STYLE("*{font-family: Arial;}") body = w.document.body table = TABLE(border=1) table <= TR(TH('test') + TH('Brython')) for result in results: row = TR() row <= TD(result['test']) if "Brython" in result and "CPython" in result: row <= TD(int( 100 * float(result['Brython']) / float(result['CPython'])), align="right") else: row <= TD("missing result") table <= row version = '.'.join(str(x) for x in __BRYTHON__.implementation[:3]) body <= H1(f"Brython {version} performance (base 100 = CPython)") body <= table
def test_next(): global script_num, failed script_num += 1 options = doc['files'].options if script_num < len(options): option = doc['files'].options[script_num] script_name = option.value doc["console"].value = script_name + "\n" src = open(option.value).read() doc['files'].selectedIndex = script_num editor.setValue(src) execute(script_name, src, forward) else: doc['console'].value = '' print('completed all tests in %.2f s' %(time.time()-t_start)) print('failed : %s' %failed) w = window.open() head = w.document.get(selector="head") head[0] <= STYLE("*{font-family: Arial;}") body = w.document.body table = TABLE(border=1) table <= TR(TH('test') + TH('Brython')) for result in results: row = TR() row <= TD(result['test']) if "Brython" in result and "CPython" in result: row <= TD(int(100 * float(result['Brython']) / float(result['CPython'])), align="right") else: row <= TD("missing result") table <= row version = '.'.join(str(x) for x in __BRYTHON__.implementation[:3]) body <= H1(f"Brython {version} performance (base 100 = CPython)") body <= table
def __init__(self, width, height): self._width = width; self._height = height; self.wnd = window.open("", "", "width=" + str(width) + ", height=" + str(height), False); self.backgroundColor = Color(0.0,0.0,1.0) popDoc = self.wnd.document canvas = popDoc.createElement("canvas") canvas.setAttribute("id", "graph") canvas.setAttribute("width", str(width)) canvas.setAttribute("height", str(height)) popDoc.body.appendChild(canvas) popDoc.body.style.margin = "0" self.context = canvas.getContext("2d")
def open(url, new=0, autoraise=True): """ new window or tab is not controllable on the client side. autoraise not available. """ # javascript window.open doesn't work if you do not specify the protocol # A solution is the next hack: if '://' in url: if url[:6] == 'ftp://': print('entro') else: protocol = url.split('//:')[0] url = url.replace(protocol + '//:', '//') else: url = '//' + url print(url) if window.open(url, _target[new]): return True return False
def __init__(self, width, height, onclose): canvas = window.document.getElementById("ggame-canvas") if canvas: self._w = window window.bsUI.graphicsmode() options = {"transparent": True, "antialias": True, "view": canvas} attachpoint = window.document.getElementById("graphics-column") w, h = attachpoint.clientWidth, attachpoint.clientHeight else: self._w = window.open("", "") w, h = self._w.innerWidth * 0.9, self._w.innerHeight * 0.9 options = {"transparent": True, "antialias": True} attachpoint = self._w.document.body GFX.utils._saidHello = True # ugly hack to block pixi banner self._stage = GFX_NewStage() self.width = width if width != 0 else int(w) self.height = height if height != 0 else int(h) self.renderer = GFX.autoDetectRenderer(self.width, self.height, options) attachpoint.appendChild(self.renderer.view) self._w.onunload = onclose
def __init__(self, width, height, onclose): self._w = window.open("", "") self._stage = JSConstructor(GFX.Container)() self.width = width if width != 0 else int(window.innerWidth * 0.9) self.height = height if height != 0 else int(window.innerHeight * 0.9) self._renderer = GFX.autoDetectRenderer(self.width, self.height, {'transparent':True}) self._w.document.body.appendChild(self._renderer.view) consoleArea = self._w.document.createElement('DIV') self.consoleText = self._w.document.createElement('TEXTAREA') self.consoleText.id = "textarea" self.consoleText.readonly = True consoleArea.appendChild(self.consoleText) style = self._w.document.createElement('STYLE') css = 'div {width: 300px; height: 100%; background-color: black; position: fixed; right: 0; top: 0;} #textarea {color: white; background-color: rgba(0,0,0,0); width: 260px; height: 810px; position: fixed; top: 20px; right: 20px; margin: 0px; resize: none; border: none; outline: none;}' style.type = 'text/css' style.appendChild(document.createTextNode(css)) self._w.document.head.appendChild(style) self._w.document.body.appendChild(consoleArea) self._w.onunload = onclose #if didLoadPyinput: # winput_init() self._w.document.body.insertAdjacentHTML('beforeend', '<div id = "inputScreen" style = "display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.2); z-index: 50;"><div style = "position: fixed; left: calc(50% - 150px); top: calc(50% - 75px); background-color: white;"><p id = "toPrompt"></p><input type = "text" id = "toInput"><input type = "submit" id = "toSubmit"></div></div>')
def __init__(self, width, height, onclose): self._w = window.open("", "") self._stage = JSConstructor(GFX.Container)() self._renderer = GFX.autoDetectRenderer(width, height, {'transparent':True}) self._w.document.body.appendChild(self._renderer.view) self._w.onunload = onclose
from browser import window content = open("2016fallcadpb_groups.txt").read() #print(content) result = content.splitlines() data = "" n = 1 for line in result: group = line.split(":")[1][:-1].split(",") #print(group) for i in range(len(group)): if i == 0: data += "第" + str(n) + "組組長為" + group[i] data += "<br /><a href='https://github.com/" + group[ i] + "/2016fallcadp_bg" + str(n) + "'>bg" + str( n) + "分組倉儲</a><br /><br />" data += "組員有" + group[i] + "," n = n + 1 window.open().document.write(data)
# 因為經由 zip 逐一重新 transpose 的列資料, 必須配合最大 (也就是總共有 7 列, 也就是 N 的值) 列數補上空白字串 (也就是空位) # 所以不能使用 zip, 而必須導入 zip_longest 模組方法 from itertools import zip_longest final_seat = list(zip_longest(*column_list[::-1], fillvalue="")) # 列出最後的座位表 #g.es(final_seat) # 最後轉成 html table 標註格式 out_string += "<br /> <br />" out_string += "<table border='1' width='100%'>" out_string += "<tr><td colspan='9' style='text-align:center'>講台</td></tr>" for row in range(len(final_seat)): out_string += "<tr>" # 因為每一 row 有 9, 也就是 total_column 個位子 for i in range(total_column): try: if i%2 != 0: out_string += "<td style='text-align:center' bgcolor='#FFD78C' height='30'>" + str(final_seat[row][i]) + "</td>" else: out_string += "<td style='text-align:center' height='30'>" + str(final_seat[row][i]) + "</td>" except: out_string += "<td> </td>" out_string += "</tr>" out_string += "</table><br /><br /><br />" out_string += "</body></html>" return out_string # 等運算或資料處理結束後, 再將相關值送到對應的 template 進行資料的展示 #return render_template('optionaction.html', option_list1=option_list1, option_list2=option_list2) # 開啟新視窗, 並將 openaction() 執行後傳回的字串, # 寫到新的視窗中 window.open().document.write(optionaction()) #print(optionaction())
def popup(event): window.open('popup.html', 'popup', 'scrollbars=no')
def tabs(event): window.open('#', '_blank')
def email_kaya(self,ev): stringk = self.uenc('Hi Kaya,\nHere are the results from '+self.subjects[0].name+':\n') stringk += self.uenc(self.results()) #print('sk',stringk) window.open('mailto:[email protected]?subject=Results&body='+stringk,'Sending to Kaya') self.web_email('Kaya: [email protected]')
def email_sophie(self,ev): strings = self.uenc('Hi Sophie,\nHere are the results from '+self.subjects[0].name+':\n') strings += self.uenc(self.results()) #print('ss',stringk) window.open('mailto:[email protected]?subject=Results&body='+strings,'Sending to Sophie') self.web_email('Sophie: [email protected]')
from browser import window, document from random import randint from javascript import JSObject, JSConstructor w = window.open("", "") PIXI = JSObject(window.PIXI) Stage = JSConstructor(PIXI.Container) Sprite = JSConstructor(PIXI.Sprite) GRAPHICS = JSConstructor(PIXI.Graphics) STAGE = Stage() RENDERER = PIXI.autoDetectRenderer(1000, 650, {'transparent': True}) w.document.body.appendChild(RENDERER.view) nloops = 0 def animate(fake): w.requestAnimationFrame(animate) for s in sprites: s.poll() RENDERER.render(STAGE) class BunnySprite(object): def __init__(self, stage, x, y): self.sprite = Sprite(PIXI.Texture.fromImage("bunny.png", False)) self.sprite.interactive = True self.sprite.anchor.x = 0.5 self.sprite.anchor.y = 0.5
# 所以不能使用 zip, 而必須導入 zip_longest 模組方法 from itertools import zip_longest final_seat = list(zip_longest(*column_list[::-1], fillvalue="")) # 列出最後的座位表 #g.es(final_seat) # 最後轉成 html table 標註格式 out_string += "<br /> <br />" out_string += "<table border='1' width='100%'>" out_string += "<tr><td colspan='9' style='text-align:center'>講台</td></tr>" for row in range(len(final_seat)): out_string += "<tr>" # 因為每一 row 有 9, 也就是 total_column 個位子 for i in range(total_column): try: if i%2 != 0: out_string += "<td style='text-align:center' bgcolor='#FFD78C' height='30'>" + str(final_seat[row][i]) + "</td>" else: out_string += "<td style='text-align:center' height='30'>" + str(final_seat[row][i]) + "</td>" except: out_string += "<td> </td>" out_string += "</tr>" out_string += "</table><br /><br /><br />" out_string += "</body></html>" return out_string # 等運算或資料處理結束後, 再將相關值送到對應的 template 進行資料的展示 #return render_template('optionaction.html', option_list1=option_list1, option_list2=option_list2) # 開啟新視窗, 並將 openaction() 執行後傳回的字串, # 寫到新的視窗中 window.open().document.write(optionaction(group_data)) #print(optionaction())
def open_new(url): return window.open(url, "_blank")
def open(url, new=0, autoraise=True): window.open(url)
#g.es(final_seat) # 最後轉成 html table 標註格式 out_string += "<br /> <br />" out_string += "<table border='1' width='100%'>" out_string += "<tr><td colspan='9' style='text-align:center'>講台</td></tr>" for row in range(len(final_seat)): out_string += "<tr>" # 因為每一 row 有 9, 也就是 total_column 個位子 for i in range(total_column): try: if i % 2 != 0: out_string += "<td style='text-align:center' bgcolor='#FFD78C' height='30'>" + str( final_seat[row][i]) + "</td>" else: out_string += "<td style='text-align:center' height='30'>" + str( final_seat[row][i]) + "</td>" except: out_string += "<td> </td>" out_string += "</tr>" out_string += "</table><br /><br /><br />" out_string += "</body></html>" return out_string # 等運算或資料處理結束後, 再將相關值送到對應的 template 進行資料的展示 #return render_template('optionaction.html', option_list1=option_list1, option_list2=option_list2) # 開啟新視窗, 並將 openaction() 執行後傳回的字串, # 寫到新的視窗中 window.open().document.write(optionaction(group_data)) #print(optionaction())
#g.es(final_seat) # 最後轉成 html table 標註格式 out_string += "<br /> <br />" out_string += "<table border='1' width='100%'>" out_string += "<tr><td colspan='9' style='text-align:center'>講台</td></tr>" for row in range(len(final_seat)): out_string += "<tr>" # 因為每一 row 有 9, 也就是 total_column 個位子 for i in range(total_column): try: if i % 2 != 0: out_string += "<td style='text-align:center' bgcolor='#FFD78C' height='30'>" + str( final_seat[row][i]) + "</td>" else: out_string += "<td style='text-align:center' height='30'>" + str( final_seat[row][i]) + "</td>" except: out_string += "<td> </td>" out_string += "</tr>" out_string += "</table><br /><br /><br />" out_string += "</body></html>" return out_string # 等運算或資料處理結束後, 再將相關值送到對應的 template 進行資料的展示 #return render_template('optionaction.html', option_list1=option_list1, option_list2=option_list2) # 開啟新視窗, 並將 openaction() 執行後傳回的字串, # 寫到新的視窗中 window.open().document.write(optionaction()) #print(optionaction())
from browser import window, WindowAnimationRunner from math import cos, sin, floor from random import random THREE = window.THREE glwin = window.open("","","width=1200,height=800") # Global variables camera = THREE.OrthographicCamera(-1.0, 1.0, 1.0, -1.0, -500.0, 1000.0) camera.position.x = 200.0 camera.position.y = 100.0 camera.position.z = 200.0 renderer = THREE.WebGLRenderer({"antialias": True}) renderer.setClearColor(THREE.Color(0xFFFFFF), 1.0) scene = THREE.Scene() progressEnd = 10 def onWindowResize(event): halfW = glwin.innerWidth / 2 halfH = glwin.innerHeight / 2 camera.left = -halfW camera.right = halfW camera.top = halfH camera.bottom = -halfH camera.updateProjectionMatrix() renderer.setSize(glwin.innerWidth, glwin.innerHeight) def setUp():