def __init__(self, **kwargs): if not kwargs.has_key('StyleName'): kwargs['StyleName'] = "gwt-TabBar" # this is awkward: FlowPanel is the composite, # so we either the element here, and pass it in to FlowPanel. element = None if kwargs.has_key('Element'): element = kwargs.pop('Element') self.panel = FlowPanel(Element=element) self.selectedTab = None self.tabListeners = [] #self.panel.setVerticalAlignment(HasAlignment.ALIGN_BOTTOM) first = HTML(" ", True) rest = HTML(" ", True) first.setStyleName("gwt-TabBarFirst") rest.setStyleName("gwt-TabBarRest") first.setHeight("100%") rest.setHeight("100%") self.panel.add(first) self.panel.add(rest) first.setHeight("100%") #self.panel.setCellHeight(first, "100%") #self.panel.setCellWidth(rest, "100%") Composite.__init__(self, self.panel, **kwargs) self.sinkEvents(Event.ONCLICK)
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): SimplePanel.__init__(self) flow = FlowPanel(Width="400px") flow.add(Button("Item 1")) flow.add(Button("Item 2")) flow.add(Button("Item 3")) flow.add(Button("Item 4")) flow.add(Button("Item 5")) flow.add(Button("Item 6")) flow.add(Button("Item 7")) flow.add(Button("Item 8")) flow.add(Button("Item 9")) flow.add(Button("Item 10")) self.add(flow)
def __init__(self): self.root = RootPanel() #Flow panel taking up 70% of the page. CSS centers it. self.flow = FlowPanel(Width="70%", StyleName='flow-panel') for x in range(0, 10): self.panel = VerticalPanel() #Label each image with its number in the sequence title = Label("Item %s" % x, element=DOM.createElement('span'), StyleName="title item") #Add a neat-o image. image = Image('images/pyjamas.png', Width="200px", Height="200px", StyleName="cat-image cat-item") #Add to the Vertical Panel the image title self.panel.add(title) self.panel.add(image) self.flow.add(self.panel) self.root.add(self.flow)
def reduceterm(sender, maxlines): """When the Reduce button is pressed: call cc.runfile with our input. There is a maximum number of lines that we will output, to prevent a stalling browser and an overfull document. The user can raise this limit with a link. """ input = inputArea.getText() output = "" nlines = 0 def catchoutput(s, end="\n"): output += s + end nlines += 1 if nlines > maxlines: raise OverlongOutput() cc._defs = dict() try: cc.runfile(inputfile=io.StringIO(input), verbose=False, printout=catchoutput, printerr=catchoutput) except OverlongOutput: extra = FlowPanel(StyleName="terminated") extra.add( InlineLabel("Reduction terminated after %s lines. " % (maxlines, ))) extra.add( Button( "Try longer", functools.partial(queuereduce, maxlines=nextmaxlines(maxlines)))) showOutput(output, extra=extra) except Exception, e: Window.alert(e)
def __init__(self, default_value='0', show_indices=True): self._default_value = default_value self._show_indices = show_indices self._values = [] self.panel = FlowPanel()
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")
def showOutput(output, extra=None, nlHTML="<br>"): """Clear outputPanel and show newline-separated output in it. The following types of lines will be parsed differently: - A sequence of "-> term", "-> term" will get a DisclosurePanel. - Definitions will be collapsed in a DisclosurePanel. If extra is set, then append that widget.""" lines = splitlines(output.strip()) if lines: outputPanel.clear() fp = FlowPanel() outputPanel.add(fp) # Add content to the FlowPanel # We distinguish a number of line groups: # # 0: no special handling. # 1: definition group # 2: reduction group curgroup = 0 curgroupwidgets = [] curgrouphead = None RARROW = chr(0x2192) def fixarrow(line): return line def addline(line): global curgroup, curgroupwidgets, curgrouphead, fp line = line.strip() line = line.replace("->", RARROW) if line.startswith("Installing "): # New group: 1 if curgroup != 1: finishgroup() curgroup = 1 curgroupwidgets.append(Label(line)) elif line.startswith(RARROW): # New group: 2. if curgroup == 0: # The last line is still stored in curgroupwidgets. We use # it as the DisclosurePanel head. assert curgrouphead == None if curgroupwidgets == []: curgrouphead = "unknown reduction" else: assert len(curgroupwidgets) == 1 curgrouphead = curgroupwidgets[0].getText() curgroupwidgets = [] elif curgroup != 2: finishgroup() curgroup = 2 curgroupwidgets.append(Label(line)) # Window.alert(curgroupwidgets) else: # New group: 0 finishgroup() curgroup = 0 curgroupwidgets = [Label(line)] 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 for line in lines: addline(line) finishgroup() # fp.add(InlineLabel(lines[0])) # for line in lines[1:]: # fp.add(InlineHTML(nlHTML)) # fp.add(InlineLabel(line)) if extra != None: outputPanel.add(extra) # outputPanel.add(Label(output)) outputPanel.setStyleName("proper") else: showOutputMeta("No output.")
def onModuleLoad(self): dlp = DockPanel(Width="100%", Height="100%") self.m_rte = RichTextArea(Width="500px", Height="400px") self.m_tb = RichTextToolbar(self.m_rte, self) buts = FlowPanel() self.m_getCurr = Button("Refresh v", self) self.m_setHtml = Button("Set html ^", self) self.m_setHtml.setTitle("Set html from the lower left text area") self.m_toSCursor = Button("< To Cursor", self) self.m_toSCursor.setTitle( "Set the selection to be a cursor at the beginning of the current selection" ) self.m_toECursor = Button("To Cursor >", self) self.m_toECursor.setTitle( "Set the selection to be a cursor at the end of the current selection" ) self.m_surround1 = Button("Surround1", self) self.m_surround2 = Button("Surround2", self) self.m_font1 = Button("Times New Roman", self) self.m_font2 = Button("Arial", self) grid = Grid(2, 2) self.m_startNode = self.createTextBox(1) self.m_startOffset = self.createTextBox(3) self.m_endNode = self.createTextBox(4) self.m_endOffset = self.createTextBox(5) self.m_select = Button("`>Select", self) self.m_select.setTitle("Select the texts/offsets in the boxes above") self.m_cursor = Button("`>Cursor", self) self.m_cursor.setTitle( "Set cursor to text/offset of top 2 boxes above") grid.setWidget(0, 0, self.m_startNode) grid.setWidget(0, 1, self.m_startOffset) grid.setWidget(1, 0, self.m_endNode) grid.setWidget(1, 1, self.m_endOffset) self.m_deleteSel = Button("Delete", self) self.m_reset = Button("Reset", self) buts.add(self.m_getCurr) buts.add(self.m_setHtml) buts.add(self.m_toSCursor) buts.add(self.m_toECursor) buts.add(self.m_font1) buts.add(self.m_font2) buts.add(self.m_surround1) buts.add(self.m_surround2) buts.add(grid) buts.add(self.m_select) buts.add(self.m_cursor) buts.add(self.m_deleteSel) buts.add(self.m_reset) dlp.add(buts, DockPanel.WEST) textPanels = DockPanel() self.m_html = TextArea() self.m_html.setSize("100%", "100%") self.m_sel = TextArea() self.m_sel.setSize("100%", "100%") textPanels.add(self.m_sel, DockPanel.EAST) textPanels.add(self.m_html, DockPanel.WEST) dlp.add(textPanels, DockPanel.SOUTH) dlp.add(self.m_tb, DockPanel.NORTH) dlp.add(self.m_rte, DockPanel.CENTER) rp = RootPanel.get() rp.add(dlp) DeferredCommand.add(getattr(self, "set_html_focus")) self.reset()