Пример #1
0
from pyjamas.Canvas.GWTCanvas import GWTCanvas
from pyjamas.ui.RootPanel import RootPanel
from pyjamas.DOM import getFirstChild
from pyjamas import Window
from pyjamas.ui.HTML import HTML
import math
from __pyjamas__ import jsimport

# Include the processing.js in the module scope
jsimport("processing.js")
from __javascript__ import Processing  # defined by processing.js

p = None
radius = 50.0
delay = 16


def setup():
    global p, radius, delay, X, Y, nX, nY
    p.size(200, 200)
    p.strokeWeight(10)
    p.frameRate(15)
    X = p.width / 2
    Y = p.width / 2
    nX = X
    nY = Y


def draw():
    global p, radius, delay, X, Y, nX, nY
    radius = radius + math.sin(p.frameCount / 4)
Пример #2
0
#
# if you ABSOLUTELY MUST use javascript, here's how to do it.
#

from pyjamas import logging
log = logging.getAppendLogger(__name__, logging.DEBUG, logging.PLAIN_FORMAT)

# this simply tells the compiler that the two names are to be dropped
# into the javascript global namespace
from __javascript__ import examplevar, get_examplevar

# the default behaviour of jsimport is to include the javascript file
# "inline" - unmodified - direct into the compiler output
from __pyjamas__ import jsimport

jsimport("example.js")


def main():
    global examplevar
    #examplevar is actually "out of modules", in a super scope

    log.debug(examplevar)
    examplevar = 'Altered'
    log.debug(get_examplevar())


main()

examplevar = "Realtered"
log.debug(get_examplevar())
Пример #3
0
from pyjamas.ui.RootPanel import RootPanel
from pyjamas.ui.HTML import HTML
from pyjamas.ui.TextArea import TextArea
from pyjamas.ui.Label import Label
from pyjamas.ui import InnerHTML
from pyjamas.ui.KeyboardListener import KeyboardHandler
from pyjamas.JSONService import JSONProxy

from __javascript__ import Showdown
from __pyjamas__ import JS
from __pyjamas__ import jsimport

from pyjamas import log
from pyjamas import History

jsimport("showdown.js")

def getShowdown():
    JS("""return new Showdown.converter()""")

class WikiBox(HTML):
    def __init__(self, html=None, wordWrap=True, Element=None, **kwargs):
        self.converter = getShowdown()
        HTML.__init__(self, html, wordWrap, Element, **kwargs)
    def setHTML(self, text):
        newText = self.converter.makeHtml(text)
        InnerHTML.setHTML(self, newText)

class Wiki(KeyboardHandler):
    def __init__(self):
        self.remote = DataService()
Пример #4
0
# application.  the larger the random bit of javascript, the more chance
# there is that it will interact in some horrendous way with the pyjamas
# infrastructure.
#
# if you ABSOLUTELY MUST use javascript, here's how to do it.
#

from pyjamas import log

# this simply tells the compiler that the two names are to be dropped
# into the javascript global namespace
from __javascript__ import examplevar, get_examplevar

# the default behaviour of jsimport is to include the javascript file
# "inline" - unmodified - direct into the compiler output
from __pyjamas__ import jsimport

jsimport("example.js")

def main():
    global examplevar
    # Note that the javascript example var is globally
    # defined, but not accessible from the global
    # scope. You'll have to swich to a local scope
    # and define the javascript names global
    log.writebr(examplevar)
    examplevar = 'Altered'
    log.writebr( get_examplevar() )

main()
Пример #5
0
from pyjamas.Canvas.GWTCanvas import GWTCanvas
from pyjamas.ui.RootPanel import RootPanel
from pyjamas.DOM import getFirstChild
from pyjamas import Window
from pyjamas.ui.HTML import HTML
import math
from __pyjamas__ import jsimport

# Include the processing.js in the module scope
jsimport("processing.js")
from __javascript__ import Processing # defined by processing.js


p = None
radius = 50.0
delay = 16

def setup():
    global p,radius,delay,X,Y,nX,nY
    p.size(200,200)
    p.strokeWeight( 10 )
    p.frameRate( 15 )
    X = p.width / 2
    Y = p.width / 2
    nX = X
    nY = Y

def draw():
    global p,radius,delay,X,Y,nX,nY
    radius = radius + math.sin( p.frameCount / 4 )
    X+=(nX-X)/delay