def buildLabels(self): grid = GridLayout() grid.setSpacing(True) grid.setWidth("100%") grid.setColumns(6) for prop in CssProperty.values(): l = Label("-") l.setSizeUndefined() l.setCaption(str(prop)) self._props[prop] = l grid.addComponent(l) return grid
def buildLabels(self): grid = GridLayout() grid.setSpacing(True) grid.setWidth('100%') grid.setColumns(6) for prop in CssProperty.values(): l = Label('-') l.setSizeUndefined() l.setCaption(str(prop)) self._props[prop] = l grid.addComponent(l) return grid
def _create_label(self, item, ui, desc, suffix = ':'): """Creates an item label. """ label = item.get_label(ui) if (label == '') or (label[-1:] in '?=:;,.<>/\\"\'-+#|'): suffix = '' control = Label(label + suffix) control.setSizeUndefined() if item.emphasized: self._add_emphasis(control) # FIXME: Decide what to do about the help. control.help = item.get_help(ui) return control
def setPath(self, path): # could be optimized: always builds path from scratch home self._layout.removeAllComponents() link = ActiveLink('Home', ExternalResource('#')) link.addListener(self, ILinkActivatedListener) self._layout.addComponent(link) if path is not None and not ('' == path): parts = path.split('/') link = None for part in parts: separator = Label("»", Label.CONTENT_XHTML); separator.setSizeUndefined() self._layout.addComponent(separator) f = FeatureSet.FEATURES.getFeature(part) link = ActiveLink(f.getName(), ExternalResource('#' + f.getFragmentName())) link.setData(f) link.addListener(self, ILinkActivatedListener) self._layout.addComponent(link) if link is not None: link.setStyleName('bold')
def setPath(self, path): # could be optimized: always builds path from scratch home self._layout.removeAllComponents() link = ActiveLink('Home', ExternalResource('#')) link.addListener(self, ILinkActivatedListener) self._layout.addComponent(link) if path is not None and not ('' == path): parts = path.split('/') link = None for part in parts: separator = Label("»", Label.CONTENT_XHTML) separator.setSizeUndefined() self._layout.addComponent(separator) f = FeatureSet.FEATURES.getFeature(part) link = ActiveLink(f.getName(), ExternalResource('#' + f.getFragmentName())) link.setData(f) link.addListener(self, ILinkActivatedListener) self._layout.addComponent(link) if link is not None: link.setStyleName('bold')
def __init__(self): super(SliderVerticalExample, self).__init__() self.setSpacing(True) value = Label('0') value.setSizeUndefined() slider = Slider('Select a value between 0 and 100') slider.setOrientation(Slider.ORIENTATION_VERTICAL) slider.setHeight('200px') slider.setMin(0) slider.setMax(100) slider.setImmediate(True) slider.addListener(SliderListener(value), IValueChangeListener) self.addComponent(slider) self.addComponent(value) self.setComponentAlignment(slider, Alignment.TOP_CENTER) self.setComponentAlignment(value, Alignment.TOP_CENTER)
def __init__(self): super(CssLayoutsExample, self).__init__() self.setMargin(True) # Note, that this code example may not be self explanatory without # checking out the related CSS file in the sampler theme. panel = Panel('Panel') panel.setStyleName('floatedpanel') panel.setWidth('30%') panel.setHeight('370px') panel.addComponent( Label('This panel is 30% wide ' + 'and 370px high (defined on the server side) ' + 'and floated right (with custom css). ' + 'Try resizing the browser window to see ' + 'how the black boxes (floated left) ' + 'behave. Every third of them has colored text ' + 'to demonstrate the dynamic css injection.')) bottomCenter = Label( 'I\'m a 3 inches wide footer at the bottom of the layout') bottomCenter.setSizeUndefined() # disable 100% default width bottomCenter.setStyleName('footer') cssLayout = MyCssLayout() cssLayout.setWidth('100%') cssLayout.addComponent(panel) for _ in range(15): # add black labels that float left cssLayout.addComponent(Brick()) cssLayout.addComponent(bottomCenter) self.addComponent(cssLayout)
def __init__(self): super(CssLayoutsExample, self).__init__() self.setMargin(True) # Note, that this code example may not be self explanatory without # checking out the related CSS file in the sampler theme. panel = Panel('Panel') panel.setStyleName('floatedpanel') panel.setWidth('30%') panel.setHeight('370px') panel.addComponent(Label('This panel is 30% wide ' + 'and 370px high (defined on the server side) ' + 'and floated right (with custom css). ' + 'Try resizing the browser window to see ' + 'how the black boxes (floated left) ' + 'behave. Every third of them has colored text ' + 'to demonstrate the dynamic css injection.')) bottomCenter = Label( 'I\'m a 3 inches wide footer at the bottom of the layout') bottomCenter.setSizeUndefined() # disable 100% default width bottomCenter.setStyleName('footer') cssLayout = MyCssLayout() cssLayout.setWidth('100%') cssLayout.addComponent(panel) for _ in range(15): # add black labels that float left cssLayout.addComponent(Brick()) cssLayout.addComponent(bottomCenter) self.addComponent(cssLayout)
def setFeatureContainer(self, c): self._grid.removeAllComponents() features = c.getItemIds() rootSet = CssLayout() rootTitle = None highlightRow = CssLayout() highlightRow.setStyleName('highlight-row') sampleCount = 0 for f in features: if isinstance(f, FeatureSet): if c.isRoot(f): if rootTitle is not None: rootTitle.setValue(('<em>' + str(sampleCount) + ' samples</em>' + rootTitle.getValue())) sampleCount = 0 desc = f.getDescription() try: idx = desc.index(".") except ValueError: idx = -1 rootTitle = Label("<h2>" + f.getName() + "</h2><span>" + desc[:idx + 1] + "</span>", Label.CONTENT_XHTML) rootTitle.setSizeUndefined() if f.getRelatedFeatures() is not None: rootTitle.setValue('<em>' + len(f.getRelatedFeatures()) + ' samples</em>' + rootTitle.getValue()) rootSet = CssLayout() rootSet.setStyleName('root') rootTitle.setStyleName('root-section') self._grid.addComponent(rootTitle) self._grid.addComponent(rootSet) else: sampleCount += 1 resId = '75-' + f.getIconName() res = self._app.getSampleIcon(resId) if rootSet.getParent() is None: # This sample is directly inside a non root feature # set, we present these with higher priority if rootTitle is None: parent = self._app._allFeatures.getParent(f) rootTitle = Label("<h2>" + parent.getName() + "</h2>", Label.CONTENT_XHTML) rootTitle.setStyleName('root-section highlights-title') rootTitle.setSizeUndefined() self._grid.addComponent(rootTitle) if parent.getDescription() is not None: desc = Label(parent.getDescription(), Label.CONTENT_XHTML) desc.setStyleName('highlights-description') desc.setSizeUndefined() self._grid.addComponent(desc) # Two samples per row if sampleCount % 2 == 1: highlightRow = CssLayout() highlightRow.setStyleName('highlight-row') self._grid.addComponent(highlightRow) l = CssLayout() l.setStyleName('highlight') er = ExternalResource('#' + f.getFragmentName()) sample = ActiveLink(f.getName(), er) sample.setIcon(res) # if f.getSinceVersion().isNew(): # sample.addStyleName('new') l.addComponent(sample) if (f.getDescription() is not None and f.getDescription() != ''): d = f.getDescription() desc = Label(d[:d.index(".") + 1], Label.CONTENT_XHTML) desc.setSizeUndefined() l.addComponent(desc) highlightRow.addComponent(l) else: sample = ActiveLink(f.getName(), ExternalResource('#' + f.getFragmentName())) sample.setStyleName(BaseTheme.BUTTON_LINK) sample.addStyleName('screenshot') if (f.getDescription() is not None and f.getDescription() != ''): desc = f.getDescription() try: idx = desc.index('.') except ValueError: idx = -1 sample.setDescription(desc[:idx + 1]) # if f.getSinceVersion().isNew(): # sample.addStyleName('new') sample.setIcon(res) rootSet.addComponent(sample) if rootTitle is not None: rootTitle.setValue('<em>' + str(sampleCount) + ' samples</em>' + rootTitle.getValue())
def setFeatureContainer(self, c): self._grid.removeAllComponents() features = c.getItemIds() rootSet = CssLayout() rootTitle = None highlightRow = CssLayout() highlightRow.setStyleName('highlight-row') sampleCount = 0 for f in features: if isinstance(f, FeatureSet): if c.isRoot(f): if rootTitle is not None: rootTitle.setValue( ('<em>' + str(sampleCount) + ' samples</em>' + rootTitle.getValue())) sampleCount = 0 desc = f.getDescription() try: idx = desc.index(".") except ValueError: idx = -1 rootTitle = Label( "<h2>" + f.getName() + "</h2><span>" + desc[:idx + 1] + "</span>", Label.CONTENT_XHTML) rootTitle.setSizeUndefined() if f.getRelatedFeatures() is not None: rootTitle.setValue('<em>' + len(f.getRelatedFeatures()) + ' samples</em>' + rootTitle.getValue()) rootSet = CssLayout() rootSet.setStyleName('root') rootTitle.setStyleName('root-section') self._grid.addComponent(rootTitle) self._grid.addComponent(rootSet) else: sampleCount += 1 resId = '75-' + f.getIconName() res = self._app.getSampleIcon(resId) if rootSet.getParent() is None: # This sample is directly inside a non root feature # set, we present these with higher priority if rootTitle is None: parent = self._app._allFeatures.getParent(f) rootTitle = Label("<h2>" + parent.getName() + "</h2>", Label.CONTENT_XHTML) rootTitle.setStyleName('root-section highlights-title') rootTitle.setSizeUndefined() self._grid.addComponent(rootTitle) if parent.getDescription() is not None: desc = Label(parent.getDescription(), Label.CONTENT_XHTML) desc.setStyleName('highlights-description') desc.setSizeUndefined() self._grid.addComponent(desc) # Two samples per row if sampleCount % 2 == 1: highlightRow = CssLayout() highlightRow.setStyleName('highlight-row') self._grid.addComponent(highlightRow) l = CssLayout() l.setStyleName('highlight') er = ExternalResource('#' + f.getFragmentName()) sample = ActiveLink(f.getName(), er) sample.setIcon(res) # if f.getSinceVersion().isNew(): # sample.addStyleName('new') l.addComponent(sample) if (f.getDescription() is not None and f.getDescription() != ''): d = f.getDescription() desc = Label(d[:d.index(".") + 1], Label.CONTENT_XHTML) desc.setSizeUndefined() l.addComponent(desc) highlightRow.addComponent(l) else: sample = ActiveLink( f.getName(), ExternalResource('#' + f.getFragmentName())) sample.setStyleName(BaseTheme.BUTTON_LINK) sample.addStyleName('screenshot') if (f.getDescription() is not None and f.getDescription() != ''): desc = f.getDescription() try: idx = desc.index('.') except ValueError: idx = -1 sample.setDescription(desc[:idx + 1]) # if f.getSinceVersion().isNew(): # sample.addStyleName('new') sample.setIcon(res) rootSet.addComponent(sample) if rootTitle is not None: rootTitle.setValue('<em>' + str(sampleCount) + ' samples</em>' + rootTitle.getValue())