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)
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()
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)
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)
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)
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)
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)
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
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()
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()
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,
** 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><br></tt> or <tt><li></tt> delimited HTML line. This ** default is only used when the footnote thickness is set to ** <tt>NAI</tt> (the default).
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()
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,
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()
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()
** 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