class LabelRichExample(VerticalLayout, IClickListener): def __init__(self): super(LabelRichExample, self).__init__() self.setSpacing(True) self._editor = RichTextArea() self._richText = Label('<h1>Rich text example</h1>' '<p>The <b>quick</b> brown fox jumps <sup>over</sup> ' 'the <b>lazy</b> dog.</p>' '<p>This text can be edited with the <i>Edit</i> -button</p>') self._richText.setContentMode(Label.CONTENT_XHTML) self.addComponent(self._richText) self._b = Button('Edit') self._b.addListener(self, IClickListener) self.addComponent(self._b) self._editor.setWidth('100%') def buttonClick(self, event): if self.getComponentIterator().next() == self._richText: self._editor.setValue(self._richText.getValue()) self.replaceComponent(self._richText, self._editor) self._b.setCaption('Apply') else: self._richText.setValue(self._editor.getValue()) self.replaceComponent(self._editor, self._richText) self._b.setCaption('Edit')
class LabelRichExample(VerticalLayout, IClickListener): def __init__(self): super(LabelRichExample, self).__init__() self.setSpacing(True) self._editor = RichTextArea() self._richText = Label( '<h1>Rich text example</h1>' '<p>The <b>quick</b> brown fox jumps <sup>over</sup> ' 'the <b>lazy</b> dog.</p>' '<p>This text can be edited with the <i>Edit</i> -button</p>') self._richText.setContentMode(Label.CONTENT_XHTML) self.addComponent(self._richText) self._b = Button('Edit') self._b.addListener(self, IClickListener) self.addComponent(self._b) self._editor.setWidth('100%') def buttonClick(self, event): if self.getComponentIterator().next() == self._richText: self._editor.setValue(self._richText.getValue()) self.replaceComponent(self._richText, self._editor) self._b.setCaption('Apply') else: self._richText.setValue(self._editor.getValue()) self.replaceComponent(self._editor, self._richText) self._b.setCaption('Edit')
def __init__(self): super(NotificationCustomExample, self).__init__() self.setSpacing(True) caption = TextField('Caption', 'Message sent') caption.setDescription(('Main info; a short caption-only ' 'notification is often most effective.')) caption.setWidth('200px') self.addComponent(caption) description = RichTextArea() description.setWidth('100%') description.setValue('<p>to <i>[email protected]</i></p>') description.setCaption('Description') description.setDescription(('Additional information; ' 'try to keep it short.')) self.addComponent(description) horiz = HorizontalLayout() horiz.setSpacing(True) self.addComponent(horiz) position = NativeSelect('Position') position.setNullSelectionAllowed(False) horiz.addComponent(position) self.initPositionItems(position) style = NativeSelect('Style') style.setNullSelectionAllowed(False) horiz.addComponent(style) self.initTypeItems(style) delay = Slider('Delay (msec), -1 means click to hide') delay.setDescription( ('Delay before fading<br/>Pull all the way to ' 'the left to get -1, which means forever (click to hide).')) delay.setWidth('100%') # 'description' will push width delay.setMin(Notification.DELAY_FOREVER) delay.setMax(10000) self.addComponent(delay) # TODO icon select l = ShowListener(self, caption, description, style, position, delay) show = Button('Show notification', l) self.addComponent(show) self.setComponentAlignment(show, Alignment.MIDDLE_RIGHT)
def __init__(self): super(NotificationCustomExample, self).__init__() self.setSpacing(True) caption = TextField('Caption', 'Message sent') caption.setDescription(('Main info; a short caption-only ' 'notification is often most effective.')) caption.setWidth('200px') self.addComponent(caption) description = RichTextArea() description.setWidth('100%') description.setValue('<p>to <i>[email protected]</i></p>') description.setCaption('Description') description.setDescription(('Additional information; ' 'try to keep it short.')) self.addComponent(description) horiz = HorizontalLayout() horiz.setSpacing(True) self.addComponent(horiz) position = NativeSelect('Position') position.setNullSelectionAllowed(False) horiz.addComponent(position) self.initPositionItems(position) style = NativeSelect('Style') style.setNullSelectionAllowed(False) horiz.addComponent(style) self.initTypeItems(style) delay = Slider('Delay (msec), -1 means click to hide') delay.setDescription(('Delay before fading<br/>Pull all the way to ' 'the left to get -1, which means forever (click to hide).')) delay.setWidth('100%') # 'description' will push width delay.setMin(Notification.DELAY_FOREVER) delay.setMax(10000) self.addComponent(delay) # TODO icon select l = ShowListener(self, caption, description, style, position, delay) show = Button('Show notification', l) self.addComponent(show) self.setComponentAlignment(show, Alignment.MIDDLE_RIGHT)
def __init__(self): super(TooltipsExample, self).__init__() self.setSpacing(True) # Plain tooltip (description) plain = Button("Mouse over for plain tooltip") plain.setStyleName(BaseTheme.BUTTON_LINK) # add the tooltip: plain.setDescription("A simple plaintext tooltip") self.addComponent(plain) # Richtext tooltip (description) rich = Button("Mouse over for richtext tooltip") rich.setStyleName(BaseTheme.BUTTON_LINK) # add the tooltip: rich.setDescription( ( '<h2><img src="../VAADIN/themes/sampler/' 'icons/comment_yellow.gif"/>A richtext tooltip</h2>' "<ul>" "<li>HTML formatting</li><li>Images<br/>" "</li><li>etc...</li></ul>" ) ) self.addComponent(rich) # Edit rte = RichTextArea() rte.setValue(("Click <b>" + self._editTxt + "</b> to edit this tooltip, then <b>" + self._applyTxt + "</b>")) rte.setVisible(False) # hide editor initially rte.setWidth("100%") self.addComponent(rte) aply = Button(self._editTxt, EditListener(self, rte)) aply.setDescription(rte.getValue()) self.addComponent(aply)
def __init__(self): super(TooltipsExample, self).__init__() self.setSpacing(True) # Plain tooltip (description) plain = Button('Mouse over for plain tooltip') plain.setStyleName(BaseTheme.BUTTON_LINK) # add the tooltip: plain.setDescription('A simple plaintext tooltip') self.addComponent(plain) # Richtext tooltip (description) rich = Button('Mouse over for richtext tooltip') rich.setStyleName(BaseTheme.BUTTON_LINK) # add the tooltip: rich.setDescription( ('<h2><img src=\"../VAADIN/themes/sampler/' 'icons/comment_yellow.gif\"/>A richtext tooltip</h2>' '<ul>' '<li>HTML formatting</li><li>Images<br/>' '</li><li>etc...</li></ul>')) self.addComponent(rich) # Edit rte = RichTextArea() rte.setValue( ('Click <b>' + self._editTxt + '</b> to edit this tooltip, then <b>' + self._applyTxt + '</b>')) rte.setVisible(False) # hide editor initially rte.setWidth('100%') self.addComponent(rte) aply = Button(self._editTxt, EditListener(self, rte)) aply.setDescription(rte.getValue()) self.addComponent(aply)