• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python widgets.html_params函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中wtforms.widgets.html_params函数的典型用法代码示例。如果您正苦于以下问题:Python html_params函数的具体用法?Python html_params怎么用?Python html_params使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了html_params函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: select_multi_checkbox

def select_multi_checkbox(field, ul_class='', **kwargs):
    '''Custom multi-select widget for vendor documents needed

    Returns:
        SelectMulti checkbox widget with tooltip labels
    '''
    kwargs.setdefault('type', 'checkbox')
    field_id = kwargs.pop('id', field.id)
    html = [u'<div %s>' % widgets.html_params(id=field_id, class_=ul_class)]

    # if we don't have any field data, set it to an empty list
    # to avoid a rendering TypeError
    if field.data is None:
        field.data = []

    for value, label, _ in field.iter_choices():
        name, description, href = label
        choice_id = u'%s-%s' % (field_id, value)
        options = dict(kwargs, name=field.name, value=value, id=choice_id)
        if int(value) in field.data:
            options['checked'] = 'checked'
        html.append(u'<div class="checkbox">')
        html.append(u'<input %s /> ' % widgets.html_params(**options))
        html.append(u'<label for="%s">%s</label>' % (choice_id, build_label_tooltip(name, description)))
        html.append(u'</div>')
    html.append(u'</div>')
    return u''.join(html)
开发者ID:dobtco,项目名称:beacon,代码行数:27,代码来源:view_util.py


示例2: __call__

  def __call__(self, field, **kwargs):
    kwargs.setdefault('id', field.id)
    field_id = kwargs.pop('id')
    kwargs.setdefault('name', field.name)
    field_name = kwargs.pop('name')
    kwargs.pop('type', None)
    value = kwargs.pop('value', None)
    if value is None:
      value = field._value()
    if not value:
      value = ''

    date_fmt = kwargs.pop('format', None)
    if date_fmt is not None:
      date_fmt = date_fmt.replace("%", "")\
        .replace("d", "dd")\
        .replace("m", "mm")\
        .replace("Y", "yyyy")
    else:
      date_fmt = get_locale().date_formats['short'].pattern
      date_fmt = babel2datepicker(date_fmt)
      date_fmt = date_fmt.replace('M', 'm')  # force numerical months

    s = u'<div {}>\n'.format(html_params(
      **{'class': "input-group date",
         'data-provide': 'datepicker',
         'data-date': value,
         'data-date-format': date_fmt}))

    s += u'  <input size="13" type="text" class="form-control" {} />\n'.format(
        html_params(name=field_name, id=field_id, value=value))
    s += u'  <span class="input-group-addon"><i class="icon-calendar"></i></span>\n'
    s += u'</div>\n'
    return Markup(s)
开发者ID:mmariani,项目名称:abilian-core,代码行数:34,代码来源:widgets.py


示例3: __call__

    def __call__(self, field, **kwargs):

        if field.data:
            previous_markup = """
            <label><input {attr} /> {field.data.file_name}</label>
            """.format(
                field=field,
                attr=html_params(**{
                    'id': field.id + '-previous',
                    'class_': 'js-fileinput-previous',
                    'type': 'checkbox',
                    'name': field.name + '-previous',
                    'value': '1',
                    'checked': True,
                    'data-fileinput-new': '#{}-new'.format(field.id)
                }))

        else:
            previous_markup = ''

        upload_markup = '<input {attr} />'.format(
            attr=html_params(**{
                'id': field.id + '-new',
                'type': 'file',
                'name': field.name + '-new',
                'class_': 'file js-fileinput-new',
                'data-initial-caption': 'Upload new file...',
                'data-show-upload': 'false',
                'data-show-preview': 'false',
                'data-fileinput-previous': '#{}-previous'.format(field.id)
            }))

        markup = previous_markup + upload_markup

        return markup
开发者ID:davidmote,项目名称:occams_forms,代码行数:35,代码来源:widgets.py


示例4: __call__

 def __call__(self, field, **kwargs):
     kwargs.setdefault('id', field.id)
     html = ['<select %s>' % html_params(name=field.name, **kwargs)]
     for val, label, selected in field.iter_choices():
         html.append(self.render_option(val, label, selected))
     html.append('</select>')
     html.append('<input type=text style="display: none" {0} {1} >'
         .format(html_params(name=field.name+"_input"),
                 html_params(id=field.name+"_input")))
     return HTMLString(''.join(html))
开发者ID:peskk3am,项目名称:b2share,代码行数:10,代码来源:HTML5ModelConverter.py


示例5: __call__

 def __call__(self, field, **kwargs):
     kwargs.setdefault("id", field.id)
     name = "%s.png" % field.name
     url = kwargs.get("url", "%s/%s" % (kwargs.get("path"), name))
     kwargs.setdefault("value", name)
     preview = HTMLString(u"<img %s />" % html_params(name="preview_"+name,
                                                      src=url))
     inputButton = HTMLString(u"<input %s  />" % html_params(name=field.name,
                                                             type=u"file",
                                                             **kwargs))
     return preview + inputButton
开发者ID:linuxsoftware,项目名称:world-of-beer,代码行数:11,代码来源:form.py


示例6: select_multi_checkbox

def select_multi_checkbox(field, ul_class='', ul_role='', **kwargs):
    kwargs.setdefault('type', 'checkbox')
    field_id = kwargs.pop('id', field.id)
    html = [u'<ul %s>' % html_params(id=field_id, class_=ul_class, role=ul_role)]
    for value, label, checked in field.iter_choices():
        choice_id = u'%s-%s' % (field_id, value)
        options = dict(kwargs, name=field.name, value=value, id=choice_id)
        if checked:
            options['checked'] = 'checked'
        html.append(u'<li><input %s /> ' % html_params(**options))
        html.append(u'<label for="%s">%s</label></li>' % (field_id, label))
    html.append(u'</ul>')
    return u''.join(html)
开发者ID:BaxterStockman,项目名称:cloudendar,代码行数:13,代码来源:forms.py


示例7: __call__

	def __call__(self, field, **kwargs):
		kwargs.setdefault('id', field.id)
		sub_kwargs = dict((k[4:],v) for k, v in kwargs.iteritems() if k.startswith(self.sub_startswith))
		kwargs = dict(filter(lambda x: not x[0].startswith(self.sub_startswith), kwargs.iteritems()))
		sub_html = '%s %s' % (self.sub_tag, html_params(**sub_kwargs))
		html = ['<%s %s>' % (self.html_tag, html_params(**kwargs))]
		for subfield in field:
			if self.prefix_label:
				html.append('<%s>%s %s</%s>' % (sub_html, subfield.label, subfield(), self.sub_tag))
			else:
				html.append('<%s>%s %s</%s>' % (sub_html, subfield(), subfield.label, self.sub_tag))
		html.append('</%s>' % self.html_tag)
		return HTMLString(''.join(html))
开发者ID:dotajin,项目名称:haoku-open,代码行数:13,代码来源:fields.py


示例8: render_subfield

    def render_subfield(self, subfield, **kwargs):
        html = []

        html.append("<div %s>" % html_params(class_='row'))
        # Field
        html.append(subfield())
        # Buttons
        html.append("<div %s>%s</div>" % (
            html_params(class_='col-xs-2'),
            self._sort_button() + self._remove_button()
        ))
        html.append("</div>")
        return ''.join(html)
开发者ID:mhellmic,项目名称:b2share,代码行数:13,代码来源:field_widgets.py


示例9: _add_field_widget

    def _add_field_widget(field, **kwargs):
        # spoof field_name in context of it's form
        field_name = "{}{}".format(
                field._prefix,
                field.short_name,
                )

        # render child fields (which should be wrapped w/ delete widgets)
        wrapper_id = "{}_wrapper".format(field_name)
        html_string = "<div {}>".format(html_params(id=wrapper_id))
        for subfield in field:
            html_string += subfield.widget(subfield, **kwargs)
        html_string += "</div>"

        # render a hidden template of the subfields 
        template_id = "{}_template".format(field_name)
        subform_tmpl_kwargs = {
                "id": template_id,
                "style": "display: none;",
                }
        html_string += "<div {}>".format(html_params(**subform_tmpl_kwargs))
        tmpl_prefix = "{0}-!{0}!".format(field_name)
        tmpl_field = field.unbound_field.bind(form=None, name=tmpl_prefix,
                prefix="", _meta=field.meta)
        tmpl_field.process(formdata=None, data={})
        tmpl_field.widget = deleteable_widget_wrapper(tmpl_field.widget)
        html_string += tmpl_field.widget(tmpl_field)
        html_string += "</div>"

        # create function that duplicates the template field
        field_name_regex = field_name.replace("-", "\-").replace("_", "\_")
        tmpl_regex = "\!+{0}+\!".format(field_name_regex)
        onclick = """
$("#{0}").append(
    $("#{1}").clone()  // Duplicate subform from template
    .show()  // Display the duplicated subform
    .html(  // rewrite HTML of new subform
        $('#{1}').html()
            .replace(new RegExp('{2}', 'g'),
                        (new Date).getTime().toString())
         )
    .attr('id', '')  // remove #subform_template from new subform
);""".format(wrapper_id, template_id, tmpl_regex)
        new_link_params = html_params(
                href="javascript:void(0)",
                onclick=onclick,
                )
        html_string += "<a {}>".format(new_link_params)
        html_string += "New"
        html_string += "</a>"
        return HTMLString(html_string)
开发者ID:MaxwellGBrown,项目名称:notebook,代码行数:51,代码来源:dynamic_field_list.py


示例10: __call__

 def __call__(self, field, **kwargs):
     kwargs.setdefault('id', field.id)
     field_id = kwargs.pop('id')
     kwargs.pop('type', None)
     value = kwargs.pop('value', None)
     if value is None:
         value = field._value()
     if not value:
         value = ' '
     date_value, time_value = value.split(' ', 1)
     return Markup(u'<input type="date" data-datepicker="datepicker" %s /> <input type="time" data-provide="timepicker" %s />' % (
         html_params(name=field.name, id=field_id + '-date', value=date_value, **kwargs),
         html_params(name=field.name, id=field_id + '-time', value=time_value, **kwargs)
         ))
开发者ID:pajju,项目名称:baseframe,代码行数:14,代码来源:forms.py


示例11: __call__

    def __call__(self, field, **kwargs):
        kwargs.setdefault("id", field.id)
        kwargs.setdefault("name", field.name)

        template = self.data_template if field.data else self.empty_template

        return HTMLString(
            template
            % {
                "text": html_params(type="text", value=field.data),
                "file": html_params(type="file", **kwargs),
                "marker": "_%s-delete" % field.name,
            }
        )
开发者ID:dpgaspar,项目名称:Flask-AppBuilder,代码行数:14,代码来源:upload.py


示例12: __call__

 def __call__(self, field, title='', **kwargs):
     kwargs.setdefault('id', field.id)
     if self.multiple:
         kwargs['multiple'] = 'multiple'
     html = [u'<select %s>' % html_params(name=field.name, **kwargs)]
     for val, label, selected in field.iter_choices():
         options = {'value': val}
         if selected:
             options['selected'] = u'selected'            
         if val is not None or val != '_None':
             options['title'] = url('/images/flags/%s.png' % str(val))
         html.append(u'<option %s>%s</option>' % (html_params(**options), escape(unicode(label))))
     html.append(u'</select>')
     return u''.join(html)        
开发者ID:rafal-kos,项目名称:pytis,代码行数:14,代码来源:validators.py


示例13: __call__

    def __call__(self, field, **kwargs):
        kwargs.setdefault('id', field.id)
        kwargs.setdefault('name', field.name)

        template = self.data_template if field.data else self.empty_template

        return HTMLString(template % {
            'text': html_params(type='text',
                                readonly='readonly',
                                value=field.data),
            'file': html_params(type='file',
                                **kwargs),
            'marker': '_%s-delete' % field.name
        })
开发者ID:cluo,项目名称:flask-admin,代码行数:14,代码来源:upload.py


示例14: __call__

    def __call__(self, field, **kwargs):
        kwargs.setdefault('id', field.id)
        sub_kwargs = dict((k[4:], v) for k, v in kwargs.iteritems() if k.startswith(self.sub_startswith))
        kwargs = dict(filter(lambda x: not x[0].startswith(self.sub_startswith), kwargs.iteritems()))
        sub_html = '%s %s' % (self.sub_tag, html_params(**sub_kwargs))
        left = ['<%s %s>' % (self.html_tag, html_params(id='%s-left' % field.id, class_='drag-left drag-part'))]
        right = ['<%s %s>' % (self.html_tag, html_params(id='%s-right' % field.id, class_='drag-right drag-part'))]
        for subfield in field:
            if subfield.checked:
                right.append('<%s>%s %s</%s>' % (sub_html, subfield.label, subfield(), self.sub_tag))
            else:
                left.append('<%s>%s %s</%s>' % (sub_html, subfield(), subfield.label, self.sub_tag))
        left.append('</%s>' % self.html_tag)
        right.append('</%s>' % self.html_tag)
        html = """<div class="drag-select">%s%s</div><script type="text/javascript">
            $(function() {

                function initClick(id) {
                    $('#' + id + '-left > div, #' + id + 'right > div').click(function () {})
                    $('#' + id + '-left > div').unbind('click').click(function () {
                        $(this).find('input[type="checkbox"]').get(0).checked = true;
                        $('#' + id + '-right').append($(this).clone())
                        $(this).remove()
                        initClick(id);
                    })
                    $('#' + id + '-right > div').unbind('click').click(function () {
                        $(this).find('input[type="checkbox"]').removeAttr('checked');
                        $('#' + id + '-left').append($(this).clone())
                        $(this).remove()
                        initClick(id);
                    })
                }

                function init(id) {
                    dragula([document.getElementById(id + '-left'), document.getElementById(id + '-right')])
                        .on('drop', function (el, target) {
                            if (target === document.getElementById(id + '-left')) {
                                $(el).find('input[type="checkbox"]').removeAttr('checked');
                            } else {
                                $(el).find('input[type="checkbox"]').get(0).checked = true;
                            }
                            initClick(id)
                        })
                    initClick(id);
                }
                init('%s')
            });
        </script>""" % (''.join(left), ''.join(right), field.id)
        return HTMLString(html)
开发者ID:PyFansLi,项目名称:chiki,代码行数:49,代码来源:widgets.py


示例15: render_option

    def render_option(cls, value, label, mixed):
        """
        Renders an option as the appropriate element,
        but wraps options into an ``optgroup`` tag
        if the ``label`` parameter is ``list`` or ``tuple``.

        The last option, mixed, differs from "selected" in that
        it is a tuple containing the coercion function, the
        current field data, and a flag indicating if the
        associated field supports multiple selections.
        """
        # See if this label is actually a group of items
        if isinstance(label, (list, tuple)):
            children = []

            # Iterate on options for the children.
            for item_value, item_label in label:
                item_html = cls.render_option(item_value, item_label, mixed)
                children.append(item_html)

            html = u"<optgroup %s>%s</optgroup>\n"
            data = (html_params(label=unicode(value)), u"".join(children))
        else:
            # Get our coercion function, the field data, and
            # a flag indicating if this is a multi-select from the tuple
            coerce_func, fielddata, multiple = mixed

            # See if we have field data - if not, don't bother
            # to see if something's selected.
            if fielddata is not None:
                # If this is a multi-select, look for the value
                # in the data array. Otherwise, look for an exact
                # value match.
                if multiple:
                    selected = coerce_func(value) in fielddata
                else:
                    selected = coerce_func(value) == fielddata
            else:
                selected = False

            options = {"value": value}

            if selected:
                options["selected"] = True

            html = u"<option %s>%s</option>\n"
            data = (html_params(**options), escape(unicode(label)))

        return HTMLString(html % data)
开发者ID:Athlon1600,项目名称:radremedy,代码行数:49,代码来源:groupedselectfield.py


示例16: __call__

    def __call__(self, field, **kwargs):
        kwargs.setdefault("id", field.id)
        kwargs.setdefault("name", field.name)

        args = {"file": html_params(type="file", **kwargs), "marker": "_%s-delete" % field.name}

        if field.data and isinstance(field.data, string_types):
            url = self.get_url(field)
            args["image"] = html_params(src=url)

            template = self.data_template
        else:
            template = self.empty_template

        return HTMLString(template % args)
开发者ID:loulouxiv,项目名称:flask-admin,代码行数:15,代码来源:upload.py


示例17: __call__

 def __call__(self, field, **kwargs):
     kwargs.setdefault('id', field.id)
     if self.multiple:
         kwargs['multiple'] = 'multiple'
     html = [u'<select %s>' % html_params(name=field.name, **kwargs)]
     for value, label, selected in field.iter_choices():
         if hasattr(label, '__iter__'):
             html.append(u'<optgroup %s>' % html_params(label=value))
             for v, l, s in label:
                 html.append(self.render_option(v, l, s))
             html.append(u'</optgroup>')
         else:
             html.append(self.render_option(value, label, selected))
     html.append(u'</select>')
     return HTMLString(u''.join(html))
开发者ID:eaudeweb,项目名称:art17-consultation,代码行数:15,代码来源:forms.py


示例18: render_option

    def render_option(cls, value, label, mixed):
        """
        Render option as HTML tag, but not forget to wrap options into
        ``optgroup`` tag if ``label`` var is ``list`` or ``tuple``.
        """
        if isinstance(label, (list, tuple)):
            return cls.render_optgroup(value, label, mixed)

        try:
            coerce_func, data = mixed
        except TypeError:
            selected = mixed
        else:
            if isinstance(data, list) or isinstance(data, tuple):
                selected = coerce_func(value) in data
            else:
                selected = coerce_func(value) == data

        options = {'value': value}

        if selected:
            options['selected'] = True

        html = u'<option %s>%s</option>'
        data = (html_params(**options), html_escape(six.text_type(label)))

        return HTMLString(html % data)
开发者ID:kvesteri,项目名称:wtforms-components,代码行数:27,代码来源:widgets.py


示例19: scopes_multi_checkbox

def scopes_multi_checkbox(field, **kwargs):
    """Render multi checkbox widget."""
    kwargs.setdefault('type', 'checkbox')
    field_id = kwargs.pop('id', field.id)

    html = ['<div class="row">']

    for value, label, checked in field.iter_choices():
        choice_id = u'%s-%s' % (field_id, value)

        options = dict(
            kwargs,
            name=field.name,
            value=value,
            id=choice_id,
            class_=' ',
        )

        if checked:
            options['checked'] = 'checked'

        html.append(u'<div class="col-md-3">')
        html.append(u'<label for="%s" class="checkbox-inline">' % field_id)
        html.append(u'<input %s /> ' % widgets.html_params(**options))
        html.append("%s <br/><small class='text-muted'>%s</small>" % (
            value, label.help_text)
        )
        html.append(u'</label></div>')
    html.append(u'</div>')

    return HTMLString(u''.join(html))
开发者ID:bruno314,项目名称:invenio-oauth2server,代码行数:31,代码来源:forms.py


示例20: render_option

    def render_option(cls, value, label, mixed):
        """
        Render option as HTML tag, but not forget to wrap options into
        ``optgroup`` tag if ``label`` var is ``list`` or ``tuple``.
        """
        if isinstance(label, (list, tuple)):
            children = []

            for item_value, item_label in label:
                item_html = cls.render_option(item_value, item_label, mixed)
                children.append(item_html)

            html = u'<optgroup label="%s">%s</optgroup>'
            data = (escape(unicode(value)), u'\n'.join(children))
        else:
            coerce_func, data = mixed
            if isinstance(data, list) or isinstance(data, tuple):
                selected = coerce_func(value) in data
            else:
                selected = coerce_func(value) == data

            options = {'value': value}

            if selected:
                options['selected'] = u'selected'

            html = u'<option %s>%s</option>'
            data = (html_params(**options), escape(unicode(label)))

        return HTMLString(html % data)
开发者ID:cluck,项目名称:wtforms-alchemy,代码行数:30,代码来源:fields.py



注:本文中的wtforms.widgets.html_params函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python core.html_params函数代码示例发布时间:2022-05-26
下一篇:
Python validators.url函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap