def render(self, _=None): for js_url in self.get_js_dependencies(): load(constants.DEFAULT_HOST + '/' + js_url + ".js") while doc['me'].hasChildNodes(): doc['me'].removeChild(doc['me'].lastChild) self.draw()
def render(self, path="render.html"): """ Produce rendered charts in a html file :param path: :return: """ for js_url in self.get_js_dependencies(): load(constants.DEFAULT_HOST + '/' + js_url + ".js") while doc['me'].hasChildNodes(): doc['me'].removeChild(doc['me'].lastChild) self.draw()
import sys import time import traceback import javascript import random import json from browser import document, window, alert, timer, bind, html, load from browser.local_storage import storage load("howler.js") # In web workers, "window" is replaced by "self". import time #from browser import bind, self import sys import time import traceback import javascript import random import json import copy from browser import bind, self, window from pyangelo_consts import * class PyAngeloImage(): def __init__(self, image, sprite): self.img = image self.height = image.naturalHeight
document <= html.LINK(rel="stylesheet", href=_path + 'css/smoothness/jquery-ui.css') # The scripts must be loaded in blocking mode, by using the function # load(script_url[, names]) in module javascript # If we just add them to the document with script tags, eg : # # document <= html.SCRIPT(sciprt_url) # _jqui = window.jQuery.noConflict(True) # # the name "jQuery" is not in the Javascript namespace until the script is # fully loaded in the page, so "window.jQuery" raises an exception # Load jQuery and put name 'jQuery' in the global Javascript namespace load(_path + 'jquery-1.11.2.min.js', ['jQuery']) load(_path + 'jquery-ui.min.js') _jqui = window.jQuery.noConflict(True) _events = [ 'abort', 'beforeinput', 'blur', 'click', 'compositionstart', 'compositionupdate', 'compositionend', 'dblclick', 'error', 'focus', 'focusin', 'focusout', 'input', 'keydown', 'keyup', 'load', 'mousedown', 'mouseenter', 'mouseleave', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'resize', 'scroll', 'select', 'unload' ] class JQFunction: def __init__(self, func):
import sys import time import traceback import javascript import random import json from browser import document, window, alert, timer, worker, bind, html, load from browser.local_storage import storage load("js/howler.js") # In web workers, "window" is replaced by "self". import time #from browser import bind, self import sys import time import traceback import javascript import random import json import copy from browser import bind, self, window from pyangelo_consts import * from AngeloTurtle import * PyAngeloWorker = worker.Worker("executor") my_turtle = AngeloTurtle()
document <= html.LINK(rel="stylesheet", href=_path+'css/smoothness/jquery-ui.css') # The scripts must be loaded in blocking mode, by using the function # load(script_url[, names]) in module javascript # If we just add them to the document with script tags, eg : # # document <= html.SCRIPT(sciprt_url) # _jqui = window.jQuery.noConflict(True) # # the name "jQuery" is not in the Javascript namespace until the script is # fully loaded in the page, so "window.jQuery" raises an exception # Load jQuery and put name 'jQuery' in the global Javascript namespace load(_path+'jquery-1.11.2.min.js') load(_path+'jquery-ui.min.js') _jqui = window.jQuery.noConflict(True) _events = ['abort', 'beforeinput', 'blur', 'click', 'compositionstart', 'compositionupdate', 'compositionend', 'dblclick', 'error', 'focus', 'focusin',
document <= html.LINK(rel="stylesheet", href=_path + 'css/smoothness/jquery-ui.css') # The scripts must be loaded in blocking mode, by using the function # load(script_url[, names]) in module javascript # If we just add them to the document with script tags, eg : # # document <= html.SCRIPT(sciprt_url) # _jqui = window.jQuery.noConflict(True) # # the name "jQuery" is not in the Javascript namespace until the script is # fully loaded in the page, so "window.jQuery" raises an exception # Load jQuery and put name 'jQuery' in the global Javascript namespace load(_path + 'jquery-1.11.2.min.js') load(_path + 'jquery-ui.min.js') _jqui = window.jQuery.noConflict(True) _events = [ 'abort', 'beforeinput', 'blur', 'click', 'compositionstart', 'compositionupdate', 'compositionend', 'dblclick', 'error', 'focus', 'focusin', 'focusout', 'input', 'keydown', 'keyup', 'load', 'mousedown', 'mouseenter', 'mouseleave', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'resize', 'scroll', 'select', 'unload' ] class JQFunction: def __init__(self, func):
import sys import time import traceback import javascript import random import json import math from vector import * from browser import document, window, alert, timer, worker, bind, html, load from browser.local_storage import storage load("howler.js") load("js/planck-with-testbed.js") # Cursor control and motion KEY_HOME = 0xff50 KEY_ESC = 27 KEY_LEFT = 37 KEY_UP = 38 KEY_RIGHT = 39 KEY_DOWN = 40 KEY_W = 87 KEY_A = 65 KEY_C = 67 KEY_S = 83 KEY_D = 68 KEY_PAGEUP = 0xff55 KEY_PAGEDOWN = 0xff56 KEY_END = 0xff57
def module_exists(module_name): try: __import__(module_name) except ImportError: return False else: return True if module_exists("browser") and module_exists("javascript"): from browser import window, document, load from javascript import JSObject, JSConstructor load("https://cdnjs.cloudflare.com/ajax/libs/pixi.js/3.0.11/pixi.min.js") load("https://cdnjs.cloudflare.com/ajax/libs/buzz/1.1.10/buzz.min.js") major = window.__BRYTHON__.implementation[0] minor = window.__BRYTHON__.implementation[1] if major == 3 and minor >= 3 or major > 3: GFX = window.PIXI GFX_Rectangle = GFX.Rectangle.new GFX_Texture = GFX.Texture.new GFX_Texture_fromImage = GFX.Texture.fromImage.new GFX_Sprite = GFX.Sprite.new GFX_Graphics = GFX.Graphics.new() GFX_Text = GFX.Text.new GFX_NewStage = GFX.Container.new SND = window.buzz SND_Sound = SND.sound.new else: GFX = JSObject(window.PIXI)
def module_exists(module_name): try: __import__(module_name) except ImportError: return False else: return True if module_exists('browser') and module_exists('javascript'): from browser import window, document, load from javascript import JSObject, JSConstructor #load("https://cdnjs.cloudflare.com/ajax/libs/pixi.js/3.0.5/pixi.min.js") #load("https://cdnjs.cloudflare.com/ajax/libs/buzz/1.1.10/buzz.min.js") #load("static/pixi-4.8.2.min.js") load("static/pixi-3.0.5.min.js") load("static/buzz-1.2.1.js") major = window.__BRYTHON__.implementation[0] minor = window.__BRYTHON__.implementation[1] if major == 3 and minor >= 3 or major > 3: GFX = window.PIXI GFX_Rectangle = GFX.Rectangle.new GFX_Texture = GFX.Texture.new GFX_Texture_fromImage = GFX.Texture.fromImage.new GFX_Sprite = GFX.Sprite.new GFX_Graphics = GFX.Graphics.new() GFX_Text = GFX.Text.new GFX_NewStage = GFX.Container.new SND = window.buzz SND_Sound = SND.sound.new else:
for rule in self.lexer.rules: match = rule.matches(self.s, self.idx) if match: self.idx = match[1] source_pos = match[0] token = Token(rule.name, self.s[match[0]:match[1]], source_pos) return token else: raise LexingError(None, self.idx) __next__ = next try: # Brython from browser import window, load load("rply_re.js") exec_regexp = window.exec_regexp class Rule(object): def __init__(self, name, pattern, flags=0): self.name = name if not pattern.startswith("^"): pattern = "^" + pattern self.re = window.RegExp.new(pattern) #, flags) def matches(self, s, pos): m = exec_regexp(self.re, s[pos:]) if m: return pos + m[0], pos + m[0] + m[1] return None except: import re