Beispiel #1
0
    def __init__(self, container=document.body, parent=None):
        self.container = container
        self.parent = parent
        if parent is None:
            self._table = html.TABLE(Class="menu-table")
            self.panel = html.TR(Class="menu-row")
            self._table <= self.panel
            self.container <= self._table

            self.panel.bind("mouseover", self.hide_submenus)

            document.bind("click", self.reset)

        else:
            self.panel = html.TABLE(Class="menu-table")
            self.container <= self.panel

        @bind(self.panel, "click")
        def click(evt):
            evt.stopPropagation()

        cstyle = window.getComputedStyle(self.container)
        self.fontSize = cstyle.getPropertyValue('font-size')
        self.selecting = False
        container.open_child = None
Beispiel #2
0
    def __init__(self, title="", style={}, top=0, left=0, ok_cancel=False):
        for key in style:
            for item in styles:
                styles[item][key] = style[key]
        html.DIV.__init__(self, style=styles["dialog"])
        self.left = left
        self.top = top
        self._title = html.DIV(html.SPAN(title), style=styles["title"])
        self <= self._title
        btn = html.SPAN("&times;", style=styles["close"])
        self._title <= btn
        btn.bind("click", self.close)
        self.panel = html.DIV(style=styles["panel"])
        self <= self.panel

        if ok_cancel:
            ok_cancel_zone = html.DIV(style={"text-align": "center"})
            self.ok_button = html.BUTTON("Ok")
            self.cancel_button = html.BUTTON("Cancel")
            self.cancel_button.bind("click", self.close)
            ok_cancel_zone <= self.ok_button + self.cancel_button
            self <= ok_cancel_zone

        document <= self
        self._title.bind("mousedown", self.mousedown)
        document.bind("mousemove", self.mousemove)
        self._title.bind("mouseup", self.mouseup)
        self.bind("leave", self.mouseup)
        self.is_moving = False
Beispiel #3
0
 def mousedown(self, event):
     document.bind("mousemove", self.mousemove)
     document.bind("touchmove", self.mousemove)
     self.is_moving = True
     self.initial = [self.left - event.x, self.top - event.y]
     # prevent default behaviour to avoid selecting the moving element
     event.preventDefault()
    def __init__(self, container=document.body, parent=None, default_css=True):
        """Create a new menu, inserted inside the container. For the top level
        menu, parent is None, otherwise it is a SPAN element (top menu) or a
        TR element (submenu)."""
        self.container = container
        self.parent = parent

        if default_css:
            # Insert default CSS stylesheet if not already loaded
            for stylesheet in document.styleSheets:
                if stylesheet.ownerNode.id == "brython-menu":
                    break
            else:
                document <= html.STYLE(style_sheet, id="brython-menu")

        self.default_css = default_css

        if parent:
            parent.submenu = html.TABLE(Class="brython-menu-submenu")
            parent.submenu.style.position = "absolute"
            parent.submenu.style.display = "none"
            self.container <= parent.submenu

            parent.bind("click", self.unfold)

        if not hasattr(self.container, "bind_document"):
            # Click on the document outside of the menu removes all submenus
            document.bind("click", self.hide_menus)
            self.container.bind_document = True
Beispiel #5
0
    def __init__(self, container=None, parent=None):
        self.container = container
        self.parent = parent
        self.panel = html.UL(style=st1)
        self.container <= self.panel

        document.bind("click", self.hide_menus)
    def __init__(self):
        self.commands = []

        # get the canvas element
        self.canvas = document["canvas"]
        self.ctx = self.canvas.getContext('2d')

        self.width = self.canvas.width
        self.height = self.canvas.height

        self.timer_id = None

        self.resources = {}
        self.loadingResources = 0

        self.keys = dict([(a, False) for a in range(255)] +
                         [(a, False) for a in range(0xff00, 0xffff)])

        document.bind("keydown", self._keydown)
        document.bind("keyup", self._keyup)

        self.soundPlayers = {}

        # clear to cornflower blue (XNA!) by default
        self.__clear(0.392, 0.584, 0.929)
Beispiel #7
0
    def __init__(self):
        global test_buff, PyAngeloWorker, array

        self.commands = []

        # get the canvas element
        self.canvas = document["canvas"]
        self.ctx = self.canvas.getContext('2d')

        self.width = self.canvas.width
        self.height = self.canvas.height

        self.timer_id = None

        self.stopped = False

        self.resources = {}
        self.loadingResources = 0

        self.keys = dict([(a, False) for a in range(255)] +
                         [(a, False) for a in range(0xff00, 0xffff)])

        document.bind("keydown", self._keydown)
        document.bind("keyup", self._keyup)

        self.soundPlayers = {}

        self.state = self.STATE_WAIT
        self.anim_timer = 0
        self.anim_time = 200

        self.starting_text = "Starting up"
        self.loading_text = "Loading resources"

        #timer.set_interval(self.update, 16)

        # clear to cornflower blue (XNA!) by default
        self.__clear(0.392, 0.584, 0.929)

        keys_buff = window.SharedArrayBuffer.new(512)
        array = window.Int8Array.new(keys_buff)

        window.console.log("Attempting to send shared data")

        PyAngeloWorker.send(keys_buff)
        #PyAngeloWorker.send(input_buff)

        self.pixel_id = self.ctx.createImageData(1, 1)
        self.pixel_color = self.pixel_id.data

        self.last_frame_commands = []

        self.just_halted = False

        self.input_concluded = False

        self.input_buffer_index = 0

        timer.request_animation_frame(self.update)
Beispiel #8
0
    def __init__(self, id=None, style={}):
        default_style = dict(position='relative', height='auto', width='auto')
        default_style.update(style)
        html.UL.__init__(self, Class="ui-widget ui-menu", style=default_style)

        widget.Widget.__init__(self, self, 'menu', id)
        document.bind('click', self.leave)
        self.active = False
Beispiel #9
0
def main():
    document.bind('keypress', keypress_handler)
    update_game_names(loop=True, select_newest=True)
    window._animate_lock = False
    favorites.update_button.bind('click', update_button_handler)
    favorites.keyboard_help_button.bind('click', keyboard_help_button_handler)

    timer.request_animation_frame(window.animate)
Beispiel #10
0
 def __init__(self, id=None, style={}):
     default_style = dict(position= 'relative', height='auto',
         width='auto')
     default_style.update(style)
     html.UL.__init__(self, Class="ui-widget ui-menu", style=default_style)
 
     widget.Widget.__init__(self, self, 'menu', id)
     document.bind('click', self.leave)
     self.active = False
Beispiel #11
0
 def __init__(self):
     self.x1 = 100
     self.y1 = 40
     self.ambiente = Cena(self.CENA_corredor_1)
     self.boneco = Elemento(self.BONECO,
                            x=self.x1,
                            y=self.y1,
                            cena=self.ambiente)
     document.bind("keydown",
                   self.anda_boneco)  # captura o evento de teclado
Beispiel #12
0
 def __init__(self):
     self.calcada = Cena(self.CENA_CALCADA, direita=cena)
     self.banhista = Elemento(self.BANHISTA, x=100, y=200, cena=self.calcada)
     self.dark_side = Elemento(self.DARK_SIDE, x=100, y=100, cena=self.calcada)
     self.dark_side.o = 0  # faz a opacidade virar zero, não mostra o letreiro
     document.bind("keydown", self.anda_banhista)  # captura o evento de teclado
     _ = self.banhista.img # ('https://i.imgur.com/chvIdvJ.png')
     self.banhista.elt.bind("mouseover", self.ve_dark)  # usa o evento para mostrar "dark side"
     self.banhista.elt.bind("mouseout", self.ve_dark)  # usa o mesmo evento para ocultar "dark side"
     self.muda = 1
Beispiel #13
0
 def __init__(self):
     self.x1 = 0
     self.y1 = 500
     self.fundo = Cena(FUNDO)
     self.personagem = Elemento(img=PERSONAGEM,
                                cena=self.fundo,
                                x=self.x1,
                                y=self.y1,
                                h=50,
                                w=50)
     document.bind("keydown", self.andapersonagem)
Beispiel #14
0
def show(path, zone, page_num=0):
    slideshow = Slideshow(path)

    if page_num < 0:
        page_num = 0
    elif page_num >= len(slideshow.pages):
        page_num = len(pages) - 1
    slideshow.page_num = page_num
    document.unbind('keydown')
    document.bind('keydown', lambda ev: keydown(ev, slideshow, zone))

    show_page(slideshow, zone, page_num)
Beispiel #15
0
def show(path, zone, page_num=0):
    slideshow = Slideshow(path)
    
    if page_num<0:
        page_num = 0
    elif page_num >= len(slideshow.pages):
        page_num = len(pages)-1
    slideshow.page_num = page_num
    document.unbind('keydown')
    document.bind('keydown',lambda ev:keydown(ev, slideshow, zone))

    show_page(slideshow, zone, page_num)
Beispiel #16
0
 def __init__(self):
     self.x1 = -50
     self.y1 = 200
     self.fundo = Cena(FUNDO)
     self.bonequinha = Elemento(img=BONEQUINHA,
                                cena=self.fundo,
                                x=self.x1,
                                y=self.y1,
                                h=200,
                                w=200)
     document.bind("keydown",
                   self.andaboneca)  # captura o evento de teclado
Beispiel #17
0
    def __init__(self):
        self.ambiente = Cena(self.CENA_corredor_1)
        self.pos_x = 100
        self.pos_y = 40
        self.boneco = Elemento(self.BONECO,
                               x=self.pos_x,
                               y=self.pos_y,
                               width,
                               height,
                               cena=self.ambiente)

        document.bind("keydown",
                      self.anda_boneco)  # captura o evento de teclado
Beispiel #18
0
    def __init__(self):
        """Gera o início do jogo com a posição do personagem e a primeira cena

           :return: self.boneco com parâmetros (personagem, poisção_x, posição_y, cenário)
        """
        self.x1 = 100
        self.y1 = 40
        self.ambiente = Cena(self.CENA_corredor_1)
        self.boneco = Elemento(self.BONECO,
                               x=self.x1,
                               y=self.y1,
                               cena=self.ambiente)
        document.bind("keydown",
                      self.anda_boneco)  # captura o evento de teclado
Beispiel #19
0
 def __init__(self):
     self.x1 = 0
     self.y1 = 460
     self.fundo = Cena(FUNDO)
     self.pena = Elemento(img=PENA,
                          cena=self.fundo,
                          x=200,
                          y=450,
                          h=80,
                          w=80)
     self.personagem = Elemento(img=PERSONAGEM,
                                cena=self.fundo,
                                x=self.x1,
                                y=self.y1,
                                h=100,
                                w=100)
     document.bind("keydown", self.andapersonagem)
Beispiel #20
0
    def __init__(self,
                 title="",
                 style={},
                 top=None,
                 left=None,
                 ok_cancel=False):
        for key in style:
            for item in styles:
                styles[item][key] = style[key]
        html.DIV.__init__(self, style=styles["dialog"])
        self._title = html.DIV(html.SPAN(title), style=styles["title"])
        self <= self._title
        btn = html.SPAN("&times;", style=styles["close"])
        self._title <= btn
        btn.bind("click", self.close)
        self.panel = html.DIV(style=styles["panel"])
        self <= self.panel

        if ok_cancel:
            ok_cancel_zone = html.DIV(style={"text-align": "center"})
            self.ok_button = html.BUTTON("Ok")
            self.cancel_button = html.BUTTON("Cancel")
            self.cancel_button.bind("click", self.close)
            ok_cancel_zone <= self.ok_button + self.cancel_button
            self <= ok_cancel_zone

        document <= self
        cstyle = window.getComputedStyle(self)

        # Center horizontally and vertically
        if left is None:
            width = round(float(cstyle.width[:-2]) + 0.5)
            left = int((window.innerWidth - width) / 2)
        self.left = left
        self.style.left = f'{left}px'
        if top is None:
            height = round(float(cstyle.height[:-2]) + 0.5)
            top = int((window.innerHeight - height) / 2)
        self.top = top
        self.style.top = f'{top}px'

        self._title.bind("mousedown", self.mousedown)
        document.bind("mousemove", self.mousemove)
        self._title.bind("mouseup", self.mouseup)
        self.bind("leave", self.mouseup)
        self.is_moving = False
 def start_game(self):  
     self.intro_count = 0        
     #make a new enemy
     self.new_problem()
     #bind the keys
     doc.bind("keydown", self.process_keyDown)
     doc.bind("keyup", self.process_keyUp)
     #queue up the introduction screens
     for x in range(5):
         self.popup_queue.append(self.intro)
     self.popup_queue.append(self.new_enemy_pokemon ) 
     self.ctx.font = "30px Calibri"
     self.ctx.fillStyle = "#000000"
     self.center_text("Press Enter To Begin", self.canvas.height/2)
     self.ctx.strokeStyle = "#000000"
     self.ctx.rect(0, 0, self.canvas.width, self.canvas.height)
     self.ctx.stroke()
Beispiel #22
0
    def on_mouse_down(self, event):
        global highest_z
        global captured

        captured = self

        self.start_x = event.clientX - self.note.offsetLeft
        self.start_y = event.clientY - self.note.offsetTop
        self.note.style.zIndex = highest_z
        highest_z = highest_z + 1

        if self.mouse_move_handler is None:
            self.mouse_move_handler = self.on_mouse_move
            self.mouse_up_handler = self.on_mouse_up

        document.bind('mousemove', self.mouse_move_handler)
        document.bind('mouseup', self.mouse_up_handler)
Beispiel #23
0
def save_sheet(dialog):
    document.bind('keydown', doc_keydown)
    sheet_name = dialog.get(selector='input')[0].value
    if not sheet_name.strip():
        d = ui.dialog.Dialog()
        d.set_title("Error")
        d.set_body("No sheet name provided")
        return

    if sheet_name in sheet_names():
        d = ui.dialog.YesNoDialog(
            "Save sheet",
            "A sheet named %s already exists. Override ?" % sheet_name,
            confirm_override, None)
        d.sheet_name = sheet_name
        return

    save_sheet_content(sheet_name)
Beispiel #24
0
def save_sheet(dialog):
    document.bind('keydown', doc_keydown)
    sheet_name = dialog.get(selector='input')[0].value
    if not sheet_name.strip():
        d = ui.dialog.Dialog()
        d.set_title("Error")
        d.set_body("No sheet name provided")
        return

    if sheet_name in sheet_names():
        d = ui.dialog.YesNoDialog("Save sheet",
            "A sheet named %s already exists. Override ?" %sheet_name,
            confirm_override,
            None)
        d.sheet_name = sheet_name
        return

    save_sheet_content(sheet_name)
Beispiel #25
0
def showartis(ev):
    if 'vertical-menu' in doc:
        del doc['vertical-menu']
    doc.unbind('mouseclick', custom_menu)

    ev.stopPropagation()
    # Set up artifact select
    arti = DIV(Id='vertical-menu', Class='vertical-menu')
    for art in artifacts:
        temp = DIV(strings[art],
                   Id=art,
                   data_id=ev.target.attrs["data-id"],
                   Class='vertical-menu menu-item')
        temp.bind('click', custom_menu)
        arti <= temp
    arti.top = ev.y
    arti.left = ev.x
    doc <= arti
    doc.bind('click', custom_menu)
Beispiel #26
0
    def __init__(self, container=document.body, parent=None, level=0):
        """Create a new menu, inserted inside the container. For the top level
        menu, parent is None, otherwise it is a SPAN item."""
        self.container = container
        self.level = level
        self.parent = parent
        self.submenus = []

        if parent:
            self.submenu = html.DIV(Class="sub")
            if "menu-submenu" in css:
                self.submenu.classList.add(css["menu-submenu"])
            self.submenu.style.position = "absolute"
            self.submenu.style.display = "none"
            self.container <= self.submenu

            parent.bind("click", self.unfold)

        if not hasattr(self.container, "bind_document"):
            document.bind("click", self.hide_menus)
            self.container.bind_document = True
def show(path, zone, page_num=None):
    slideshow = Slideshow(path)

    if page_num is None:
        page_num = 0
        # check if page num was stored in a cookie
        cookies = document.cookie
        if cookies:
            elts = dict([x.strip() for x in cookie.split('=')]
                        for cookie in cookies.split(";"))
            if "page" in elts:
                page_num = int(elts["page"])
    if page_num < 0:
        page_num = 0
    elif page_num >= len(slideshow.pages):
        page_num = len(pages) - 1

    slideshow.page_num = page_num
    document.unbind('keydown')
    document.bind('keydown', lambda ev: keydown(ev, slideshow, zone))

    show_page(slideshow, zone, page_num)
def show(path, zone, page_num=None):
    slideshow = Slideshow(path)
    
    if page_num is None:
        page_num = 0
        # check if page num was stored in a cookie
        cookies = document.cookie
        if cookies:
            elts = dict([x.strip() for x in cookie.split('=')] 
                for cookie in cookies.split(";"))
            if "page" in elts:
                page_num = int(elts["page"])
    if page_num < 0:
        page_num = 0
    elif page_num >= len(slideshow.pages):
        page_num = len(slideshow.pages) - 1

    slideshow.page_num = page_num
    document.unbind('keydown')
    document.bind('keydown',lambda ev:keydown(ev, slideshow, zone))
    
    show_page(slideshow, zone, page_num)
Beispiel #29
0
    storage["brython_spreadsheet%s" % sheet_name] = json.dumps(info)
    document["sheet_name"].text = sheet_name


current_menu = None


def stop_menu(*args):
    global current_menu
    if current_menu:
        current_menu.close()
    current_menu = None


document.bind("keydown", doc_keydown)
document.bind("click", stop_menu)

menu_file = None


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")
Beispiel #30
0
        event.target.class_name = 'colour-btn'
    else:
        event.target.class_name = 'colour-btn checked'

def toggleBoardSettings(event):
    event.preventDefault()
    current = document['boardSettingsPanel'].style.display
    document['boardSettingsPanel'].style.display = 'none' if current == 'block' else 'block'

document['boardSettingsBtn'].bind('click', toggleBoardSettings)

def hideBoardSettings(event):
    if event.target.id != 'boardSettingsBtn' and event.target.parent.id != 'boardSettingsBtn':
        document['boardSettingsPanel'].style.display = 'none'

document.bind('click', hideBoardSettings)

def setSelectedBackgroundModal(selected_id):
    document['background-1'].class_name = document['background-1'].class_name = 'background-select-image'
    document['background-2'].class_name = document['background-2'].class_name = 'background-select-image'
    document['background-3'].class_name = document['background-3'].class_name = 'background-select-image'
    document['background-4'].class_name = document['background-4'].class_name = 'background-select-image'
    document['background-{0}'.format(selected_id)].class_name += ' selected'

    selected = [opt for opt in document['boardSelect'] if hasattr(opt, 'value') and opt.value == document['boardSelect'].value].pop()
    selected.data_background = selected_id
    document['body'].class_name = 'background-{0}'.format(selected_id)

    req = ajax.ajax()
    req.open('POST', '/bgchange', True)
    req.set_header('content-type', 'application/x-www-form-urlencoded')
Beispiel #31
0
            else:
                zone.style.cursor = 'default'

        elif self.tool == 'rubber':
            ctx.strokeStyle = '#808'
            ctx.rect(X-zleft, Y-ztop,
                self.rubber_size, self.rubber_size)
            ctx.fill()


def no_sel(ev):
    ev.preventDefault()
    ev.stopPropagation()

# avoid default behaviour to select text when dragging mouse 
document.bind('mousedown', no_sel)
document.bind('mousemove', no_sel)
document.bind('touchmove', no_sel)

def pick_rgb(ev, tool):
    div = ev.target
    x, y = panel.mouse_pos(ev)
    current = getattr(panel, tool).strip('#')
    color_elts = [current[i:i+2] for i in (0, 2, 4)]
    
    rgb = int(256*((x-div.abs_left)/div.width))
    
    # move slider
    slider = div.get(selector='DIV')[0]
    slider.left = int(div.width*rgb/256)
    
Beispiel #32
0
def cancel_save_as(dialog):
    document.bind('keydown', doc_keydown)
    dialog.close()
Beispiel #33
0
    storage['brython_spreadsheet%s' % sheet_name] = json.dumps(info)
    document['sheet_name'].text = sheet_name


current_menu = None


def stop_menu(*args):
    global current_menu
    if current_menu:
        current_menu.close()
    current_menu = None


document.bind('keydown', doc_keydown)
document.bind('click', stop_menu)

menu_file = None


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")
Beispiel #34
0
def cancel_save_as(dialog):
    document.bind('keydown', doc_keydown)
    dialog.close()
Beispiel #35
0
 def mouseDown(e):
     self._element.style.position='absolute'
     self._deltaX=e.clientX - self._element.offsetLeft
     self._deltaY=e.clientY - self._element.offsetTop
     doc.bind('mousemove', drag)
Beispiel #36
0
run = None


def change(event):
    if event.keyCode == 39:
        global run
        if run is None:
            # start animation
            animloop(1)
        else:
            # stop animation
            window.cancelAnimationFrame(run)
            run = None


document.bind("keydown", change)


def render():
    global x, dx
    moving.style.transform = "translate({}px,0)".format(x)
    x += dx
    if x > document["zone15"].offsetWidth - moving.offsetWidth:
        dx = -dx
        moving.html = "&#9668;"  # left triangle
    elif x <= 0:
        dx = -dx
        moving.html = "&#9658;"  # right triangle


def animloop(t):
Beispiel #37
0
	appKey, hmacKey = [line.strip() for line in inFile.readlines()][:2]
	inFile.close()
	return appKey, hmacKey

if __name__ == "__main__":
	pixelRatio = window.devicePixelRatio
	canvas = document.getElementById("canvas")
	context = canvas.getContext("2d")
	canvas.width = window.innerWidth * pixelRatio
	canvas.height = window.innerHeight * pixelRatio
	alert([window.innerWidth, window.innerHeight])
	pointerId = 0
	instanceId = 0
	appKey, hmacKey = getAPIKeys()
	
	MyScript = window.MyScript
	inkManager = JSConstructor(MyScript.InkManager)()
	shapeRenderer = JSConstructor(MyScript.ShapeRenderer)()
	shapeRecognizer = JSConstructor(MyScript.ShapeRecognizer)()
	resetScribble()
	
	document.bind("touchstart", disableScrolling)
	
	canvas.bind("touchstart", touchStart)
	canvas.bind("touchmove", touchMove)
	canvas.bind("touchend", touchEnd)
	canvas.bind("touchleave", touchLeave)
	
	submit = document.getElementById("toolbarSubmit")
	submit.bind("touchend", submitScribble)
Beispiel #38
0
        for j, cell in enumerate(row.get(selector='TD')):
            if cell.info['entry']:
                info.append([i, j, cell.info['entry']])

    storage['brython_spreadsheet%s' %sheet_name] = json.dumps(info)
    document['sheet_name'].text = sheet_name
    
current_menu = None

def stop_menu(*args):
    global current_menu
    if current_menu:
        current_menu.close()
    current_menu = None

document.bind('click', stop_menu)

menu_file = None

RegExp = window.RegExp.new
String = window.String.new

def clear_selections():

    for klass in ("column-select", "selected", "row-select", "selection-top",
            "selection-bottom", "selection-left", "selection-right"):
        for cell in document.get(selector="."+klass):
            cell.classList.remove(klass)
    
mouseDown = 0
selected_line = None
Beispiel #39
0
            else:
                zone.style.cursor = 'default'

        elif self.tool == 'rubber':
            ctx.strokeStyle = '#808'
            ctx.rect(X-zleft, Y-ztop,
                self.rubber_size, self.rubber_size)
            ctx.fill()


def no_sel(ev):
    ev.preventDefault()
    ev.stopPropagation()

# avoid default behaviour to select text when dragging mouse 
document.bind('mousedown', no_sel)
document.bind('mousemove', no_sel)
document.bind('touchmove', no_sel)

def pick_rgb(ev, tool):
    div = ev.target
    x, y = panel.mouse_pos(ev)
    current = getattr(panel, tool).strip('#')
    color_elts = [current[i:i+2] for i in (0, 2, 4)]
    
    rgb = int(256*((x-div.abs_left)/div.width))
    
    # move slider
    slider = div.get(selector='DIV')[0]
    slider.left = int(div.width*rgb/256)
    
    def __init__(self):

        self.commands = []

        # get the canvas element
        self.canvas = document["canvas"]
        self.ctx = self.canvas.getContext('2d')

        self.width = self.canvas.width
        self.height = self.canvas.height

        self.timer_id = None
        self.main_loop = None

        self.stopped = False

        self.resources = {}
        self.loadingResources = 0

        self.keys = dict([(a, False) for a in range(255)] +
                         [(a, False) for a in range(0xff00, 0xffff)])
        self.keys[KEY_V_LEFT] = False
        self.keys[KEY_V_RIGHT] = False
        self.keys[KEY_V_UP] = False
        self.keys[KEY_V_DOWN] = False
        self.keys[KEY_V_FIRE] = False

        document.bind("keydown", self._keydown)
        document.bind("keyup", self._keyup)

        self.mouse_x = 0
        self.mouse_y = 0
        document.bind("mousedown", self._mousedown)
        document.bind("mouseup", self._mouseup)
        document.bind("mousemove", self._mousemove)

        self.touches = {}

        document.bind("touchstart", self._touchstart)
        document.bind("touchend", self._touchend)
        document.bind("touchmove", self._touchmove)

        self.soundPlayers = {}

        self.state = self.STATE_STOP
        self.anim_timer = 0
        self.anim_time = 200

        self.starting_text = "Starting up"
        self.loading_text = "Loading resources"

        # clear to cornflower blue (XNA!) by default
        self.clear(0.392, 0.584, 0.929)

        self.pixel_id = self.ctx.createImageData(1, 1)
        self.pixel_color = self.pixel_id.data

        self.last_frame_commands = []

        self.just_halted = False

        self.input_concluded = False

        self.input_buffer_index = 0

        self.loading_filename = ""

        timer.request_animation_frame(self.update)
Beispiel #41
0
from browser import document


def exists(obj, attName):
    try:
        getattr(obj, attName)
        return True
    except AttributeError:
        return False


def goFull():
    docelem = document.documentElement
    try:
        document.fullscreenElement
    except AttributeError:
        if exists(docelem, 'requestFullscreen'):
            docelem.requestFullscreen()
        elif exists(docelem, 'mozRequestFullScreen'):
            docelem.mozRequestFullScreen()
        elif exists(docelem, 'webkitRequestFullscreen'):
            docelem.webkitRequestFullscreen()
        elif exists(docelem, 'msRequestFullscreen'):
            docelem.msRequestFullscreen()


document.bind('click', goFull)
Beispiel #42
0
        for j, cell in enumerate(row.get(selector='TD')):
            if cell.info['entry']:
                info.append([i, j, cell.info['entry']])

    storage['brython_spreadsheet%s' %sheet_name] = json.dumps(info)
    document['sheet_name'].text = sheet_name
    
current_menu = None

def stop_menu(*args):
    global current_menu
    if current_menu:
        current_menu.close()
    current_menu = None

document.bind('keydown', doc_keydown)
document.bind('click', stop_menu)

menu_file = None

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")
    
Beispiel #43
0
 def mouseDown(e):
     self._element.style.position = 'absolute'
     self._deltaX = e.clientX - self._element.offsetLeft
     self._deltaY = e.clientY - self._element.offsetTop
     doc.bind('mousemove', drag)