Ejemplo n.º 1
0
    def __init__(self, **ka):
        ka['StyleName'] = ka.get('StyleName', "gwt-Tree")

        self.root = None
        self.childWidgets = Set()
        self.curSelection = None
        self.focusable = None
        self.focusListeners = []
        self.mouseListeners = []
        self.imageBase = pygwt.getModuleBaseURL()
        self.keyboardListeners = []
        self.listeners = []
        self.lastEventType = ""

        element = ka.pop('Element', None) or DOM.createDiv()
        self.setElement(element)
        DOM.setStyleAttribute(self.getElement(), "position", "relative")
        self.focusable = Focus.createFocusable()
        # Hide focus outline in Mozilla/Webkit/Opera
        DOM.setStyleAttribute(self.focusable, "outline", "0px")
        # Hide focus outline in IE 6/7
        DOM.setElemAttribute(self.focusable, "hideFocus", "true");

        DOM.setStyleAttribute(self.focusable, "fontSize", "0")
        DOM.setStyleAttribute(self.focusable, "position", "absolute")
        DOM.setIntStyleAttribute(self.focusable, "zIndex", -1)
        DOM.appendChild(self.getElement(), self.focusable)

        self.root = RootTreeItem()
        self.root.setTree(self)

        Widget.__init__(self, **ka)

        self.sinkEvents(Event.ONMOUSEDOWN | Event.ONCLICK | Event.KEYEVENTS)
        DOM.sinkEvents(self.focusable, Event.FOCUSEVENTS)
Ejemplo n.º 2
0
    def __init__(self, text, disclosurePanel):
        Widget.__init__(self)
        self.disclosurePanel = disclosurePanel
        self.imageBase = pygwt.getModuleBaseURL()

        self.root = DOM.createTable()
        self.tbody = DOM.createTBody()
        self.tr = DOM.createTR()
        self.imageTD = DOM.createTD()
        self.labelTD = DOM.createTD()
        self.imgElem = DOM.createImg()

        self.updateState()

        self.setElement(self.root)
        DOM.appendChild(self.root, self.tbody)
        DOM.appendChild(self.tbody, self.tr)
        DOM.appendChild(self.tr, self.imageTD)
        DOM.appendChild(self.tr, self.labelTD)
        DOM.appendChild(self.imageTD, self.imgElem)

        self.setText(text)

        disclosurePanel.addEventHandler(self)
        self.updateState()
Ejemplo n.º 3
0
 def __call__(self, inst, uri, name="_blank", specs=""):
     if '://' not in uri:
         import pygwt
         uri = Soup.URI.new(pygwt.getModuleBaseURL()).new_with_base(uri).to_string(0)
     rc = RunnerContext()
     rc._destroy_cb = lambda *args: logger.debug('destroying sub window...')
     rc.setup(uri)
    def __init__(self, **ka):
        ka['StyleName'] = ka.get('StyleName', "gwt-Tree")

        self.root = None
        self.childWidgets = Set()
        self.curSelection = None
        self.focusable = None
        self.focusListeners = []
        self.mouseListeners = []
        self.imageBase = pygwt.getModuleBaseURL()
        self.keyboardListeners = []
        self.listeners = []
        self.lastEventType = ""

        element = ka.pop('Element', None) or DOM.createDiv()
        self.setElement(element)
        DOM.setStyleAttribute(self.getElement(), "position", "relative")
        self.focusable = Focus.createFocusable()
        # Hide focus outline in Mozilla/Webkit/Opera
        DOM.setStyleAttribute(self.focusable, "outline", "0px")
        # Hide focus outline in IE 6/7
        DOM.setElemAttribute(self.focusable, "hideFocus", "true")

        DOM.setStyleAttribute(self.focusable, "fontSize", "0")
        DOM.setStyleAttribute(self.focusable, "position", "absolute")
        DOM.setIntStyleAttribute(self.focusable, "zIndex", -1)
        DOM.appendChild(self.getElement(), self.focusable)

        self.root = RootTreeItem()
        self.root.setTree(self)

        Widget.__init__(self, **ka)

        self.sinkEvents(Event.ONMOUSEDOWN | Event.ONCLICK | Event.KEYEVENTS)
        DOM.sinkEvents(self.focusable, Event.FOCUSEVENTS)
Ejemplo n.º 5
0
Archivo: Gettext.py Proyecto: Afey/pyjs
 def change_texts(self, text):
     self.b.setText(_("Click me"))
     self.h.setHTML(_("<b>Hello World</b> (html)"))
     self.l.setText(_("Hello World (label)"))
     text = [_("Hello from %s") % pygwt.getModuleBaseURL()]
     for i in range(4):
         text.append(ngettext('%(num)d single', '%(num)d plural', i) % dict(num=i))
     text = '<br />'.join(text)
     self.base.setHTML(text)
Ejemplo n.º 6
0
Archivo: Gettext.py Proyecto: Afey/pyjs
 def __init__(self):
     self.b = Button(_("Click me"), self.greet, StyleName='teststyle')
     self.h = HTML(_("<b>Hello World</b> (html)"), StyleName='teststyle')
     self.l = Label(_("Hello World (label)"), StyleName='teststyle')
     self.base = HTML(_("Hello from %s") % pygwt.getModuleBaseURL(),
                      StyleName='teststyle')
     RootPanel().add(self.b)
     RootPanel().add(self.h)
     RootPanel().add(self.l)
     RootPanel().add(self.base)
Ejemplo n.º 7
0
 def change_texts(self, text):
     self.b.setText(_("Click me"))
     self.h.setHTML(_("<b>Hello World</b> (html)"))
     self.l.setText(_("Hello World (label)"))
     text = [_("Hello from %s") % pygwt.getModuleBaseURL()]
     for i in range(4):
         text.append(
             ngettext('%(num)d single', '%(num)d plural', i) % dict(num=i))
     text = '<br />'.join(text)
     self.base.setHTML(text)
Ejemplo n.º 8
0
 def __init__(self):
     self.b = Button(_("Click me"), self.greet, StyleName='teststyle')
     self.h = HTML(_("<b>Hello World</b> (html)"), StyleName='teststyle')
     self.l = Label(_("Hello World (label)"), StyleName='teststyle')
     self.base = HTML(_("Hello from %s") % pygwt.getModuleBaseURL(),
                      StyleName='teststyle')
     RootPanel().add(self.b)
     RootPanel().add(self.h)
     RootPanel().add(self.l)
     RootPanel().add(self.base)
Ejemplo n.º 9
0
    def __init__(self, text):
        Widget.__init__(self)
        self.imageBase = pygwt.getModuleBaseURL()

        self.root = DOM.createTable()
        self.tbody = DOM.createTBody()
        self.tr = DOM.createTR()
        self.imageTD = DOM.createTD()
        self.labelTD = DOM.createTD()
        self.imgElem = DOM.createImg()

        self.setElement(self.root)
        DOM.appendChild(self.root, self.tbody)
        DOM.appendChild(self.tbody, self.tr)
        DOM.appendChild(self.tr, self.imageTD)
        DOM.appendChild(self.tr, self.labelTD)
        DOM.appendChild(self.imageTD, self.imgElem)

        self.setText(text)
Ejemplo n.º 10
0
    def __init__(self, text):
        Widget.__init__(self)
        self.imageBase = pygwt.getModuleBaseURL()

        self.root = DOM.createTable()
        self.tbody = DOM.createTBody()
        self.tr = DOM.createTR()
        self.imageTD = DOM.createTD()
        self.labelTD = DOM.createTD()
        self.imgElem = DOM.createImg()

        self.setElement(self.root)
        DOM.appendChild(self.root, self.tbody)
        DOM.appendChild(self.tbody, self.tr)
        DOM.appendChild(self.tr, self.imageTD)
        DOM.appendChild(self.tr, self.labelTD)
        DOM.appendChild(self.imageTD, self.imgElem)

        self.setText(text)
Ejemplo n.º 11
0
    def _convertUrlToAbsolute(self, url):

        uri = pygwt.getModuleBaseURL()
        if url[0] == '/':
            # url is /somewhere.
            sep = uri.find('://')
            if not uri.startswith('file://'):
                
                slash = uri.find('/', sep+3)
                if slash > 0:
                    uri = uri[:slash]

            return "%s%s" % (uri, url)

        else:
            if url[:7] != 'file://' and url[:7] != 'http://' and \
               url[:8] != 'https://':
                slash = uri.rfind('/')
                return uri[:slash+1] + url

        return url
Ejemplo n.º 12
0
def greet(fred):
    global sc
    txt = fred.getText()
    if txt == "Click me lots":
        sc = StyleSheetCssText(newcolours)
        fred.setText("Did it work?")
    elif txt == "Did it work?":
        sc.remove()
        fred.setText("It did!")
    elif txt == "It did!":
        sc = StyleSheetCssText(morenewcolours)
        fred.setText("Play again!")
    elif txt != "Ok enough now":
        fred.setText("Ok enough now")
        sc.remove()


if __name__ == '__main__':
    pyjd.setup("public/CSSMess.html?fred=foo#me")
    b = Button("Click me lots", greet, StyleName='teststyle')
    h = HTML("<b>CSSMess World</b> (html)", StyleName='teststyle')
    l = Label("CSSMess World (label)", StyleName='teststyle')
    base = HTML("CSSMess from %s" % pygwt.getModuleBaseURL(),
                StyleName='teststyle')
    RootPanel().add(b)
    RootPanel().add(h)
    RootPanel().add(l)
    RootPanel().add(base)
    StyleSheetCssFile("./CSSMess.css")
    pyjd.run()
Ejemplo n.º 13
0
import pyjd
from pyjamas.ui.RootPanel import RootPanel
from pyjamas.ui.Button import Button
from pyjamas.ui.HTML import HTML
from pyjamas.ui.Label import Label
from pyjamas import Window

import pygwt


def greet(fred):
    fred.setText("No, really click me!")
    Window.alert("Hello, AJAX!")


if __name__ == "__main__":
    pyjd.setup("public/Hello.html")
    b = Button("Click me", greet, StyleName="teststyle")
    h = HTML("<b>Hello World</b> (html)", StyleName="teststyle")
    l = Label("Hello World (label)", StyleName="teststyle")
    base = HTML("Hello from %s" % pygwt.getModuleBaseURL(), StyleName="teststyle")
    RootPanel().add(b)
    RootPanel().add(h)
    RootPanel().add(l)
    RootPanel().add(base)
    pyjd.run()
Ejemplo n.º 14
0
        if self.readyState in (self.LOADING, self.DONE):
            raise TypeError('InvalidStateError')
        #TODO: there are 1-2 more check, but really ... ?
        self._meta['response-type'] = responseType

    def __init__(self, app):
        self._app = app

    def open(self, method, url, async=True, user=None, password=None):
        import pygwt
        self.abort()
        async = async and True or False
        user = user or None
        password = password or None
        view = self._app._view
        uri = Soup.URI.new(pygwt.getModuleBaseURL()).new_with_base(url)
        uri.set_user(user)
        uri.set_password(password)
        msg = Soup.Message.new_from_uri(method, uri)
        uri = msg.get_uri()
        self._msg = msg
        self._meta = GIXMLHttpRequest._meta.copy()
        self._meta.update({
            'source-origin': uri.copy_host().to_string(0).rstrip('/'),
            'upload': GIXMLHttpRequestUpload(),
            'ready-state': self.OPENED,
            'synchronous-flag': not async and True or None,
            'request-method': method.upper(),
            'request-url': uri.to_string(0),
            'request-username': user,
            'request-password': password,
Ejemplo n.º 15
0
** The full path to the default GChart blank image
** (specifically, a 1 x 1 pixel transparent GIF) it requires
** to prevent "missing image" icons from appearing in your
** charts.
** <p>
**
** Convenience constant equal to:
**
** <pre>
** pygwt.getModuleBaseURL()+GChart.DEFAULT_BLANK_IMAGE_URL
** </pre>
**
** @see #setBlankImageURL setBlankImageURL
**
*"""
DEFAULT_BLANK_IMAGE_URL_FULLPATH = pygwt.getModuleBaseURL(
) + DEFAULT_BLANK_IMAGE_URL
DEFAULT_GRID_HEIGHT = DEFAULT_TICK_THICKNESS
DEFAULT_GRID_WIDTH = DEFAULT_TICK_THICKNESS
GRID_BORDER_STYLE = "solid"
GRID_BORDER_WIDTH = 1
"""* The default color used for all axes, gridlines, and ticks.
**
** @see #setGridColor setGridColor
**
"""
DEFAULT_GRID_COLOR = "black"
"""* The default thickness (height) of the rectangular region at
** the bottom of the chart allocated for footnotes, per
** <tt>&lt;br&gt;</tt> or <tt>&lt;li&gt;</tt> delimited HTML line. This
** default is only used when the footnote thickness is set to
** <tt>NAI</tt> (the default).
Ejemplo n.º 16
0
import pyjd # this is dummy in pyjs.
from pyjamas.ui.RootPanel import RootPanel
from pyjamas.ui.Button import Button
from pyjamas.ui.HTML import HTML
from pyjamas.ui.Label import Label
from pyjamas import Window

import pygwt

def greet(fred):
    print "greet button"
    Window.alert("Hello, AJAX!")

if __name__ == '__main__':
    pyjd.setup("public/Hello.html?fred=foo#me")
    b = Button("Click me", greet, StyleName='teststyle')
    h = HTML("<b>Hello World</b> (html)", StyleName='teststyle')
    l = Label("Hello World (label)", StyleName='teststyle')
    base = HTML("Hello from %s" % pygwt.getModuleBaseURL(),
                                  StyleName='teststyle')
    RootPanel().add(b)
    RootPanel().add(h)
    RootPanel().add(l)
    RootPanel().add(base)
    pyjd.run()
Ejemplo n.º 17
0
        if self.readyState in (self.LOADING, self.DONE):
            raise TypeError('InvalidStateError')
        #TODO: there are 1-2 more check, but really ... ?
        self._meta['response-type'] = responseType

    def __init__(self, app):
        self._app = app

    def open(self, method, url, async=True, user=None, password=None):
        import pygwt
        self.abort()
        async = async and True or False
        user = user or None
        password = password or None
        view = self._app._view
        uri = Soup.URI.new(pygwt.getModuleBaseURL()).new_with_base(url)
        uri.set_user(user)
        uri.set_password(password)
        msg = Soup.Message.new_from_uri(method, uri)
        uri = msg.get_uri()
        self._msg = msg
        self._meta = GIXMLHttpRequest._meta.copy()
        self._meta.update({
            'source-origin':
            uri.copy_host().to_string(0).rstrip('/'),
            'upload':
            GIXMLHttpRequestUpload(),
            'ready-state':
            self.OPENED,
            'synchronous-flag':
            not async and True or None,
Ejemplo n.º 18
0
import pyjd  # this is dummy in pyjs.
from pyjamas.ui.RootPanel import RootPanel
from pyjamas.ui.Button import Button
from pyjamas.ui.HTML import HTML
from pyjamas.ui.Label import Label
from pyjamas import Window

import pygwt


def greet(fred):
    fred.setText("No, really click me!")
    Window.alert("Hello, AJAX!")


if __name__ == '__main__':
    pyjd.setup("public/Hello.html?fred=foo#me")
    b = Button("Click me", greet, StyleName='teststyle')
    h = HTML("<b>Hello World</b> (html)", StyleName='teststyle')
    l = Label("Hello World (label)", StyleName='teststyle')
    base = HTML("Hello from %s" % pygwt.getModuleBaseURL(),
                StyleName='teststyle')
    RootPanel().add(b)
    RootPanel().add(h)
    RootPanel().add(l)
    RootPanel().add(base)
    pyjd.run()
Ejemplo n.º 19
0
Archivo: CSSMess.py Proyecto: Afey/pyjs
sc = None
def greet(fred):
    global sc
    txt = fred.getText()
    if txt == "Click me lots":
        sc = StyleSheetCssText(newcolours)
        fred.setText("Did it work?")
    elif txt == "Did it work?":
        sc.remove()
        fred.setText("It did!")
    elif txt == "It did!":
        sc = StyleSheetCssText(morenewcolours)
        fred.setText("Play again!")
    elif txt != "Ok enough now":
        fred.setText("Ok enough now")
        sc.remove()

if __name__ == '__main__':
    pyjd.setup("public/CSSMess.html?fred=foo#me")
    b = Button("Click me lots", greet, StyleName='teststyle')
    h = HTML("<b>CSSMess World</b> (html)", StyleName='teststyle')
    l = Label("CSSMess World (label)", StyleName='teststyle')
    base = HTML("CSSMess from %s" % pygwt.getModuleBaseURL(),
                                  StyleName='teststyle')
    RootPanel().add(b)
    RootPanel().add(h)
    RootPanel().add(l)
    RootPanel().add(base)
    StyleSheetCssFile("./CSSMess.css")
    pyjd.run()
Ejemplo n.º 20
0
** The full path to the default GChart blank image
** (specifically, a 1 x 1 pixel transparent GIF) it requires
** to prevent "missing image" icons from appearing in your
** charts.
** <p>
**
** Convenience constant equal to:
**
** <pre>
** pygwt.getModuleBaseURL()+GChart.DEFAULT_BLANK_IMAGE_URL
** </pre>
**
** @see #setBlankImageURL setBlankImageURL
**
*"""
DEFAULT_BLANK_IMAGE_URL_FULLPATH = pygwt.getModuleBaseURL()+DEFAULT_BLANK_IMAGE_URL
DEFAULT_GRID_HEIGHT = DEFAULT_TICK_THICKNESS
DEFAULT_GRID_WIDTH = DEFAULT_TICK_THICKNESS
GRID_BORDER_STYLE = "solid"
GRID_BORDER_WIDTH = 1

"""* The default color used for all axes, gridlines, and ticks.
**
** @see #setGridColor setGridColor
**
"""
DEFAULT_GRID_COLOR = "black"


"""* The default thickness (height) of the rectangular region at
** the bottom of the chart allocated for footnotes, per