def bind_load_visible_devices_on_scroll(): console.log("load_visible_devices_on_scroll") def scrolled_timeout(): global scrolling_timeout scrolling_timeout = None load_visible_macs() def window_scrolled(event): global scrolling_timeout if scrolling_timeout: clear_timeout(scrolling_timeout) scrolling_timeout = set_timeout(scrolled_timeout, 500) window.bind('scroll', window_scrolled)
def addHandler(self, handler): """ Registers an object to handle events for the object. @param handler EventHandler: the event handler object. @return None """ def keyPress(ev): callHandlerWithOrWithoutEvent(handler.handleKeyPress, Event(ev)) def keyRelease(ev): callHandlerWithOrWithoutEvent(handler.handleKeyRelease, Event(ev)) def mouseDrag(ev): callHandlerWithOrWithoutEvent(handler.handleMouseDrag, Event(ev)) def mouseEnter(ev): callHandlerWithOrWithoutEvent(handler.handleMouseEnter, Event(ev)) def mouseLeave(ev): callHandlerWithOrWithoutEvent(handler.handleMouseLeave, Event(ev)) def mouseMove(ev): callHandlerWithOrWithoutEvent(handler.handleMouseMove, Event(ev)) def mousePress(ev): callHandlerWithOrWithoutEvent(handler.handleMousePress, Event(ev)) def mouseRelease(ev): callHandlerWithOrWithoutEvent(handler.handleMouseRelease, Event(ev)) types = ['keydown', 'keyup', 'mouseenter', 'mouseleave', 'mousemove', 'mousedown', 'mouseup'] funcs = [keyPress, keyRelease, mouseEnter, mouseLeave, mouseMove, mousePress, mouseRelease] handler_methods = ['handleKeyPress', 'handleKeyRelease', 'handleMouseEnter', 'handleMouseLeave', 'handleMouseMove', 'handleMousePress', 'handleMouseRelease'] for i in range(len(handler_methods)): if getattr(handler, handler_methods[i]).__doc__ != 'Not Implemented': if 'Key' in handler_methods[i]: window.bind(types[i], funcs[i]) else: self._svgGraphic.bind(types[i], funcs[i])
def __init__(self, canvas): self.canvas = canvas self.context = canvas.getContext('2d') self.translation = [0, 0] self.nodes = [] self.connections = [] self.buttons = [] self.next_idx = 0 self.selected_obj = None self.selection_type = None self.mouse_held = False self.dragging = False self.mouse_pos = None self.created_transition = False canvas.bind('mousedown', self.mouse_down) canvas.bind('mouseup', self.mouse_up) canvas.bind('mousemove', self.mouse_move) # canvas.bind('contextmenu', self.context_menu) canvas.bind('keypress', self.key_press) window.bind('resize', self.resize)
if not todo["title"]: self.remove_todo(todo) def cancel_edit(self, todo): self.edited_todo = None todo.title = self.edit_cache def remove_completed(self, ev=None): self.todos = VisibilityFilters.active(self.todos) @staticmethod @directive def todo_focus(el, binding, vnode, old_vnode, *args): if binding.value: el.focus() app = App('#app') def on_hash_change(ev): visibility = window.location.hash.replace('#', '').replace("/", '') if VisibilityFilters(visibility): app.visibility = visibility else: window.location.hash = '' app.visibility = 'all' window.bind("hashchange", on_hash_change)
self._playSounds = True def storePlaySoundsSetting(self): self._storage['playSounds'] = str(self._playSounds) # Use brython to create the canvas. real_canvas = html.CANVAS(width=CANVAS_WIDTH, height=CANVAS_HEIGHT, id='c') document <= real_canvas def windowChange(ev): print(window.innerWidth, window.innerHeight) window.bind('resize', windowChange) # Use the canvas in fabric canvas = fabric.Canvas.new('c', { 'width': CANVAS_WIDTH, 'height': CANVAS_HEIGHT, 'selectable': False, 'backgroundColor': 'darkgreen' }) app = App(document, canvas) document <= html.H2( html.A("Instructions", href="instructions.html", Class="right-edge")) document <= html.H5('Version: 1.1', Class="right-edge")
from browser import document, alert, window _canvas_div = document['maindiv'] _canvas = document['maincanvas'] def on_resize(ev): _canvas.height = _canvas_div.height _canvas.width = _canvas_div.width on_resize(None) window.bind('resize', on_resize)
last_ed = Editor(el, content) elif mode == 'exercises': last_ed.add_exercises(content, id) def on_hash_change(event=None): """Handle the user clicking on an anchor to a different lesson.""" fragment = window.location.hash.strip('#') if fragment: load_lesson(fragment) def on_key(event): """Handle reloading the current lesson from the server.""" if event.ctrlKey and event.keyCode == 82: fragment = window.location.hash.strip('#') if fragment: load_lesson(fragment) event.preventDefault() window.bind('keydown', on_key) window.bind('hashchange', on_hash_change) if window.location.hash: on_hash_change(None) # Make sure the executor is warm executor.send({})
def init(self): window.bind('visibilitychange', self.visibilitychange) window.bind('show', self.connect) window.bind('fade', self.socket.disconnect) self.init_socket()
import brySVG.dragcanvas as SVG data = [[[(0, 0), (50, 50), (100, 0)], 0], [[(0, 50), (50, 0), (50, 100)], 80], [[(0, 0), (0, 50), (50, 50)], 160], [[(0, 25), (25, 0), (50, 25)], 210], [[(0, 0), (25, 25), (0, 50)], 270], [[(25, 0), (50, 25), (25, 50), (0, 25)], 310], [[(0, 0), (25, 25), (75, 25), (50, 0)], 360]] def onresize(event): canvas.fitContents() canvas = SVG.CanvasObject("95vw", "100%", "cyan") document["demo2"] <= canvas for points, offset in data: piece = SVG.PolygonObject(points) canvas.addObject(piece) canvas.translateObject(piece, (offset, 0)) outline = SVG.PolygonObject([(180, 100), (280, 100), (280, 200), (180, 200)], fillcolour="none") canvas.addObject(outline, fixed=True) canvas.fitContents() canvas.mouseMode = SVG.MouseMode.DRAG canvas.vertexSnap = True window.bind("resize", onresize)
def mounted(self): window.bind("resize", self.resize) self.resize(None)