Python wtforms.widgets 模块,HTMLString() 实例源码

我们从Python开源项目中,提取了以下32个代码示例,用于说明如何使用wtforms.widgets.HTMLString()

项目:league    作者:massgo    | 项目源码 | 文件源码
def __call__(self, field, **kwargs):
        """Render table to HTML."""
        columns = kwargs.pop('columns', field.columns)
        rows = kwargs.pop('rows', field.rows)

        html = []
        html.append('<div class="table-responsive"><table class="table '
                    'table-striped"><thead><tr><th />')
        for column in columns:
            html.append('<th>{}</th>'.format(column))
        html.append('</tr></thead><tbody>')

        for row in rows:
            html.append('<tr><td><input class="form-check-input" '
                        'type="checkbox" name="obj_id" value="{}" '
                        '/></td>'.format(row[0]))
            for value in row[1:]:
                html.append('<td>{}</td>'.format(value))
            html.append('</tr>')
        html.append('</tbody></table></div>')
        return HTMLString(''.join(html))
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
def __call__(self, field, **kwargs):
        show_input = True
        show_preview = True
        if 'only_input' in kwargs or 'only_preview' in kwargs:
            show_input = kwargs.pop('only_input', False)
            show_preview = kwargs.pop('only_preview', False)
        if not show_input and not show_preview:
            raise ValueError('One of show_input and show_preview must be true')
        html = ''
        if show_input:
            class_ = kwargs.pop('class', '').split() + \
                kwargs.pop('class_', '').split()
            class_ += ['flask-pagedown-input']
            html += pagedown_pre_html + super(PageDown, self).__call__(
                field, id='flask-pagedown-' + field.name,
                class_=' '.join(class_), **kwargs) + pagedown_post_html
        if show_preview:
            html += preview_html % {'field': field.name}
        return HTMLString(html)
项目:pillar    作者:armadillica    | 项目源码 | 文件源码
def __call__(self, field, **kwargs):
        html = []
        kwargs.setdefault('id', field.id)
        html.append('<div %s>' % html_params(**kwargs))
        hidden = ''
        for subfield in field:
            if subfield.type == 'HiddenField':
                hidden += text_type(subfield)
            else:
                html.append('<div><span>%s</span>%s%s</div>' % (
                    text_type(subfield.label), hidden, text_type(subfield)))
                hidden = ''
        html.append('</div>')
        if hidden:
            html.append(hidden)
        return HTMLString(''.join(html))
项目:Sci-Finder    作者:snverse    | 项目源码 | 文件源码
def __call__(self, text=None, **kwargs):
        if 'for_' in kwargs:
            kwargs['for'] = kwargs.pop('for_')
        else:
            kwargs.setdefault('for', self.field_id)

        attributes = widgets.html_params(**kwargs)
        return widgets.HTMLString('<label %s>%s</label>' % (attributes, text or self.text))
项目:Sci-Finder    作者:snverse    | 项目源码 | 文件源码
def __call__(self, text=None, **kwargs):
        if 'for_' in kwargs:
            kwargs['for'] = kwargs.pop('for_')
        else:
            kwargs.setdefault('for', self.field_id)

        attributes = widgets.html_params(**kwargs)
        return widgets.HTMLString('<label %s>%s</label>' % (attributes, text or self.text))
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def __call__(self, field, **kwargs):
        html = super(PageDown, self).__call__(field, id = 'flask-pagedown-' + field.name, class_ = 'flask-pagedown-input', **kwargs)
        return HTMLString(pagedown_pre_html + html + pagedown_post_html % field.name)
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def __call__(self, text=None, **kwargs):
        if 'for_' in kwargs:
            kwargs['for'] = kwargs.pop('for_')
        else:
            kwargs.setdefault('for', self.field_id)

        attributes = widgets.html_params(**kwargs)
        return widgets.HTMLString('<label %s>%s</label>' % (attributes, text or self.text))
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def __call__(self, field, **kwargs):
        html = super(PageDown, self).__call__(field, id = 'flask-pagedown-' + field.name, class_ = 'flask-pagedown-input', **kwargs)
        return HTMLString(pagedown_pre_html + html + pagedown_post_html % field.name)
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def __call__(self, text=None, **kwargs):
        if 'for_' in kwargs:
            kwargs['for'] = kwargs.pop('for_')
        else:
            kwargs.setdefault('for', self.field_id)

        attributes = widgets.html_params(**kwargs)
        return widgets.HTMLString('<label %s>%s</label>' % (attributes, text or self.text))
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
def __call__(self, text=None, **kwargs):
        if 'for_' in kwargs:
            kwargs['for'] = kwargs.pop('for_')
        else:
            kwargs.setdefault('for', self.field_id)

        attributes = widgets.html_params(**kwargs)
        return widgets.HTMLString('<label %s>%s</label>' % (attributes, text or self.text))
项目:crm    作者:Incubaid    | 项目源码 | 文件源码
def __call__(self, field, **kwargs):
        objpk = kwargs.get('pk', None)
        obj = kwargs.get('obj', None)
        kwargs.setdefault('id', field.id)
        if obj is not None:
            return HTMLString(obj.as_image)
        return ""
项目:pyetje    作者:rorlika    | 项目源码 | 文件源码
def __call__(self, text=None, **kwargs):
        if 'for_' in kwargs:
            kwargs['for'] = kwargs.pop('for_')
        else:
            kwargs.setdefault('for', self.field_id)

        attributes = widgets.html_params(**kwargs)
        return widgets.HTMLString('<label %s>%s</label>' % (attributes, text or self.text))
项目:tingsmen    作者:pasqu4le    | 项目源码 | 文件源码
def __call__(self, field, **kwargs):
            kwargs.setdefault('id', field.id)
            kwargs.setdefault('type', self.input_type)
            kwargs.setdefault('value', field.id)
            return HTMLString('<button %s>%s</button>' % (self.html_params(name=field.name, **kwargs),
                                                          field.label.text))

    # Represents a <button type="submit">, allowing checking if a submit button has been pressed.
项目:FileStoreGAE    作者:liantian-cn    | 项目源码 | 文件源码
def __call__(self, text=None, **kwargs):
        if 'for_' in kwargs:
            kwargs['for'] = kwargs.pop('for_')
        else:
            kwargs.setdefault('for', self.field_id)

        attributes = widgets.html_params(**kwargs)
        return widgets.HTMLString('<label %s>%s</label>' % (attributes, text or self.text))
项目:python-group-proj    作者:Sharcee    | 项目源码 | 文件源码
def __call__(self, text=None, **kwargs):
        if 'for_' in kwargs:
            kwargs['for'] = kwargs.pop('for_')
        else:
            kwargs.setdefault('for', self.field_id)

        attributes = widgets.html_params(**kwargs)
        return widgets.HTMLString('<label %s>%s</label>' % (attributes, text or self.text))
项目:Flask-NvRay-Blog    作者:rui7157    | 项目源码 | 文件源码
def __call__(self, text=None, **kwargs):
        if 'for_' in kwargs:
            kwargs['for'] = kwargs.pop('for_')
        else:
            kwargs.setdefault('for', self.field_id)

        attributes = widgets.html_params(**kwargs)
        return widgets.HTMLString('<label %s>%s</label>' % (attributes, text or self.text))
项目:Flask-NvRay-Blog    作者:rui7157    | 项目源码 | 文件源码
def __call__(self, text=None, **kwargs):
        if 'for_' in kwargs:
            kwargs['for'] = kwargs.pop('for_')
        else:
            kwargs.setdefault('for', self.field_id)

        attributes = widgets.html_params(**kwargs)
        return widgets.HTMLString('<label %s>%s</label>' % (attributes, text or self.text))
项目:NZ-ORCID-Hub    作者:Royal-Society-of-New-Zealand    | 项目源码 | 文件源码
def __call__(self, field, **kwargs):
        """Render widget."""
        kwargs.setdefault('id', field.id)
        html = ["<!-- data: %r -->" % (field.data, ), '<div %s>' % html_params(**kwargs)]
        html.extend(self.render_select("year", field))
        html.extend(self.render_select("month", field))
        html.extend(self.render_select("day", field))
        html.append("</div>")
        return HTMLString(''.join(html))
项目:jenkins-panel    作者:nikitinsm    | 项目源码 | 文件源码
def play_btn_formatter(self, context, model, name):
        btn = """
<a class="btn btn-primary pull-right" href="%s">
    <span class="fa fa-play glyphicon glyphicon-play"></span>
</a>""" % url_for('.run_job', pk=model.get('_id'))

        return HTMLString(btn)
项目:jenkins-panel    作者:nikitinsm    | 项目源码 | 文件源码
def run_job(self, pk):
        #TODO: ajax call
        job = self.coll.find_one({'_id': ObjectId(pk)})
        name = 'auto-' + job.get('name')
        client.build_job(name)
        info = client.get_job_info(name)
        flash(HTMLString(u'?????? "%s" ???????? <a href="%s" target="_blank">?????????</a>' % (name, info.get('url'))))
        return redirect(url_for('.index_view'))

    # TODO
项目:webapp    作者:superchilli    | 项目源码 | 文件源码
def __call__(self, field, **kwargs):
        html = super(PageDown, self).__call__(field, id = 'flask-pagedown-' + field.name, class_ = 'flask-pagedown-input', **kwargs)
        return HTMLString(pagedown_pre_html + html + pagedown_post_html % field.name)
项目:webapp    作者:superchilli    | 项目源码 | 文件源码
def __call__(self, text=None, **kwargs):
        if 'for_' in kwargs:
            kwargs['for'] = kwargs.pop('for_')
        else:
            kwargs.setdefault('for', self.field_id)

        attributes = widgets.html_params(**kwargs)
        return widgets.HTMLString('<label %s>%s</label>' % (attributes, text or self.text))
项目:Sudoku-Solver    作者:ayush1997    | 项目源码 | 文件源码
def __call__(self, text=None, **kwargs):
        if 'for_' in kwargs:
            kwargs['for'] = kwargs.pop('for_')
        else:
            kwargs.setdefault('for', self.field_id)

        attributes = widgets.html_params(**kwargs)
        return widgets.HTMLString('<label %s>%s</label>' % (attributes, text or self.text))
项目:gardenbot    作者:GoestaO    | 项目源码 | 文件源码
def __call__(self, text=None, **kwargs):
        if 'for_' in kwargs:
            kwargs['for'] = kwargs.pop('for_')
        else:
            kwargs.setdefault('for', self.field_id)

        attributes = widgets.html_params(**kwargs)
        return widgets.HTMLString('<label %s>%s</label>' % (attributes, text or self.text))
项目:flask-zhenai-mongo-echarts    作者:Fretice    | 项目源码 | 文件源码
def __call__(self, text=None, **kwargs):
        if 'for_' in kwargs:
            kwargs['for'] = kwargs.pop('for_')
        else:
            kwargs.setdefault('for', self.field_id)

        attributes = widgets.html_params(**kwargs)
        return widgets.HTMLString('<label %s>%s</label>' % (attributes, text or self.text))
项目:wtforms-lightmagic    作者:tornado-lightmagic    | 项目源码 | 文件源码
def __call__(self, field, **kwargs):

        if isinstance(field.data, (list, tuple)):
            def compare(val):
                return val in field.data
        else:
            def compare(val):
                return val == field.data

        kwargs.setdefault('id', field.id)
        if self.multiple:
            kwargs['multiple'] = True
        html = ['<select %s>' % html_params(name=field.name, **kwargs)]
        for item1, item2 in field.choices:
            if isinstance(item2, (list, tuple)):
                group_label = item1
                group_items = item2
                html.append('<optgroup %s>' % html_params(label=group_label))

                for inner_val, inner_label in group_items:
                    html.append(self.render_option(inner_val, inner_label, compare(inner_val)))
                html.append('</optgroup>')
            else:
                val = item1
                label = item2
                html.append(self.render_option(val, label, compare(val)))
        html.append('</select>')
        return HTMLString(''.join(html))
项目:micro-blog    作者:nickChenyx    | 项目源码 | 文件源码
def __call__(self, text=None, **kwargs):
        if 'for_' in kwargs:
            kwargs['for'] = kwargs.pop('for_')
        else:
            kwargs.setdefault('for', self.field_id)

        attributes = widgets.html_params(**kwargs)
        return widgets.HTMLString('<label %s>%s</label>' % (attributes, text or self.text))
项目:python-flask-security    作者:weinbergdavid    | 项目源码 | 文件源码
def __call__(self, text=None, **kwargs):
        if 'for_' in kwargs:
            kwargs['for'] = kwargs.pop('for_')
        else:
            kwargs.setdefault('for', self.field_id)

        attributes = widgets.html_params(**kwargs)
        return widgets.HTMLString('<label %s>%s</label>' % (attributes, text or self.text))
项目:Lixiang_zhaoxin    作者:hejaxian    | 项目源码 | 文件源码
def __call__(self, text=None, **kwargs):
        if 'for_' in kwargs:
            kwargs['for'] = kwargs.pop('for_')
        else:
            kwargs.setdefault('for', self.field_id)

        attributes = widgets.html_params(**kwargs)
        return widgets.HTMLString('<label %s>%s</label>' % (attributes, text or self.text))
项目:flask    作者:bobohope    | 项目源码 | 文件源码
def __call__(self, text=None, **kwargs):
        if 'for_' in kwargs:
            kwargs['for'] = kwargs.pop('for_')
        else:
            kwargs.setdefault('for', self.field_id)

        attributes = widgets.html_params(**kwargs)
        return widgets.HTMLString('<label %s>%s</label>' % (attributes, text or self.text))
项目:Hawkeye    作者:tozhengxq    | 项目源码 | 文件源码
def __call__(self, text=None, **kwargs):
        if 'for_' in kwargs:
            kwargs['for'] = kwargs.pop('for_')
        else:
            kwargs.setdefault('for', self.field_id)

        attributes = widgets.html_params(**kwargs)
        return widgets.HTMLString('<label %s>%s</label>' % (attributes, text or self.text))
项目:ngx_status    作者:YoYoAdorkable    | 项目源码 | 文件源码
def __call__(self, text=None, **kwargs):
        if 'for_' in kwargs:
            kwargs['for'] = kwargs.pop('for_')
        else:
            kwargs.setdefault('for', self.field_id)

        attributes = widgets.html_params(**kwargs)
        return widgets.HTMLString('<label %s>%s</label>' % (attributes, text or self.text))