def finishgroup(): global curgroup, curgroupwidgets, curgrouphead, fp if curgroup == 0: for widget in curgroupwidgets: fp.add(widget) elif curgroup == 1: dp = DisclosurePanel("Definitions") dpflow = FlowPanel() dp.add(dpflow) for widget in curgroupwidgets: dpflow.add(widget) fp.add(dp) elif curgroup == 2: curgrouphead += " (%s steps)" % (len(curgroupwidgets), ) dp = DisclosurePanel(curgrouphead) dpflow = FlowPanel() dp.add(dpflow) for widget in curgroupwidgets[:-1]: dpflow.add(widget) fp.add(dp) fp.add(curgroupwidgets[-1]) curgroup = 0 curgroupwidgets = [] curgrouphead = None
def __init__(self): Composite.__init__(self) self.albums = [] self.photos = [] self.grid = Grid(4, 4, CellPadding=4, CellSpacing=4) self.grid.addTableListener(self) self.drill = 0 self.pos = 0 self.up = Button("Up", self) self.next = Button("Next", self) self.prev = Button("Prev", self) self.timer = Timer(notify=self) self.userid = "jameskhedley" self.album_url = "http://picasaweb.google.com/data/feed/base/user/" + self.userid + "?alt=json-in-script&kind=album&hl=en_US&callback=restCb" self.doRESTQuery(self.album_url, self.timer) self.vp = VerticalPanel() self.disclosure = DisclosurePanel( "Click for boring technical details.") self.disclosure.add( HTML( '''<p>OK so you want to write client JS to do a RESTful HTTP query from picasa right? Well you can't because of the Same Origin Policy. Basically this means that because the domain of the query and the domain of the hosted site are different, then that could well be a cross-site scripting (XSS) attack. So, the workaround is to do the call from a script tag so the JSON we get back is part of the document. But since we don't know what URL to hit yet, once we find out then we have to inject a new script tag dynamically which the browser will run as soon as we append it. To be honest I'm not 100% why Google use RESTful services and not JSON-RPC or somesuch, which would be easier. Well, easier for me.''')) self.IDPanel = HorizontalPanel() self.IDPanel.add(Label("Enter google account:")) self.IDButton = Button("Go", self) self.IDBox = TextBox() self.IDBox.setText(self.userid) self.IDPanel.add(self.IDBox) self.IDPanel.add(self.IDButton) self.vp.add(self.IDPanel) self.vp.add(self.disclosure) self.vp.add(self.grid) self.initWidget(self.vp)
def __init__(self): Sink.__init__(self) text = """This is a <code>ScrollPanel</code> contained at the center of a <code>DockPanel</code>. By putting some fairly large contents in the middle and setting its size explicitly, it becomes a scrollable area within the page, but without requiring the use of an IFRAME. Here's quite a bit more meaningless text that will serve primarily to make this thing scroll off the bottom of its visible area. Otherwise, you might have to make it really, really small in order to see the nifty scroll bars!""" contents = HTML(text) scroller = ScrollPanel(contents, StyleName="ks-layouts-Scroller") dock = DockPanel(HorizontalAlignment=HasAlignment.ALIGN_CENTER, Spacing=10) 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(VerticalAlignment=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(HorizontalAlignment=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 components inside existing HTML, like this: <span id='%s' /> Notice how the menu just fits snugly in there? Cute.""" % id html = HTMLPanel(text) DOM.setStyleAttribute(menu.getElement(), "display", "inline") html.add(menu, id) disclose = DisclosurePanel("Click to disclose") disclose.add( HTML("""<b>Ta-daaaaa!</b><br />Ok - it could have been<br />more of a surprise.""")) panel = VerticalPanel(Spacing=8, HorizontalAlignment=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) panel.add(self.makeLabel("Disclosure Panel")) panel.add(disclose) self.initWidget(panel) self.setStyleName("ks-layouts")
cf = self.header.getCellFormatter() self.sortbuttons = [] for ncol in range(cols): sb = Button("sort col %d" % ncol) sb.addClickListener(self) self.header.setWidget(0, ncol, sb) cf.setWidth(0, ncol, "200px") self.sortbuttons.append(sb) def onClick(self, sender): for (ncol, b) in enumerate(self.sortbuttons): if sender == b: self.sortcol = ncol self.redraw() data = [["hello", "fred", 52], ["bye", "joe", 98], ["greetings", "alien", 0], ["sayonara", "jun", 1], ["gutentaag", "volker", 2], ["bonjour", "francois", 5], ["au reservoir", "fabrice", 8], ["go away", "mary", 73]] if __name__ == '__main__': pyjd.setup("public/SortedGridThing.html") ogw = OddGridWidget(Width="600px", Height="200px", StyleName="ogw") ogw.setData(data) dp = DisclosurePanel("Click to disclose / hide", True, Width="602px") dp.add(ogw) RootPanel().add(dp) pyjd.run()