def createUserInputUI(self, saveButton): """ Create user input UI @return user input ui """ p = VerticalPanel() title = TextBox() content = TextBox() p.setSpacing(10) p.add(self.createInput(u"Title", title)) p.add(self.createInput(u"Content", content)) p.add(saveButton) class _anonymous(ClickHandler): @java.typed(ClickEvent) def onClick(self, event): note = Note.createNote(title.getValue(), content.getValue()) class _anonymous(AsyncCallback): @java.typed(Throwable) def onFailure(self, caught): Notes_create.self###NOTIMPL QThis###.handleFailure(caught) @java.typed(Long) def onSuccess(self, noteId): p.add(HTML(u"Added note with id " + java.str(noteId))) deleteNoteLink = Anchor(u"Delete") deleteNoteLink.addClickHandler(self.DeleteNoteClickHandler(noteId)) p.add(deleteNoteLink) self.apiClient.notesCreate(note, _anonymous()) saveButton.addClickHandler(_anonymous()) # User clicks save, store it to facebook return p
def onModuleLoad(self): panel = DockPanel() RootPanel().add(panel) panel.setWidth("100%") panel.setHeight("100%") panel.setSpacing(5) title = HTML('<h1>Hello</h1>') description = HTML("""""") panel.add(title, DockPanel.NORTH) panel.add(description, DockPanel.SOUTH) links = VerticalPanel() links.setSpacing(8) panel.add(links, DockPanel.NORTH) head = HTML(""" <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> <tr bgcolor="#7799ee"> <td valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>Hello</strong></big></big></font></td ><td align=right valign=bottom ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/lkcl/src/pyjamas-desktop/pyjamas-webkit/examples/helloworld/Hello.py">/home/lkcl/src/pyjamas-desktop/pyjamas-webkit/examples/helloworld/Hello.py</a></font></td></tr></table> """) panel.add(head, DockPanel.NORTH) docs = HTML("""<tt><a href="#Hello">Hello</a> World Example</tt>""") panel.add(docs, DockPanel.NORTH) modules = eval(r'''['<a href="pyjamas.DOM.html">pyjamas.DOM</a>', '<a href="pyjamas.Window.html">pyjamas.Window</a>']''') contents = self.multicolumn(modules) contents = self.bigsection('Modules', '#fffff', '#aa55cc', contents) panel.add(contents, DockPanel.NORTH) classes = eval(r'''['<dl>\n<dt><font face="helvetica, arial"><a href="Hello.html#Hello">Hello</a>\n</font></dt></dl>\n', '<p>\n<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">\n<tr bgcolor="#ffc8d8">\n<td colspan=3 valign=bottom> <br>\n<font color="#000000" face="helvetica, arial"><a name="Hello">class <strong>Hello</strong></a></font></td></tr>\n \n<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>\n<td width="100%">Methods defined here:<br>\n<dl><dt><a name="Hello-onBrowserEvent"><strong>onBrowserEvent</strong></a>(self, event)</dt></dl>\n\n<dl><dt><a name="Hello-onModuleLoad"><strong>onModuleLoad</strong></a>(self)</dt></dl>\n\n<dl><dt><a name="Hello-onTimer"><strong>onTimer</strong></a>(self)</dt></dl>\n\n<dl><dt><a name="Hello-onWindowResized"><strong>onWindowResized</strong></a>(self, width, height)</dt></dl>\n\n</td></tr></table>']''') contents = self.multicolumn(modules) contents = self.bigsection( 'Classes', '#ffffff', '#ee77aa', HTML('\n'.join(classes))) panel.add(contents, DockPanel.NORTH) functions = eval(r'''['<dl><dt><a name="-greet"><strong>greet</strong></a>(sender, event)</dt></dl>\n']''') contents = self.multicolumn(modules) contents = self.bigsection( 'Functions', '#ffffff', '#eeaa77', HTML('\n'.join(functions))) panel.add(contents, DockPanel.NORTH) data = eval(r'''["<strong>test</strong> = 'hello'"]''') contents = self.multicolumn(modules) contents = self.bigsection( 'Data', '#ffffff', '#55aa55', HTML('\n'.join(data))) panel.add(contents, DockPanel.NORTH)
def createDefaultFrontpage(self): pp = FbProfilePic(self.apiClient.getLoggedInUser(), Size.square) pp.setSize(u"30px", u"30px") name = FbName(self.apiClient.getLoggedInUser()) name.setUseyou(False) name.setLinked(False) welcomePnl = VerticalPanel() welcomePnl.setSpacing(10) welcomePnl.add(HTML(java.str(java.str(java.str(u"<h4>Welcome, " + java.str(name)) + u" ") + java.str(pp)) + u"</h4> ")) welcomePnl.add(HTML(self.wText)) return welcomePnl
def __init__(self): Sink.__init__(self) self.fPasswordText = PasswordTextBox() self.fTextArea = TextArea() self.fTextBox = TextBox() panel = VerticalPanel() panel.setSpacing(8) panel.add(HTML("Normal text box:")) panel.add(self.createTextThing(self.fTextBox)) panel.add(HTML("Password text box:")) panel.add(self.createTextThing(self.fPasswordText)) panel.add(HTML("Text area:")) panel.add(self.createTextThing(self.fTextArea)) self.initWidget(panel)
def __init__(self): Sink.__init__(self) self.fDialogButton = Button("Show Dialog", self) self.fPopupButton = Button("Show Popup", self) panel = VerticalPanel() panel.add(self.fPopupButton) panel.add(self.fDialogButton) list = ListBox() list.setVisibleItemCount(5) for i in range(10): list.addItem("list item %d" % i) panel.add(list) panel.setSpacing(8) self.initWidget(panel)
def __init__(self, ): self.__init__._super() """ New Showcase """ vPanel = VerticalPanel() vPanel.setStyleName(u"gwittit-Stream_publish") innerPanel = VerticalPanel() innerPanel.setStyleName(u"innerPanel") innerPanel.setSpacing(10) publishButton = Button(u"PublishStream #1") helpText = Label(u"This will display a dialog where you can publish stream to your wall") publishButton2 = Button(u"PublishStream #2") helpText2 = HTML(java.str(u"This will publish a stream with the text <b>" + java.str(self.__class__.defaultUserMessage)) + u"</b> ( publish_stream must be granted )") publishButton3 = Button(u"PublisStream #3") helpText3 = HTML(u"This will prompt user to update his or her status") innerPanel.add(publishButton) innerPanel.add(helpText) vPanel.add(innerPanel) publishButton.addClickHandler(self.PublishStreamClickHandler(innerPanel, True)) innerPanel = VerticalPanel() innerPanel.setSpacing(10) innerPanel.setStyleName(u"innerPanel") innerPanel.add(publishButton2) innerPanel.add(helpText2) vPanel.add(innerPanel) publishButton2.addClickHandler(self.PublishStreamClickHandler(innerPanel, False)) innerPanel = VerticalPanel() innerPanel.setStyleName(u"innerPanel") innerPanel.add(publishButton3) innerPanel.add(helpText3) innerPanel.setSpacing(10) vPanel.add(innerPanel) publishButton3.addClickHandler(self.PublishStreamSimpleHandler()) self.initWidget(vPanel)
def __init__(self): Sink.__init__(self) disabledButton = Button("Disabled Button") disabledCheck = CheckBox("Disabled Check") normalButton = Button("Normal Button") normalCheck = CheckBox("Normal Check") panel = VerticalPanel() radio0 = RadioButton("group0", "Choice 0") radio1 = RadioButton("group0", "Choice 1") radio2 = RadioButton("group0", "Choice 2 (Disabled)") radio3 = RadioButton("group0", "Choice 3") hp=HorizontalPanel() panel.add(hp) hp.setSpacing(8) hp.add(normalButton) hp.add(disabledButton) hp=HorizontalPanel() panel.add(hp) hp.setSpacing(8) hp.add(normalCheck) hp.add(disabledCheck) hp=HorizontalPanel() panel.add(hp) hp.setSpacing(8) hp.add(radio0) hp.add(radio1) hp.add(radio2) hp.add(radio3) disabledButton.setEnabled(False) disabledCheck.setEnabled(False) radio2.setEnabled(False) panel.setSpacing(8) self.initWidget(panel)
def onModuleLoad(self): Window.addWindowResizeListener(self) panel = DockPanel() RootPanel().add(panel) self.panel = panel panel.setWidth("100%") #panel.setHeight("100%") panel.setSpacing(5) title = HTML('<h1>Timer</h1>') description = HTML("""""") #panel.add(title, DockPanel.NORTH) panel.add(description, DockPanel.NORTH) links = VerticalPanel() links.setSpacing(8) panel.add(links, DockPanel.NORTH) head = HTML(""" <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> <tr bgcolor="#7799ee"> <td valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>Timer</strong></big></big></font></td ><td align=right valign=bottom ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/lkcl/src/pyjamas-desktop/pyjamas-webkit/pyjamas/Timer.py">/home/lkcl/src/pyjamas-desktop/pyjamas-webkit/pyjamas/Timer.py</a></font></td></tr></table> """) panel.add(head, DockPanel.NORTH) docs = HTML("""""") panel.add(docs, DockPanel.NORTH) tp = TabPanel() tp.setWidth("100%") self.tp = tp panel.add(tp, DockPanel.SOUTH) #panel.setCellHeight(tp, "100%") classes = [ Proto('Timer'), ] class_content = { 'Timer': r'''<p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <font color="#000000" face="helvetica, arial"><a name="Timer">class <strong>Timer</strong></a></font></td></tr> <tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> <td width="100%">Methods defined here:<br> <dl><dt><a name="Timer-__init__"><strong>__init__</strong></a>(self, time, notify)</dt></dl> <dl><dt><a name="Timer-cancel"><strong>cancel</strong></a>(self)</dt></dl> <dl><dt><a name="Timer-getID"><strong>getID</strong></a>(self)</dt></dl> <dl><dt><a name="Timer-notify"><strong>notify</strong></a>(self, *args)</dt></dl> </td></tr></table>''', } self.class_doc = ClassDoc(classes, class_content) tp.add(self.class_doc, 'Classes') functions = ['<dl><dt><a name="-timeout_add"><strong>timeout_add</strong></a>(...)</dt></dl>\n'] title = bigtitle('Functions') contents = section(title, 'functions', HTML('\n'.join(functions))) tp.add(contents, 'Functions') tp.addTabListener(self) tp.selectTab(0) # Call the window resized handler to get the initial sizes setup. Doing # this in a deferred command causes it to occur after all widgets' sizes # have been computed by the browser. DeferredCommand().add(self)
def onModuleLoad(self): Window.addWindowResizeListener(self) panel = DockPanel() RootPanel().add(panel) self.panel = panel panel.setWidth("100%") #panel.setHeight("100%") panel.setSpacing(5) title = HTML('<h1>DeferredCommand</h1>') description = HTML("""""") #panel.add(title, DockPanel.NORTH) panel.add(description, DockPanel.NORTH) links = VerticalPanel() links.setSpacing(8) panel.add(links, DockPanel.NORTH) head = HTML(""" <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> <tr bgcolor="#7799ee"> <td valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>DeferredCommand</strong></big></big></font></td ><td align=right valign=bottom ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/lkcl/src/pyjamas-desktop/pyjamas-webkit/pyjamas/DeferredCommand.py">/home/lkcl/src/pyjamas-desktop/pyjamas-webkit/pyjamas/DeferredCommand.py</a></font></td></tr></table> """) panel.add(head, DockPanel.NORTH) docs = HTML("""""") panel.add(docs, DockPanel.NORTH) tp = TabPanel() tp.setWidth("100%") self.tp = tp panel.add(tp, DockPanel.SOUTH) #panel.setCellHeight(tp, "100%") classes = [ Proto('DeferredCommand'), ] class_content = { 'DeferredCommand': r'''<p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <font color="#000000" face="helvetica, arial"><a name="DeferredCommand">class <strong>DeferredCommand</strong></a></font></td></tr> <tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> <td width="100%">Methods defined here:<br> <dl><dt><a name="DeferredCommand-add"><strong>add</strong></a>(self, cmd)</dt></dl> <dl><dt><a name="DeferredCommand-flushDeferredCommands"><strong>flushDeferredCommands</strong></a>(self)</dt></dl> <dl><dt><a name="DeferredCommand-maybeSetDeferredCommandTimer"><strong>maybeSetDeferredCommandTimer</strong></a>(self)</dt></dl> <dl><dt><a name="DeferredCommand-onTimer"><strong>onTimer</strong></a>(self, sender)</dt></dl> </td></tr></table>''', } self.class_doc = ClassDoc(classes, class_content) tp.add(self.class_doc, 'Classes') data = [r'''<strong>deferredCommands</strong> = []''',r'''<strong>timerIsActive</strong> = False'''] title = bigtitle('Data') contents = section(title, 'data', HTML('\n'.join(data))) tp.add(contents, 'Data') tp.addTabListener(self) tp.selectTab(0) # Call the window resized handler to get the initial sizes setup. Doing # this in a deferred command causes it to occur after all widgets' sizes # have been computed by the browser. DeferredCommand().add(self)
def onModuleLoad(self): Window.addWindowResizeListener(self) panel = DockPanel() RootPanel().add(panel) self.panel = panel panel.setWidth("100%") #panel.setHeight("100%") panel.setSpacing(5) title = HTML('<h1>Location</h1>') description = HTML("""""") #panel.add(title, DockPanel.NORTH) panel.add(description, DockPanel.NORTH) links = VerticalPanel() links.setSpacing(8) panel.add(links, DockPanel.NORTH) head = HTML(""" <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> <tr bgcolor="#7799ee"> <td valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>Location</strong></big></big></font></td ><td align=right valign=bottom ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/lkcl/src/pyjamas-desktop/pyjamas-webkit/pyjamas/Location.py">/home/lkcl/src/pyjamas-desktop/pyjamas-webkit/pyjamas/Location.py</a></font></td></tr></table> """) panel.add(head, DockPanel.NORTH) docs = HTML("""""") panel.add(docs, DockPanel.NORTH) tp = TabPanel() tp.setWidth("100%") self.tp = tp panel.add(tp, DockPanel.SOUTH) #panel.setCellHeight(tp, "100%") modules = [r'''<a href="docpyjslib.html">pyjslib</a>'''] contents = self.multicolumn(modules) title = bigtitle('Modules') contents = section(title, 'module', contents) tp.add(contents, 'Modules') classes = [ Proto('Location'), ] class_content = { 'Location': r'''<p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <font color="#000000" face="helvetica, arial"><a name="Location">class <strong>Location</strong></a></font></td></tr> <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> <td colspan=2><tt>Retrieve this class by calling Window.getLocation().<br> <br> This provides a pyjs wrapper for the current location,<br> with some utility methods for convenience.<br> </tt></td></tr> <tr><td> </td> <td width="100%">Methods defined here:<br> <dl><dt><a name="Location-__init__"><strong>__init__</strong></a>(self, location)</dt></dl> <dl><dt><a name="Location-getHash"><strong>getHash</strong></a>(self)</dt></dl> <dl><dt><a name="Location-getHashDict"><strong>getHashDict</strong></a>(self)</dt></dl> <dl><dt><a name="Location-getHost"><strong>getHost</strong></a>(self)</dt></dl> <dl><dt><a name="Location-getHostname"><strong>getHostname</strong></a>(self)</dt></dl> <dl><dt><a name="Location-getHref"><strong>getHref</strong></a>(self)</dt></dl> <dl><dt><a name="Location-getPageHref"><strong>getPageHref</strong></a>(self)</dt><dd><tt>Return href with any search or hash stripped</tt></dd></dl> <dl><dt><a name="Location-getPathname"><strong>getPathname</strong></a>(self)</dt></dl> <dl><dt><a name="Location-getPort"><strong>getPort</strong></a>(self)</dt></dl> <dl><dt><a name="Location-getProtocol"><strong>getProtocol</strong></a>(self)</dt></dl> <dl><dt><a name="Location-getSearch"><strong>getSearch</strong></a>(self)</dt></dl> <dl><dt><a name="Location-getSearchDict"><strong>getSearchDict</strong></a>(self)</dt></dl> <dl><dt><a name="Location-getSearchVar"><strong>getSearchVar</strong></a>(self, key)</dt></dl> <dl><dt><a name="Location-reload"><strong>reload</strong></a>(self)</dt></dl> <dl><dt><a name="Location-setHash"><strong>setHash</strong></a>(self, hash)</dt></dl> <dl><dt><a name="Location-setHashDict"><strong>setHashDict</strong></a>(self, hashDict)</dt></dl> <dl><dt><a name="Location-setHref"><strong>setHref</strong></a>(self, href)</dt></dl> <dl><dt><a name="Location-setSearch"><strong>setSearch</strong></a>(self, search)</dt></dl> <dl><dt><a name="Location-setSearchDict"><strong>setSearchDict</strong></a>(self, searchDict)</dt></dl> </td></tr></table>''', } self.class_doc = ClassDoc(classes, class_content) tp.add(self.class_doc, 'Classes') functions = ['<dl><dt><a name="-makeUrlDict"><strong>makeUrlDict</strong></a>(s)</dt></dl>\n', '<dl><dt><a name="-makeUrlStringFromDict"><strong>makeUrlStringFromDict</strong></a>(d)</dt></dl>\n'] title = bigtitle('Functions') contents = section(title, 'functions', HTML('\n'.join(functions))) tp.add(contents, 'Functions') tp.addTabListener(self) tp.selectTab(0) # Call the window resized handler to get the initial sizes setup. Doing # this in a deferred command causes it to occur after all widgets' sizes # have been computed by the browser. DeferredCommand().add(self)
def onModuleLoad(self): Window.addWindowResizeListener(self) panel = DockPanel() RootPanel().add(panel) self.panel = panel panel.setWidth("100%") #panel.setHeight("100%") panel.setSpacing(5) title = HTML('<h1>EventDelegate</h1>') description = HTML("""""") #panel.add(title, DockPanel.NORTH) panel.add(description, DockPanel.NORTH) links = VerticalPanel() links.setSpacing(8) panel.add(links, DockPanel.NORTH) head = HTML(""" <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> <tr bgcolor="#7799ee"> <td valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>EventDelegate</strong></big></big></font></td ><td align=right valign=bottom ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/lkcl/src/pyjamas-desktop/pyjamas-webkit/pyjamas/EventDelegate.py">/home/lkcl/src/pyjamas-desktop/pyjamas-webkit/pyjamas/EventDelegate.py</a></font></td></tr></table> """) panel.add(head, DockPanel.NORTH) docs = HTML("""""") panel.add(docs, DockPanel.NORTH) tp = TabPanel() tp.setWidth("100%") self.tp = tp panel.add(tp, DockPanel.SOUTH) #panel.setCellHeight(tp, "100%") classes = [ Proto('EventDelegate'), ] class_content = { 'EventDelegate': r'''<p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <font color="#000000" face="helvetica, arial"><a name="EventDelegate">class <strong>EventDelegate</strong></a></font></td></tr> <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> <td colspan=2><tt>Create the equivalent of a bound method. This also prepends extra <br> args, if any, to the called method's argument list when it calls it.<br> <br> Pass the method name you want to implement (javascript doesn't<br> support callables).<br> <br> @type args: list<br> @param args: If given, the arguments will be prepended to the <br> arguments passed to the event callback<br> </tt></td></tr> <tr><td> </td> <td width="100%">Methods defined here:<br> <dl><dt><a name="EventDelegate-__init__"><strong>__init__</strong></a>(self, eventMethodName, obj, method, *args)</dt></dl> <dl><dt><a name="EventDelegate-onEvent"><strong>onEvent</strong></a>(self, *args)</dt></dl> </td></tr></table>''', } self.class_doc = ClassDoc(classes, class_content) tp.add(self.class_doc, 'Classes') tp.addTabListener(self) tp.selectTab(0) # Call the window resized handler to get the initial sizes setup. Doing # this in a deferred command causes it to occur after all widgets' sizes # have been computed by the browser. DeferredCommand().add(self)
def onModuleLoad(self): Window.addWindowResizeListener(self) panel = DockPanel() RootPanel().add(panel) self.panel = panel panel.setWidth("100%") #panel.setHeight("100%") panel.setSpacing(5) title = HTML('<h1>History</h1>') description = HTML("""""") #panel.add(title, DockPanel.NORTH) panel.add(description, DockPanel.NORTH) links = VerticalPanel() links.setSpacing(8) panel.add(links, DockPanel.NORTH) head = HTML(""" <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> <tr bgcolor="#7799ee"> <td valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>History</strong></big></big></font></td ><td align=right valign=bottom ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/lkcl/src/pyjamas-desktop/pyjamas-webkit/pyjamas/History.py">/home/lkcl/src/pyjamas-desktop/pyjamas-webkit/pyjamas/History.py</a></font></td></tr></table> """) panel.add(head, DockPanel.NORTH) docs = HTML("""""") panel.add(docs, DockPanel.NORTH) tp = TabPanel() tp.setWidth("100%") self.tp = tp panel.add(tp, DockPanel.SOUTH) #panel.setCellHeight(tp, "100%") classes = [ Proto('History'), ] class_content = { 'History': r'''<p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <font color="#000000" face="helvetica, arial"><a name="History">class <strong>History</strong></a></font></td></tr> <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> <td colspan=2><tt>Simple <a href="#History">History</a> management class for back/forward button support.<br> <br> This class allows your AJAX application to use a history. Each time you<br> call <a href="#History-newItem">newItem</a>(), a new item is added to the history and the history<br> listeners are notified. If the user clicks the browser's forward or back <br> buttons, the appropriate item (a string passed to newItem) is fetched<br> from the history and the history listeners are notified.<br> <br> The address bar of the browser contains the current token, using <br> the "#" seperator (for implementation reasons, not because we love <br> the # mark).<br> <br> You may want to check whether the hash already contains a history<br> token when the page loads and use that to show appropriate content;<br> this allows users of the site to store direct links in their<br> bookmarks or send them in emails.<br> <br> To make this work properly in all browsers, you must add a specially<br> named iframe to your html page, like this:<br> <br> <iframe id='__pygwt_historyFrame' style='width:0;height:0;border:0'></iframe><br> </tt></td></tr> <tr><td> </td> <td width="100%">Methods defined here:<br> <dl><dt><a name="History-addHistoryListener"><strong>addHistoryListener</strong></a>(self, listener)</dt></dl> <dl><dt><a name="History-back"><strong>back</strong></a>(self)</dt></dl> <dl><dt><a name="History-fireHistoryChangedAndCatch"><strong>fireHistoryChangedAndCatch</strong></a>(self)</dt><dd><tt># TODO</tt></dd></dl> <dl><dt><a name="History-fireHistoryChangedImpl"><strong>fireHistoryChangedImpl</strong></a>(self, historyToken)</dt></dl> <dl><dt><a name="History-forward"><strong>forward</strong></a>(self)</dt></dl> <dl><dt><a name="History-getToken"><strong>getToken</strong></a>(self)</dt></dl> <dl><dt><a name="History-newItem"><strong>newItem</strong></a>(self, historyToken)</dt></dl> <dl><dt><a name="History-onHistoryChanged"><strong>onHistoryChanged</strong></a>(self, historyToken)</dt><dd><tt># TODO - fireHistoryChangedAndCatch not implemented</tt></dd></dl> <dl><dt><a name="History-removeHistoryListener"><strong>removeHistoryListener</strong></a>(self, listener)</dt></dl> </td></tr></table>''', } self.class_doc = ClassDoc(classes, class_content) tp.add(self.class_doc, 'Classes') functions = ['<dl><dt><a name="-init"><strong>init</strong></a>()</dt></dl>\n'] title = bigtitle('Functions') contents = section(title, 'functions', HTML('\n'.join(functions))) tp.add(contents, 'Functions') data = [r'''<strong>historyListeners</strong> = []''',r'''<strong>historyToken</strong> = '''''] title = bigtitle('Data') contents = section(title, 'data', HTML('\n'.join(data))) tp.add(contents, 'Data') tp.addTabListener(self) tp.selectTab(0) # Call the window resized handler to get the initial sizes setup. Doing # this in a deferred command causes it to occur after all widgets' sizes # have been computed by the browser. DeferredCommand().add(self)
class Stream_get(Showcase): """ Showcase for method call <code>stream.get</code> @author olamar72 """ @java.init def __init__(self, *a, **kw): self.outer = VerticalPanel() self.stream = None method = u"stream.get" @__init__.register @java.typed() def __init__(self, ): self.__init__._super() self.outer.setSpacing(5) self.outer.addStyleName(u"gwittit-Stream_get") self.outer.getElement().setId(self.__class__.method) self.initWidget(self.outer) def getNeedPermission(self): """ Need read stream to render showcase """ return Permission.read_stream def permissionGranted(self): self.renderMainContent(self.outer) def getMessage(self): return u"Click to access your NewsFeed" @java.typed(VerticalPanel) def renderMainContent(self, addContentToPnl): """ Render when user granted us permission to read stream """ streamBody = VerticalPanel() streamBody.getElement().setId(u"streamBody") menu = HorizontalPanel() menu.addStyleName(u"streamMenu") menu.setSpacing(5) postsLink = Anchor(u"Posts") # Create menu profilesLink = Anchor(u"Profiles") albumsLink = Anchor(u"Albums") menu.add(HTML(u"<b> Choose Stream : </b> ")) menu.add(postsLink) menu.add(albumsLink) menu.add(profilesLink) class _anonymous(ClickHandler): @java.typed(ClickEvent) def onClick(self, event): self.renderPosts(streamBody, self.stream.getPosts()) Xfbml.parse(streamBody) postsLink.addClickHandler(_anonymous()) # Click posts link class _anonymous(ClickHandler): @java.typed(ClickEvent) def onClick(self, event): streamBody.clear() self.renderProfiles(streamBody, self.stream.getProfiles()) profilesLink.addClickHandler(_anonymous()) # Click profiles link class _anonymous(ClickHandler): @java.typed(ClickEvent) def onClick(self, event): self.renderAlbums(streamBody, self.stream.getAlbums()) albumsLink.addClickHandler(_anonymous()) # Click album links addContentToPnl.add(streamBody) self.addLoader(streamBody) # Start loading class _anonymous(AsyncCallback): @java.typed(Throwable) def onFailure(self, caught): self.handleFailure(caught) @java.typed(Stream) def onSuccess(self, result): self.stream = result addContentToPnl.insert(menu, 0) self.removeLoader(streamBody) self.renderPosts(streamBody, result.getPosts()) Xfbml.parse(streamBody) self.apiClient.streamGet(_anonymous()) # Get stream from facebook. @java.typed(VerticalPanel, JsArray) def renderAlbums(self, addContentToPnl, albums): """ Render list of albums in stream """ addContentToPnl.clear() p = VerticalPanel() p.getElement().setId(u"ProfilAlbums") p.add(HTML(u"<h3>Albums in Stream</h3>")) for a in Util.iterate(albums): p.add(HTML(java.str(u"<h4>" + java.str(a.getName())) + u"</h4>")) if a.hasCover(): p.add(HTML(u" CoverPid: " + java.str(a.getCoverPid()))) p.add(FbPhoto(a.getCoverPid(), FbPhoto.Size.small)) addContentToPnl.add(p) Xfbml.parse(p) @java.typed(VerticalPanel, JsArray) def renderProfiles(self, addContentToPnl, profiles): """ Render profiles in the stream """ addContentToPnl.clear() addContentToPnl.add(HTML(u"<h3>Profiles in Strea</h3>")) for p in Util.iterate(profiles): tmp = FlowPanel() # Split pic on the left, name on the right tmp.addStyleName(u"profiles fbColorLight rounded addSpace") tmp.add(Image(p.getPicSquare())) a = Anchor(p.getName()) # Link to profile a.addStyleName(u"postContent") a.setHref(p.getUrl()) tmp.add(a) addContentToPnl.add(tmp) @java.typed(VerticalPanel, JsArray) def renderPosts(self, addContentToPnl, posts): """ Render posts i a stream """ addContentToPnl.clear() addContentToPnl.add(HTML(u"Number of posts: " + java.str(posts.__len__()))) for post in Util.iterate(posts): try: GWT.log(u"Render: " + java.str(JSONObject(post).toString()), None) postContentPnl = VerticalPanel() postContentPnl.addStyleName(u"postContent") postContentPnl.add(HTML(java.str(FbName(post.getActorId())) + u" " + post.getMessage())) if post.getAttachment().getName() is not None: postContentPnl.add(self.createAttachmentUI(post.getAttachment())) if post.getLikes().getCount() > 0: postContentPnl.add(self.createLikesUI(post.getLikes())) if post.getComments().getCount() > 0: postContentPnl.add(self.createCommentsUI(post.getComments())) p = HorizontalPanel() # Add profilepic on the left, postcontent on the right p.addStyleName(u"post") p.add(FbProfilePic(post.getActorId())) p.add(postContentPnl) addContentToPnl.add(p) # postPnl.add ( asJson ( "LikesAsJson: ", post.getLikes () )); except Exception,e: GWT.log(u"Unkown exception ", e)
class Notifications_send(Showcase): """ Showcase for <code>notifications.send</code> """ @java.init def __init__(self, *a, **kw): self.outer = VerticalPanel() self.notificationText = TextArea() def getNeedPermission(self): """ Get email permissions. """ return Permission.email def permissionGranted(self): self.renderUI() # Send notification @java.private @java.innerclass @java.implements(ClickHandler) class NotificationSendHandler(Object): @java.init def __init__(self, *a, **kw): pass @java.typed(ClickEvent) def onClick(self, event): self.sendToServer() # Notification sent @java.private @java.innerclass @java.implements(AsyncCallbackList) class NotificationSent(Object): @java.init def __init__(self, *a, **kw): pass @java.typed(Throwable) def onFailure(self, caught): self.handleFailure(caught) @java.typed(List) def onSuccess(self, result): self.notificationText.setValue(None) self.outer.add(HTML(u"<h3>Email Sent!</h3> <br/> Recepients: ")) for uid in result: self.outer.add(FbName(uid)) Xfbml.parse(self.outer) @__init__.register @java.typed() def __init__(self,): self.__init__._super() """ Create showcase """ self.initWidget(self.outer) @java.private def renderUI(self): fbName = FbName(self.apiClient.getLoggedInUser()) fbName.setUseyou(False) text = HTML(java.str(u"This will send an email notification to " + java.str(fbName)) + u"(you).") text.getElement().setId(u"text") self.notificationText.setWidth(u"500px") self.notificationText.setHeight(u"100px") self.notificationText.setFocus(True) self.outer.setSpacing(10) submit = Button(u"Send") submit.addClickHandler(self.NotificationSendHandler()) self.outer.add(text) self.outer.add(self.notificationText) self.outer.add(submit) Xfbml.parse(text) # Send notiication. @java.private def sendToServer(self): toIds = ArrayList((Long)) toIds.add(self.apiClient.getLoggedInUser()) self.apiClient.notificationsSendEmail( toIds, u"Notification Send Email", self.notificationText.getValue(), None, self.NotificationSent() ) # toIds.add ( new Long ( FacebookConnect.getLoggedInUser () ) );
class Comments_add(Showcase): """ Showcase for method call <code>comments.add</code> @author olamar72 """ @java.init def __init__(self, *a, **kw): self.outer = VerticalPanel() self.inputWrapper = VerticalPanel() self.responseWrapper = SimplePanel() self.commentsListPanel = VerticalPanel() self.text = TextArea() self.submitButton = Button(u"Add Comment ") # Handle add comment @java.private @java.innerclass @java.implements(AsyncCallbackJavaScriptObject) class AddCommentCallback(Object): @java.init def __init__(self, *a, **kw): pass @java.typed(Throwable) def onFailure(self, caught): self.handleFailure(caught) @java.typed(JavaScriptObject) def onSuccess(self, result): self.removeLoader(self.outer) self.text.setValue(None) self.responseWrapper.add(HTML(u" Thanks :-)")) self.displayComments() # User adds comment @java.private @java.innerclass @java.implements(ClickHandler) class AddCommentClickHandler(Object): @java.init def __init__(self, *a, **kw): pass @java.typed(ClickEvent) def onClick(self, event): comment = Comment.createComment(u"comments_test", self.text.getValue()) self.apiClient.commentsAdd(comment, self.AddCommentCallback()) @__init__.register @java.typed() def __init__(self, ): self.__init__._super() """ New demo """ self.inputWrapper.setSpacing(10) self.outer.setSpacing(10) self.inputWrapper.getElement().setId(u"CommentsAdd-Input") # ID's self.submitButton.getElement().getStyle().setProperty(u"float", u"right") # Styles self.submitButton.getElement().getStyle().setProperty(u"marginTop", u"10px") self.inputWrapper.add(HTML(u"A comment would be great! Thanks.")) self.inputWrapper.add(self.createInputUi()) self.outer.add(self.inputWrapper) self.outer.add(self.responseWrapper) # Thank you self.outer.add(self.commentsListPanel) # Show list of comments self.displayComments() self.submitButton.addClickHandler(self.AddCommentClickHandler()) Xfbml.parse(self.inputWrapper) self.initWidget(self.outer) @java.private def createInputUi(self): """ * Create input text area and submit button. """ vp = VerticalPanel() p = HorizontalPanel() p.setSpacing(10) p.add(FbProfilePic(self.apiClient.getLoggedInUser(), FbProfilePic.Size.square)) self.text.setHeight(u"100px") self.text.setWidth(u"400px") vp.add(self.text) vp.add(self.submitButton) p.add(vp) return p def displayComments(self): self.commentsListPanel.clear() comments = Comments_get() self.commentsListPanel.add(comments)
def onModuleLoad(self): Window.addWindowResizeListener(self) panel = DockPanel() RootPanel().add(panel) self.panel = panel panel.setWidth("100%") # panel.setHeight("100%") panel.setSpacing(5) title = HTML("<h1>pyjslib</h1>") description = HTML("""""") # panel.add(title, DockPanel.NORTH) panel.add(description, DockPanel.NORTH) links = VerticalPanel() links.setSpacing(8) panel.add(links, DockPanel.NORTH) head = HTML( """ <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> <tr bgcolor="#7799ee"> <td valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>pyjslib</strong></big></big></font></td ><td align=right valign=bottom ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/lkcl/src/pyjamas-desktop/pyjamas-webkit/pyjamas/pyjslib.py">/home/lkcl/src/pyjamas-desktop/pyjamas-webkit/pyjamas/pyjslib.py</a></font></td></tr></table> """ ) panel.add(head, DockPanel.NORTH) docs = HTML( """<tt># Copyright 2006 James Tauber and contributors<br> #<br> # Licensed under the Apache License, Version 2.0 (the "License");<br> # you may not use this file except in compliance with the License.<br> # You may obtain a copy of the License at<br> #<br> # <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a><br> #<br> # Unless required by applicable law or agreed to in writing, software<br> # distributed under the License is distributed on an "AS IS" BASIS,<br> # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br> # See the License for the specific language governing permissions and<br> # limitations under the License.</tt>""" ) panel.add(docs, DockPanel.NORTH) tp = TabPanel() tp.setWidth("100%") self.tp = tp panel.add(tp, DockPanel.SOUTH) # panel.setCellHeight(tp, "100%") classes = [Proto("Class"), Proto("Dict"), Proto("List", [Proto("Tuple"), Proto("Tuple")]), Proto("Object")] class_content = { "Tuple": r"""<p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <font color="#000000" face="helvetica, arial"><a name="Tuple">class <strong>Tuple</strong></a>(<a href="docpyjslib.html#List">List</a>)</font></td></tr> <tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> <td width="100%">Methods defined here:<br> <dl><dt><a name="Tuple-__init__"><strong>__init__</strong></a>(self, data)</dt></dl> <hr> Methods inherited from <a href="docpyjslib.html#List">List</a>:<br> <dl><dt><a name="Tuple-__contains__"><strong>__contains__</strong></a>(self, value)</dt></dl> <dl><dt><a name="Tuple-__delitem__"><strong>__delitem__</strong></a>(self, index)</dt></dl> <dl><dt><a name="Tuple-__getitem__"><strong>__getitem__</strong></a>(self, index)</dt></dl> <dl><dt><a name="Tuple-__iter__"><strong>__iter__</strong></a>(self)</dt></dl> <dl><dt><a name="Tuple-__len__"><strong>__len__</strong></a>(self)</dt></dl> <dl><dt><a name="Tuple-__setitem__"><strong>__setitem__</strong></a>(self, index, value)</dt></dl> <dl><dt><a name="Tuple-append"><strong>append</strong></a>(self, item)</dt></dl> <dl><dt><a name="Tuple-getArray"><strong>getArray</strong></a>(self)</dt><dd><tt>Access the javascript Array that is used internally by this <a href="#list">list</a></tt></dd></dl> <dl><dt><a name="Tuple-index"><strong>index</strong></a>(self, value, start<font color="#909090">=0</font>)</dt></dl> <dl><dt><a name="Tuple-insert"><strong>insert</strong></a>(self, index, value)</dt></dl> <dl><dt><a name="Tuple-pop"><strong>pop</strong></a>(self, index<font color="#909090">=-1</font>)</dt></dl> <dl><dt><a name="Tuple-remove"><strong>remove</strong></a>(self, value)</dt></dl> <dl><dt><a name="Tuple-slice"><strong>slice</strong></a>(self, lower, upper)</dt></dl> <dl><dt><a name="Tuple-sort"><strong>sort</strong></a>(self, compareFunc<font color="#909090">=None</font>, keyFunc<font color="#909090">=None</font>, reverse<font color="#909090">=False</font>)</dt></dl> </td></tr></table>""", "list": r"""<p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <font color="#000000" face="helvetica, arial"><strong>list</strong> = <a name="list">class List</a></font></td></tr> <tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> <td width="100%">Methods defined here:<br> <dl><dt><a name="List-__contains__"><strong>__contains__</strong></a>(self, value)</dt></dl> <dl><dt><a name="List-__delitem__"><strong>__delitem__</strong></a>(self, index)</dt></dl> <dl><dt><a name="List-__getitem__"><strong>__getitem__</strong></a>(self, index)</dt></dl> <dl><dt><a name="List-__init__"><strong>__init__</strong></a>(self, data<font color="#909090">=None</font>)</dt></dl> <dl><dt><a name="List-__iter__"><strong>__iter__</strong></a>(self)</dt></dl> <dl><dt><a name="List-__len__"><strong>__len__</strong></a>(self)</dt></dl> <dl><dt><a name="List-__setitem__"><strong>__setitem__</strong></a>(self, index, value)</dt></dl> <dl><dt><a name="List-append"><strong>append</strong></a>(self, item)</dt></dl> <dl><dt><a name="List-getArray"><strong>getArray</strong></a>(self)</dt><dd><tt>Access the javascript Array that is used internally by this <a href="#list">list</a></tt></dd></dl> <dl><dt><a name="List-index"><strong>index</strong></a>(self, value, start<font color="#909090">=0</font>)</dt></dl> <dl><dt><a name="List-insert"><strong>insert</strong></a>(self, index, value)</dt></dl> <dl><dt><a name="List-pop"><strong>pop</strong></a>(self, index<font color="#909090">=-1</font>)</dt></dl> <dl><dt><a name="List-remove"><strong>remove</strong></a>(self, value)</dt></dl> <dl><dt><a name="List-slice"><strong>slice</strong></a>(self, lower, upper)</dt></dl> <dl><dt><a name="List-sort"><strong>sort</strong></a>(self, compareFunc<font color="#909090">=None</font>, keyFunc<font color="#909090">=None</font>, reverse<font color="#909090">=False</font>)</dt></dl> </td></tr></table>""", "Object": r"""<p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <font color="#000000" face="helvetica, arial"><a name="Object">class <strong>Object</strong></a></font></td></tr> <tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> <td width="100%"></td></tr></table>""", "List": r"""<p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <font color="#000000" face="helvetica, arial"><a name="List">class <strong>List</strong></a></font></td></tr> <tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> <td width="100%">Methods defined here:<br> <dl><dt><a name="List-__contains__"><strong>__contains__</strong></a>(self, value)</dt></dl> <dl><dt><a name="List-__delitem__"><strong>__delitem__</strong></a>(self, index)</dt></dl> <dl><dt><a name="List-__getitem__"><strong>__getitem__</strong></a>(self, index)</dt></dl> <dl><dt><a name="List-__init__"><strong>__init__</strong></a>(self, data<font color="#909090">=None</font>)</dt></dl> <dl><dt><a name="List-__iter__"><strong>__iter__</strong></a>(self)</dt></dl> <dl><dt><a name="List-__len__"><strong>__len__</strong></a>(self)</dt></dl> <dl><dt><a name="List-__setitem__"><strong>__setitem__</strong></a>(self, index, value)</dt></dl> <dl><dt><a name="List-append"><strong>append</strong></a>(self, item)</dt></dl> <dl><dt><a name="List-getArray"><strong>getArray</strong></a>(self)</dt><dd><tt>Access the javascript Array that is used internally by this <a href="#list">list</a></tt></dd></dl> <dl><dt><a name="List-index"><strong>index</strong></a>(self, value, start<font color="#909090">=0</font>)</dt></dl> <dl><dt><a name="List-insert"><strong>insert</strong></a>(self, index, value)</dt></dl> <dl><dt><a name="List-pop"><strong>pop</strong></a>(self, index<font color="#909090">=-1</font>)</dt></dl> <dl><dt><a name="List-remove"><strong>remove</strong></a>(self, value)</dt></dl> <dl><dt><a name="List-slice"><strong>slice</strong></a>(self, lower, upper)</dt></dl> <dl><dt><a name="List-sort"><strong>sort</strong></a>(self, compareFunc<font color="#909090">=None</font>, keyFunc<font color="#909090">=None</font>, reverse<font color="#909090">=False</font>)</dt></dl> </td></tr></table>""", "tuple": r"""<p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <font color="#000000" face="helvetica, arial"><strong>tuple</strong> = <a name="tuple">class Tuple</a>(<a href="docpyjslib.html#List">List</a>)</font></td></tr> <tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> <td width="100%">Methods defined here:<br> <dl><dt><a name="Tuple-__init__"><strong>__init__</strong></a>(self, data)</dt></dl> <hr> Methods inherited from <a href="docpyjslib.html#List">List</a>:<br> <dl><dt><a name="Tuple-__contains__"><strong>__contains__</strong></a>(self, value)</dt></dl> <dl><dt><a name="Tuple-__delitem__"><strong>__delitem__</strong></a>(self, index)</dt></dl> <dl><dt><a name="Tuple-__getitem__"><strong>__getitem__</strong></a>(self, index)</dt></dl> <dl><dt><a name="Tuple-__iter__"><strong>__iter__</strong></a>(self)</dt></dl> <dl><dt><a name="Tuple-__len__"><strong>__len__</strong></a>(self)</dt></dl> <dl><dt><a name="Tuple-__setitem__"><strong>__setitem__</strong></a>(self, index, value)</dt></dl> <dl><dt><a name="Tuple-append"><strong>append</strong></a>(self, item)</dt></dl> <dl><dt><a name="Tuple-getArray"><strong>getArray</strong></a>(self)</dt><dd><tt>Access the javascript Array that is used internally by this <a href="#list">list</a></tt></dd></dl> <dl><dt><a name="Tuple-index"><strong>index</strong></a>(self, value, start<font color="#909090">=0</font>)</dt></dl> <dl><dt><a name="Tuple-insert"><strong>insert</strong></a>(self, index, value)</dt></dl> <dl><dt><a name="Tuple-pop"><strong>pop</strong></a>(self, index<font color="#909090">=-1</font>)</dt></dl> <dl><dt><a name="Tuple-remove"><strong>remove</strong></a>(self, value)</dt></dl> <dl><dt><a name="Tuple-slice"><strong>slice</strong></a>(self, lower, upper)</dt></dl> <dl><dt><a name="Tuple-sort"><strong>sort</strong></a>(self, compareFunc<font color="#909090">=None</font>, keyFunc<font color="#909090">=None</font>, reverse<font color="#909090">=False</font>)</dt></dl> </td></tr></table>""", "dict": r"""<p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <font color="#000000" face="helvetica, arial"><strong>dict</strong> = <a name="dict">class Dict</a></font></td></tr> <tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> <td width="100%">Methods defined here:<br> <dl><dt><a name="Dict-__contains__"><strong>__contains__</strong></a>(self, key)</dt></dl> <dl><dt><a name="Dict-__delitem__"><strong>__delitem__</strong></a>(self, key)</dt></dl> <dl><dt><a name="Dict-__getitem__"><strong>__getitem__</strong></a>(self, key)</dt></dl> <dl><dt><a name="Dict-__init__"><strong>__init__</strong></a>(self, data<font color="#909090">=None</font>)</dt></dl> <dl><dt><a name="Dict-__iter__"><strong>__iter__</strong></a>(self)</dt></dl> <dl><dt><a name="Dict-__len__"><strong>__len__</strong></a>(self)</dt></dl> <dl><dt><a name="Dict-__setitem__"><strong>__setitem__</strong></a>(self, key, value)</dt></dl> <dl><dt><a name="Dict-get"><strong>get</strong></a>(self, key, default_value<font color="#909090">=None</font>)</dt></dl> <dl><dt><a name="Dict-getObject"><strong>getObject</strong></a>(self)</dt><dd><tt>Return the javascript <a href="#Object">Object</a> which this class uses to store dictionary keys and values</tt></dd></dl> <dl><dt><a name="Dict-has_key"><strong>has_key</strong></a>(self, key)</dt></dl> <dl><dt><a name="Dict-iteritems"><strong>iteritems</strong></a>(self)</dt></dl> <dl><dt><a name="Dict-iterkeys"><strong>iterkeys</strong></a>(self)</dt></dl> <dl><dt><a name="Dict-itervalues"><strong>itervalues</strong></a>(self)</dt></dl> <dl><dt><a name="Dict-keys"><strong>keys</strong></a>(self)</dt></dl> <dl><dt><a name="Dict-setdefault"><strong>setdefault</strong></a>(self, key, default_value)</dt></dl> <dl><dt><a name="Dict-update"><strong>update</strong></a>(self, d)</dt></dl> <dl><dt><a name="Dict-values"><strong>values</strong></a>(self)</dt></dl> </td></tr></table>""", "Dict": r"""<p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <font color="#000000" face="helvetica, arial"><a name="Dict">class <strong>Dict</strong></a></font></td></tr> <tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> <td width="100%">Methods defined here:<br> <dl><dt><a name="Dict-__contains__"><strong>__contains__</strong></a>(self, key)</dt></dl> <dl><dt><a name="Dict-__delitem__"><strong>__delitem__</strong></a>(self, key)</dt></dl> <dl><dt><a name="Dict-__getitem__"><strong>__getitem__</strong></a>(self, key)</dt></dl> <dl><dt><a name="Dict-__init__"><strong>__init__</strong></a>(self, data<font color="#909090">=None</font>)</dt></dl> <dl><dt><a name="Dict-__iter__"><strong>__iter__</strong></a>(self)</dt></dl> <dl><dt><a name="Dict-__len__"><strong>__len__</strong></a>(self)</dt></dl> <dl><dt><a name="Dict-__setitem__"><strong>__setitem__</strong></a>(self, key, value)</dt></dl> <dl><dt><a name="Dict-get"><strong>get</strong></a>(self, key, default_value<font color="#909090">=None</font>)</dt></dl> <dl><dt><a name="Dict-getObject"><strong>getObject</strong></a>(self)</dt><dd><tt>Return the javascript <a href="#Object">Object</a> which this class uses to store dictionary keys and values</tt></dd></dl> <dl><dt><a name="Dict-has_key"><strong>has_key</strong></a>(self, key)</dt></dl> <dl><dt><a name="Dict-iteritems"><strong>iteritems</strong></a>(self)</dt></dl> <dl><dt><a name="Dict-iterkeys"><strong>iterkeys</strong></a>(self)</dt></dl> <dl><dt><a name="Dict-itervalues"><strong>itervalues</strong></a>(self)</dt></dl> <dl><dt><a name="Dict-keys"><strong>keys</strong></a>(self)</dt></dl> <dl><dt><a name="Dict-setdefault"><strong>setdefault</strong></a>(self, key, default_value)</dt></dl> <dl><dt><a name="Dict-update"><strong>update</strong></a>(self, d)</dt></dl> <dl><dt><a name="Dict-values"><strong>values</strong></a>(self)</dt></dl> </td></tr></table>""", "Class": r"""<p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <font color="#000000" face="helvetica, arial"><a name="Class">class <strong>Class</strong></a></font></td></tr> <tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> <td width="100%">Methods defined here:<br> <dl><dt><a name="Class-__init__"><strong>__init__</strong></a>(self, name)</dt></dl> <dl><dt><a name="Class-__str___"><strong>__str___</strong></a>(self)</dt></dl> </td></tr></table>""", } self.class_doc = ClassDoc(classes, class_content) tp.add(self.class_doc, "Classes") functions = [ '<dl><dt><a name="-cmp"><strong>cmp</strong></a>(a, b)</dt></dl>\n', '<dl><dt><a name="-dir"><strong>dir</strong></a>(obj)</dt></dl>\n', '<dl><dt><a name="-filter"><strong>filter</strong></a>(obj, method, sequence<font color="#909090">=None</font>)</dt></dl>\n', '<dl><dt><a name="-getattr"><strong>getattr</strong></a>(obj, method)</dt></dl>\n', '<dl><dt><a name="-hasattr"><strong>hasattr</strong></a>(obj, method)</dt></dl>\n', '<dl><dt><a name="-hash"><strong>hash</strong></a>(obj)</dt></dl>\n', '<dl><dt><a name="-isArray"><strong>isArray</strong></a>(a)</dt></dl>\n', '<dl><dt><a name="-isFunction"><strong>isFunction</strong></a>(a)</dt></dl>\n', '<dl><dt><a name="-isIteratable"><strong>isIteratable</strong></a>(a)</dt></dl>\n', '<dl><dt><a name="-isNull"><strong>isNull</strong></a>(a)</dt></dl>\n', '<dl><dt><a name="-isNumber"><strong>isNumber</strong></a>(a)</dt></dl>\n', '<dl><dt><a name="-isObject"><strong>isObject</strong></a>(a)</dt><dd><tt># type functions from Douglas Crockford\'s Remedial Javascript: <a href="http://www.crockford.com/javascript/remedial.html">http://www.crockford.com/javascript/remedial.html</a></tt></dd></dl>\n', '<dl><dt><a name="-isString"><strong>isString</strong></a>(a)</dt></dl>\n', '<dl><dt><a name="-isUndefined"><strong>isUndefined</strong></a>(a)</dt></dl>\n', '<dl><dt><a name="-len"><strong>len</strong></a>(object)</dt></dl>\n', '<dl><dt><a name="-map"><strong>map</strong></a>(obj, method, sequence<font color="#909090">=None</font>)</dt></dl>\n', '<dl><dt><a name="-printFunc"><strong>printFunc</strong></a>(objs)</dt></dl>\n', '<dl><dt><a name="-range"><strong>range</strong></a>()</dt><dd><tt># taken from mochikit: <a href="#-range">range</a>( [start,] stop[, step] )</tt></dd></dl>\n', '<dl><dt><a name="-slice"><strong>slice</strong></a>(object, lower, upper)</dt></dl>\n', '<dl><dt><a name="-toJSObjects"><strong>toJSObjects</strong></a>(x)</dt><dd><tt>Convert the pyjs pythonic <a href="#List">List</a> and <a href="#Dict">Dict</a> objects into javascript <a href="#Object">Object</a> and Array<br>\nobjects, recursively.</tt></dd></dl>\n', ] title = bigtitle("Functions") contents = section(title, "functions", HTML("\n".join(functions))) tp.add(contents, "Functions") data = [r"""<strong>next_hash_id</strong> = 0"""] title = bigtitle("Data") contents = section(title, "data", HTML("\n".join(data))) tp.add(contents, "Data") tp.addTabListener(self) tp.selectTab(0) # Call the window resized handler to get the initial sizes setup. Doing # this in a deferred command causes it to occur after all widgets' sizes # have been computed by the browser. DeferredCommand().add(self)
def onModuleLoad(self): Window.addWindowResizeListener(self) panel = DockPanel() RootPanel().add(panel) self.panel = panel panel.setWidth("100%") #panel.setHeight("100%") panel.setSpacing(5) title = HTML('<h1>JSONParser</h1>') description = HTML("""""") #panel.add(title, DockPanel.NORTH) panel.add(description, DockPanel.NORTH) links = VerticalPanel() links.setSpacing(8) panel.add(links, DockPanel.NORTH) head = HTML(""" <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> <tr bgcolor="#7799ee"> <td valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>JSONParser</strong></big></big></font></td ><td align=right valign=bottom ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/lkcl/src/pyjamas-desktop/pyjamas-webkit/pyjamas/JSONParser.py">/home/lkcl/src/pyjamas-desktop/pyjamas-webkit/pyjamas/JSONParser.py</a></font></td></tr></table> """) panel.add(head, DockPanel.NORTH) docs = HTML("""<tt>This module contains a JSON Parser class<br> <br> JSONEncode:<br> +---------------+-------------------+---------------+<br> | PYGWT | Python | JSON |<br> +===============+===================+===============+<br> | pyjslib_Dict | dict | object |<br> +---------------+-------------------+---------------+<br> | pyjslib_List | list, tuple | array |<br> +---------------+-------------------+---------------+<br> | string | str, unicode | string |<br> +---------------+-------------------+---------------+<br> | number | int, long, float | number |<br> +---------------+-------------------+---------------+<br> | true | True | true |<br> +---------------+-------------------+---------------+<br> | false | False | false |<br> +---------------+-------------------+---------------+<br> | null | None | null |<br> +---------------+-------------------+---------------+<br> <br> <br> JSONDecode:<br> +---------------+-------------------+--------------+<br> | JSON | Python | PYGWT |<br> +===============+===================+==============+<br> | object | dict | pyjslib_Dict |<br> +---------------+-------------------+--------------+<br> | array | list | pyjslib_List |<br> +---------------+-------------------+--------------+<br> | string | unicode | string |<br> +---------------+-------------------+--------------+<br> | number (int) | int, long | number |<br> +---------------+-------------------+--------------+<br> | number (real) | float | number |<br> +---------------+-------------------+--------------+<br> | true | True | true |<br> +---------------+-------------------+--------------+<br> | false | False | false |<br> +---------------+-------------------+--------------+<br> | null | None | null |<br> +---------------+-------------------+--------------+</tt>""") panel.add(docs, DockPanel.NORTH) tp = TabPanel() tp.setWidth("100%") self.tp = tp panel.add(tp, DockPanel.SOUTH) #panel.setCellHeight(tp, "100%") classes = [ Proto('JSONParser'), ] class_content = { 'JSONParser': r'''<p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <font color="#000000" face="helvetica, arial"><a name="JSONParser">class <strong>JSONParser</strong></a></font></td></tr> <tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> <td width="100%">Methods defined here:<br> <dl><dt><a name="JSONParser-decode"><strong>decode</strong></a>(self, str)</dt></dl> <dl><dt><a name="JSONParser-decodeAsObject"><strong>decodeAsObject</strong></a>(self, str)</dt></dl> <dl><dt><a name="JSONParser-encode"><strong>encode</strong></a>(self, obj)</dt></dl> <dl><dt><a name="JSONParser-jsObjectToPy"><strong>jsObjectToPy</strong></a>(self, obj)</dt></dl> <dl><dt><a name="JSONParser-jsObjectToPyObject"><strong>jsObjectToPyObject</strong></a>(self, obj)</dt><dd><tt># TODO: __init__ parameters</tt></dd></dl> <dl><dt><a name="JSONParser-parseJSON"><strong>parseJSON</strong></a>(self, str)</dt></dl> <dl><dt><a name="JSONParser-toJSONString"><strong>toJSONString</strong></a>(self, obj)</dt><dd><tt># modified to detect __pyjslib_List & __pyjslib_Dict</tt></dd></dl> </td></tr></table>''', } self.class_doc = ClassDoc(classes, class_content) tp.add(self.class_doc, 'Classes') tp.addTabListener(self) tp.selectTab(0) # Call the window resized handler to get the initial sizes setup. Doing # this in a deferred command causes it to occur after all widgets' sizes # have been computed by the browser. DeferredCommand().add(self)
def onModuleLoad(self): Window.addWindowResizeListener(self) panel = DockPanel() RootPanel().add(panel) self.panel = panel panel.setWidth("100%") # panel.setHeight("100%") panel.setSpacing(5) title = HTML("<h1>HTTPRequest</h1>") description = HTML("""""") # panel.add(title, DockPanel.NORTH) panel.add(description, DockPanel.NORTH) links = VerticalPanel() links.setSpacing(8) panel.add(links, DockPanel.NORTH) head = HTML( """ <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> <tr bgcolor="#7799ee"> <td valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>HTTPRequest</strong></big></big></font></td ><td align=right valign=bottom ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/lkcl/src/pyjamas-desktop/pyjamas-webkit/pyjamas/HTTPRequest.py">/home/lkcl/src/pyjamas-desktop/pyjamas-webkit/pyjamas/HTTPRequest.py</a></font></td></tr></table> """ ) panel.add(head, DockPanel.NORTH) docs = HTML("""""") panel.add(docs, DockPanel.NORTH) tp = TabPanel() tp.setWidth("100%") self.tp = tp panel.add(tp, DockPanel.SOUTH) # panel.setCellHeight(tp, "100%") modules = [r"""<a href="docpyjamas.Cookies.html">pyjamas.Cookies</a>""", r"""<a href="docsys.html">sys</a>"""] contents = self.multicolumn(modules) title = bigtitle("Modules") contents = section(title, "module", contents) tp.add(contents, "Modules") classes = [Proto("HTTPRequest")] class_content = { "HTTPRequest": r"""<p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <font color="#000000" face="helvetica, arial"><a name="HTTPRequest">class <strong>HTTPRequest</strong></a></font></td></tr> <tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> <td width="100%">Methods defined here:<br> <dl><dt><a name="HTTPRequest-asyncGet"><strong>asyncGet</strong></a>(self, user, pwd, url, handler)</dt><dd><tt># also callable as: <a href="#HTTPRequest-asyncGet">asyncGet</a>(self, url, handler)</tt></dd></dl> <dl><dt><a name="HTTPRequest-asyncGetImpl"><strong>asyncGetImpl</strong></a>(self, user, pwd, url, handler)</dt></dl> <dl><dt><a name="HTTPRequest-asyncPost"><strong>asyncPost</strong></a>(self, user, pwd, url, postData<font color="#909090">=None</font>, handler<font color="#909090">=None</font>)</dt><dd><tt># also callable as: <a href="#HTTPRequest-asyncPost">asyncPost</a>(self, url, postData, handler)</tt></dd></dl> <dl><dt><a name="HTTPRequest-asyncPostImpl"><strong>asyncPostImpl</strong></a>(self, user, pwd, url, postData, handler)</dt></dl> <dl><dt><a name="HTTPRequest-createXmlHTTPRequest"><strong>createXmlHTTPRequest</strong></a>(self)</dt></dl> <dl><dt><a name="HTTPRequest-doCreateXmlHTTPRequest"><strong>doCreateXmlHTTPRequest</strong></a>(self)</dt></dl> <dl><dt><a name="HTTPRequest-onReadyStateChange"><strong>onReadyStateChange</strong></a>(self, xmlHttp, event, ignorearg)</dt></dl> </td></tr></table>""" } self.class_doc = ClassDoc(classes, class_content) tp.add(self.class_doc, "Classes") tp.addTabListener(self) tp.selectTab(0) # Call the window resized handler to get the initial sizes setup. Doing # this in a deferred command causes it to occur after all widgets' sizes # have been computed by the browser. DeferredCommand().add(self)
def __init__(self): Sink.__init__(self) text="This is a <code>ScrollPanel</code> contained at " text+= "the center of a <code>DockPanel</code>. " text+= "By putting some fairly large contents " text+= "in the middle and setting its size explicitly, it becomes a " text+= "scrollable area within the page, but without requiring the use of " text+= "an IFRAME." text+= "Here's quite a bit more meaningless text that will serve primarily " text+= "to make this thing scroll off the bottom of its visible area. " text+= "Otherwise, you might have to make it really, really small in order " text+= "to see the nifty scroll bars!" contents = HTML(text) scroller = ScrollPanel(contents) scroller.setStyleName("ks-layouts-Scroller") dock = DockPanel() dock.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) north0 = HTML("This is the <i>first</i> north component", True) east = HTML("<center>This<br>is<br>the<br>east<br>component</center>", True) south = HTML("This is the south component") west = HTML("<center>This<br>is<br>the<br>west<br>component</center>", True) north1 = HTML("This is the <b>second</b> north component", True) dock.add(north0, DockPanel.NORTH) dock.add(east, DockPanel.EAST) dock.add(south, DockPanel.SOUTH) dock.add(west, DockPanel.WEST) dock.add(north1, DockPanel.NORTH) dock.add(scroller, DockPanel.CENTER) #Logger.write("Layouts", "TODO: flowpanel") flow = FlowPanel() for i in range(8): flow.add(CheckBox("Flow %d" % i)) horz = HorizontalPanel() horz.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE) horz.add(Button("Button")) horz.add(HTML("<center>This is a<br>very<br>tall thing</center>", True)) horz.add(Button("Button")) vert = VerticalPanel() vert.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) vert.add(Button("Small")) vert.add(Button("--- BigBigBigBig ---")) vert.add(Button("tiny")) menu = MenuBar() menu0 = MenuBar(True) menu1 = MenuBar(True) menu.addItem("menu0", menu0) menu.addItem("menu1", menu1) menu0.addItem("child00") menu0.addItem("child01") menu0.addItem("child02") menu1.addItem("child10") menu1.addItem("child11") menu1.addItem("child12") #Logger.write("Layouts", "TODO: htmlpanel") id = HTMLPanel_createUniqueId() text="This is an <code>HTMLPanel</code>. It allows you to add " text+="components inside existing HTML, like this:" + "<span id='" + id text+="'></span>" + "Notice how the menu just fits snugly in there? Cute." html = HTMLPanel(text) #DOM.setStyleAttribute(menu.getElement(), "display", "inline") html.add(menu, id) panel = VerticalPanel() panel.setSpacing(8) panel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) panel.add(self.makeLabel("Dock Panel")) panel.add(dock) panel.add(self.makeLabel("Flow Panel")) panel.add(flow) panel.add(self.makeLabel("Horizontal Panel")) panel.add(horz) panel.add(self.makeLabel("Vertical Panel")) panel.add(vert) panel.add(self.makeLabel("HTML Panel")) panel.add(html) self.initWidget(panel) self.setStyleName("ks-layouts")
class EventEditor(Composite): """ Let user create a new Event. CSS Configuration <ul> <li>.gwittit-EventEditor </ul> """ @java.init def __init__(self, *a, **kw): self.outer = VerticalPanel() self.loader = Image(u"/loader.gif") self.eventInfo = None self.nameText = TextBox() self.categoryListBox = ListBox(False) self.subCategoriesListBox = ListBox(False) self.hostText = TextBox() self.locationText = TextBox() self.cityText = TextBox() self.createEventButton = Button(u"Create Event") self.apiClient = ApiFactory.getInstance() @__init__.register @java.typed() def __init__(self, ): self.__init__._super() self.outer.addStyleName(u"gwittit-EventEditor") self.outer.setSpacing(10) self.initFields() self.outer.add(self.createLabelAndInput(u"Name", self.nameText)) self.outer.add(self.createLabelAndInput(u"Category", self.categoryListBox)) self.outer.add(self.createLabelAndInput(u"SubCategory", self.subCategoriesListBox)) self.outer.add(self.createLabelAndInput(u"Host", self.hostText)) # outer.add ( createLabelAndInput ( "EventEnds" , endTimePicker ) ); self.outer.add(self.createLabelAndInput(u"Location", self.locationText)) self.outer.add(self.createLabelAndInput(u"City", self.cityText)) self.outer.add(self.createEventButton) class _anonymous(ClickHandler): @java.typed(ClickEvent) def onClick(self, event): self.saveOrUpdate() self.createEventButton.addClickHandler(_anonymous()) self.initWidget(self.outer) @java.private def saveOrUpdate(self): """ Save event to facebook """ jEvent = Json() jEvent.put(u"name", self.nameText.getValue()) jEvent.put(u"host", self.hostText.getValue()) jEvent.put(u"location", self.locationText.getValue()) jEvent.put(u"city", self.cityText.getValue()) selectedCategory = Integer(self.categoryListBox.getValue(self.categoryListBox.getSelectedIndex())) # Save Category selectedSubCategory = Integer(self.subCategoriesListBox.getValue(self.subCategoriesListBox.getSelectedIndex())) jEvent.put(u"category", EventInfo.Category.values()[(selectedCategory - 1)].toString()) jEvent.put(u"subcategory", EventInfo.SubCategory.values()[(selectedSubCategory - 1)].toString()) jEvent.put(u"start_time", Date().getTime() + Long(u"9999999999")) jEvent.put(u"end_time", Date().getTime() + Long(u"9999999999999")) eventInfo = EventInfo.fromJson(java.str(jEvent)) self.outer.add(self.loader) class _anonymous(AsyncCallback): @java.typed(Throwable) def onFailure(self, caught): self.outer.remove(self.loader) errorResponse = ErrorResponseUI(caught) errorResponse.center() errorResponse.show() @java.typed(JavaScriptObject) def onSuccess(self, result): self.outer.remove(self.loader) self.outer.add(HTML(u"Created event with ID " + java.str(result))) self.apiClient.eventsCreate(eventInfo, _anonymous()) # Create the event. @java.private def initFields(self): """ Create widgets, and set default values if any """ self.nameText.setValue(u"Birthday") self.hostText.setValue(u"host") self.locationText.setValue(u"location") self.cityText.setValue(u"Palo Alto, CA") for category in EventInfo.Category.values(): self.categoryListBox.addItem(java.str(category).replace(u"_", u" "), u"" + java.str(category.getId())) for subCategory in EventInfo.SubCategory.values(): self.subCategoriesListBox.addItem(java.str(subCategory).replace(u"_", u" "), u"" + java.str(subCategory.getId())) @java.private @java.typed(String, Widget) def createLabelAndInput(self, label, field): h = HorizontalPanel() l = HTML(java.str(u"<b>" + java.str(label)) + u": </b>") l.setWidth(u"150px") h.add(l) h.add(field) return h