本文整理汇总了Python中pyjamas.ui.VerticalPanel.setSpacing方法的典型用法代码示例。如果您正苦于以下问题:Python VerticalPanel.setSpacing方法的具体用法?Python VerticalPanel.setSpacing怎么用?Python VerticalPanel.setSpacing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.VerticalPanel
的用法示例。
在下文中一共展示了VerticalPanel.setSpacing方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createUserInputUI
# 需要导入模块: from pyjamas.ui import VerticalPanel [as 别名]
# 或者: from pyjamas.ui.VerticalPanel import setSpacing [as 别名]
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
示例2: onModuleLoad
# 需要导入模块: from pyjamas.ui import VerticalPanel [as 别名]
# 或者: from pyjamas.ui.VerticalPanel import setSpacing [as 别名]
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)
示例3: createDefaultFrontpage
# 需要导入模块: from pyjamas.ui import VerticalPanel [as 别名]
# 或者: from pyjamas.ui.VerticalPanel import setSpacing [as 别名]
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
示例4: __init__
# 需要导入模块: from pyjamas.ui import VerticalPanel [as 别名]
# 或者: from pyjamas.ui.VerticalPanel import setSpacing [as 别名]
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)
示例5: __init__
# 需要导入模块: from pyjamas.ui import VerticalPanel [as 别名]
# 或者: from pyjamas.ui.VerticalPanel import setSpacing [as 别名]
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)
示例6: __init__
# 需要导入模块: from pyjamas.ui import VerticalPanel [as 别名]
# 或者: from pyjamas.ui.VerticalPanel import setSpacing [as 别名]
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)
示例7: __init__
# 需要导入模块: from pyjamas.ui import VerticalPanel [as 别名]
# 或者: from pyjamas.ui.VerticalPanel import setSpacing [as 别名]
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)
示例8: onModuleLoad
# 需要导入模块: from pyjamas.ui import VerticalPanel [as 别名]
# 或者: from pyjamas.ui.VerticalPanel import setSpacing [as 别名]
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)
示例9: onModuleLoad
# 需要导入模块: from pyjamas.ui import VerticalPanel [as 别名]
# 或者: from pyjamas.ui.VerticalPanel import setSpacing [as 别名]
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)
示例10: onModuleLoad
# 需要导入模块: from pyjamas.ui import VerticalPanel [as 别名]
# 或者: from pyjamas.ui.VerticalPanel import setSpacing [as 别名]
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>
#.........这里部分代码省略.........
示例11: onModuleLoad
# 需要导入模块: from pyjamas.ui import VerticalPanel [as 别名]
# 或者: from pyjamas.ui.VerticalPanel import setSpacing [as 别名]
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)
示例12: onModuleLoad
# 需要导入模块: from pyjamas.ui import VerticalPanel [as 别名]
# 或者: from pyjamas.ui.VerticalPanel import setSpacing [as 别名]
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')
#.........这里部分代码省略.........
示例13: Stream_get
# 需要导入模块: from pyjamas.ui import VerticalPanel [as 别名]
# 或者: from pyjamas.ui.VerticalPanel import setSpacing [as 别名]
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>"))
#.........这里部分代码省略.........
示例14: Notifications_send
# 需要导入模块: from pyjamas.ui import VerticalPanel [as 别名]
# 或者: from pyjamas.ui.VerticalPanel import setSpacing [as 别名]
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 () ) );
示例15: Comments_add
# 需要导入模块: from pyjamas.ui import VerticalPanel [as 别名]
# 或者: from pyjamas.ui.VerticalPanel import setSpacing [as 别名]
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)