def __init__(self, view): super().__init__(view) alert = self.add_child(Alert(view, _('An error occurred:'), 'danger')) alert.add_child(HTMLElement(view, 'hr')) alert.add_child(P(view, text=self.error_message)) a = alert.add_child(A(view, Url(self.error_source_href), description='Ok')) a.use_layout(ButtonLayout(style='primary'))
def __init__(self, view, css_id, show_indicators=True, interval=5000, pause='hover', wrap=True, keyboard=True, min_height=None): super(Carousel, self).__init__(view) self.carousel_panel = self.add_child(Div(view, css_id=css_id)) self.carousel_panel.append_class('carousel') self.carousel_panel.append_class('slide') self.carousel_panel.set_attribute('data-ride', 'carousel') self.carousel_panel.set_attribute('data-interval', six.text_type(interval)) pause_option = HTMLAttributeValueOption(pause or 'false', True, constrain_value_to=['hover', 'false']) self.carousel_panel.set_attribute('data-pause', pause_option.as_html_snippet()) self.carousel_panel.set_attribute('data-wrap', 'true' if wrap else 'false') self.carousel_panel.set_attribute('data-keyboard', 'true' if keyboard else 'false') if min_height: style = self.carousel_panel.add_child(HTMLElement(self.view, 'style', children_allowed=True)) css_id = self.carousel_panel.css_id style.add_child(TextNode(self.view, '#%s .carousel-item { min-height: %sem; }' % (css_id, min_height))) self.show_indicators = show_indicators if self.show_indicators: self.indicator_list = self.carousel_panel.add_child(self.create_indicator_list()) self.inner = self.carousel_panel.add_child(self.create_inner()) self.slides = [] self.add_control(previous=True) self.add_control()
def create_html_widget(self): return HTMLElement(self.view, 'input')