Exemple #1
0
from pyjamas import DOM
from pyjamas import logging

from pyjamas.ui.RootPanel import RootPanel
from pyjamas.ui.HTML import HTML
from pyjamas.ui.Label import Label
from pyjamas.ui.Map import ImageMap, MapArea
from pyjamas.ui.HorizontalPanel import HorizontalPanel
from pyjamas.ui.VerticalPanel import VerticalPanel
from pyjamas.ui.ScrollPanel import ScrollPanel
from pyjamas.ui.MenuBar import MenuBar
from pyjamas.ui.Image import Image
from pyjamas.ui.ContextMenuPopupPanel import ContextMenuPopupPanel

log = logging.getAppendLogger(__name__, logging.DEBUG, logging.PLAIN_FORMAT)


class MapAreaDemo:

    def onModuleLoad(self):
        # build image display
        width = 200 #px
        height = 215 #px
        scale = 1.5
        img = Image(
            "babykatie_small.jpg", 
            Width="%dpx" % int(scale * width),
            Height="%dpx" % int(scale * height),
        )
        img.element.setAttribute("usemap", "#themap")
Exemple #2
0
# WARNING: the use of javascript pretty much trashes all chance of using
# pyjamas-desktop.  give serious consideration to doing something OTHER
# than including random bits of javascript off the internet in a pyjamas
# 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 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())
Exemple #3
0
# Date Time Example
# Copyright (C) 2009 Yit Choong (http://code.google.com/u/yitchoong/)

import pyjd  # dummy in pyjs

from pyjamas.ui.VerticalPanel import VerticalPanel
from pyjamas.ui.RootPanel import RootPanel
from pyjamas.ui.TextBox import TextBox
from pyjamas.ui.Button import Button
from pyjamas.ui.Calendar import DateField, Calendar, CalendarPopup
from pyjamas.ui.MonthField import MonthField

from pyjamas import logging

log = logging.getAppendLogger()


class App:
    def onModuleLoad(self):

        text = TextBox()
        df1 = DateField()
        df2 = DateField(format="%Y/%m/%d")
        b = Button("Show Calendar", self)
        self.cal = Calendar()
        df3 = MonthField()

        vp = VerticalPanel()
        vp.setSpacing(10)
        vp.add(df1)
        vp.add(b)
"""Use this to output (cumulatively) text at the bottom of the HTML page.
NOTE: This module is for convenience only and uses pyjamas.logging, a ported
version of Python's logging module. You can use Pyjamas' logging directly as
you would with Python, at your option."""

from pyjamas import logging

__logger = logging.getAppendLogger(__name__, logging.DEBUG, '%(message)s')

def setLogger(logger):
    """
    Replace the logger currently in use by a new one, e.g.
    log.setLogger(logging.getXxxxLogger()) ... Xxxx = Alert, Append, Console
    """
    global __logger
    __logger = logger

def debug(msg, *args, **kwargs):
    __logger.debug(msg, *args, **kwargs)

def info(msg, *args, **kwargs):
    __logger.info(msg, *args, **kwargs)

def warning(msg, *args, **kwargs):
    __logger.warning(msg, *args, **kwargs)

warn = warning

def error(msg, *args, **kwargs):
    __logger.error(msg, *args, **kwargs)
Exemple #5
0
# Date Time Example
# Copyright (C) 2009 Yit Choong (http://code.google.com/u/yitchoong/)

import pyjd  # dummy in pyjs

from pyjamas.ui.VerticalPanel import VerticalPanel
from pyjamas.ui.RootPanel import RootPanel
from pyjamas.ui.TextBox import TextBox
from pyjamas.ui.Button import Button
from pyjamas.ui.Calendar import DateField, Calendar, CalendarPopup
from pyjamas.ui.MonthField import MonthField

from pyjamas import logging
log = logging.getAppendLogger()


class App:
    def onModuleLoad(self):

        text = TextBox()
        df1 = DateField()
        df2 = DateField(format='%Y/%m/%d')
        b = Button("Show Calendar", self)
        self.cal = Calendar()
        df3 = MonthField()

        vp = VerticalPanel()
        vp.setSpacing(10)
        vp.add(df1)
        vp.add(b)
        vp.add(df2)
Exemple #6
0
"""Use this to output (cumulatively) text at the bottom of the HTML page.
NOTE: This module is for convenience only and uses pyjamas.logging, a ported
version of Python's logging module. You can use Pyjamas' logging directly as
you would with Python, at your option."""

from pyjamas import logging

__logger = logging.getAppendLogger(__name__, logging.DEBUG, '%(message)s')


def setLogger(logger):
    """
    Replace the logger currently in use by a new one, e.g.
    log.setLogger(logging.getXxxxLogger()) ... Xxxx = Alert, Append, Console
    """
    global __logger
    __logger = logger


def debug(msg, *args, **kwargs):
    __logger.debug(msg, *args, **kwargs)


def info(msg, *args, **kwargs):
    __logger.info(msg, *args, **kwargs)


def warning(msg, *args, **kwargs):
    __logger.warning(msg, *args, **kwargs)