Ejemplo n.º 1
0
class Input(htmlgen.Element):
    type = htmlgen.html_attribute('type', default='text')
    name = htmlgen.html_attribute('name')
    value = htmlgen.html_attribute('value')

    def __init__(self, type, name=None, value=None):
        super().__init__("input")
        self.type = type
        if name is not None:
            self.name = name
        if value is not None:
            self.value = value
Ejemplo n.º 2
0
class Style(Element):
    def __init__(self, contents):
        super(Style, self).__init__('style')
        self.type_ = 'text/css'
        self.append_raw(contents)

    type_ = html_attribute('type')
Ejemplo n.º 3
0
class Abbreviation(Element):
    def __init__(self, *content, title=""):
        super().__init__("abbr")
        self.extend(content)
        self.title = title

    title = html_attribute('title')
Ejemplo n.º 4
0
class Link(Element):
    """An HTML inline link (<a>) element.

        >>> link = Link("http://www.example.com/", "caption")
        >>> link.append(", more")
        >>> link.url
        'http://www.example.com/'
        >>> str(link)
        '<a href="http://www.example.com/">caption, more</a>'

    By default links open in the same window. This can be influenced using
    the target property:

        >>> link = Link("/foo/bar")
        >>> link.target
        '_self'
        >>> link.set_blank_target()
        >>> link.target
        '_blank'
        >>> link.target = "my-window"
        >>> str(link)
        '<a href="/foo/bar" target="my-window"></a>'

    Please refer to the HeadLink class for <link> elements.

    """
    def __init__(self, url, *content):
        super(Link, self).__init__("a")
        self.url = url
        self.extend(content)

    url = html_attribute("href")
    target = html_attribute("target", "_self")
    title = html_attribute("title")

    def set_blank_target(self):
        self.target = "_blank"
Ejemplo n.º 5
0
    class MyForm(htmlgen.Element):
        action = htmlgen.html_attribute('action')

        def __init__(self):
            super().__init__("form")
            self.action = '/submit'
            self.set_attribute('method', 'post')

        def generate_children(self):
            for v in parameters:
                name = v.metadata.get('display_name', v.name)
                namediv = WrapperDiv(name, css_classes=['field-name'])
                input_elm = make_input_element(v)
                yield WrapperDiv(namediv,
                                 input_elm,
                                 css_classes=['form-field'])

            submit = Input('submit')
            submit.id = 'submit-button'
            submit.set_attribute('value', 'Run notebook')
            submit.add_css_classes('btn', 'btn-success')
            yield WrapperDiv(submit, id='submit-div')