当前位置: 首页>>代码示例>>Python>>正文


Python html.SPAN属性代码示例

本文整理汇总了Python中gluon.html.SPAN属性的典型用法代码示例。如果您正苦于以下问题:Python html.SPAN属性的具体用法?Python html.SPAN怎么用?Python html.SPAN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在gluon.html的用法示例。


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

示例1: testJSON

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import SPAN [as 别名]
def testJSON(self):
        # the main and documented "way" is to use the json() function
        # it has a few corner-cases that make json() be somewhat
        # different from the standard buyt being compliant
        # it's just a matter of conventions

        # incompatible spacing, newer simplejson already account
        # for this but it's still better to remember
        weird = {'JSON': u"ro" + u'\u2028' + u'ck' + u'\u2029' + u's!'}
        rtn = json(weird)
        self.assertEqual(rtn, u'{"JSON": "ro\\u2028ck\\u2029s!"}')
        # date, datetime, time strictly as strings in isoformat, minus the T
        objs = [
            datetime.datetime(2014, 1, 1, 12, 15, 35),
            datetime.date(2014, 1, 1),
            datetime.time(12, 15, 35)
            ]
        iso_objs = [obj.isoformat()[:19].replace('T', ' ') for obj in objs]
        json_objs = [json(obj) for obj in objs]
        json_web2pyfied = [json(obj) for obj in iso_objs]
        self.assertEqual(json_objs, json_web2pyfied)
        # int or long int()ified
        # self.assertEqual(json(1), json(1))
        # decimal stringified
        obj = {'a': decimal.Decimal('4.312312312312')}
        self.assertEqual(json(obj), u'{"a": "4.312312312312"}')
        # lazyT translated
        T = translator('', 'en')
        lazy_translation = T('abc')
        self.assertEqual(json(lazy_translation), u'"abc"')
        # html helpers are xml()ed before too
        self.assertEqual(json(SPAN('abc')), u'"<span>abc</span>"')
        # unicode keys make a difference with loads_json
        base = {u'è': 1, 'b': 2}
        base_enc = json(base)
        base_load = loads_json(base_enc)
        self.assertTrue(base == base_load)
        # if unicode_keys is false, the standard behaviour is assumed
        base_load = loads_json(base_enc, unicode_keys=False)
        self.assertFalse(base == base_load) 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:42,代码来源:test_serializers.py

示例2: test_SPAN

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import SPAN [as 别名]
def test_SPAN(self):
        self.assertEqual(SPAN('<>', _a='1', _b='2').xml(),
                         b'<span a="1" b="2">&lt;&gt;</span>') 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:5,代码来源:test_html.py

示例3: formstyle_bootstrap3_stacked

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import SPAN [as 别名]
def formstyle_bootstrap3_stacked(form, fields):
    """ bootstrap 3 format form layout

    Note:
        Experimental!
    """
    parent = CAT()
    for id, label, controls, help in fields:
        # wrappers
        _help = SPAN(help, _class='help-block')
        # embed _help into _controls
        _controls = CAT(controls, _help)
        if isinstance(controls, INPUT):
            if controls['_type'] == 'submit':
                controls.add_class('btn btn-primary')
            if controls['_type'] == 'button':
                controls.add_class('btn btn-default')
            elif controls['_type'] == 'file':
                controls.add_class('input-file')
            elif controls['_type'] in ('text', 'password'):
                controls.add_class('form-control')
            elif controls['_type'] == 'checkbox':
                label['_for'] = None
                label.insert(0, controls)
                _controls = DIV(label, _help, _class="checkbox")
                label = ''
            elif isinstance(controls, (SELECT, TEXTAREA)):
                controls.add_class('form-control')

        elif isinstance(controls, SPAN):
            _controls = P(controls.components)

        elif isinstance(controls, UL):
            for e in controls.elements("input"):
                e.add_class('form-control')

        if isinstance(label, LABEL):
            label['_class'] = add_class(label.get('_class'),'control-label')

        parent.append(DIV(label, _controls, _class='form-group', _id=id))
    return parent 
开发者ID:lucadealfaro,项目名称:true_review_web2py,代码行数:43,代码来源:sqlhtml.py

示例4: testJSON

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import SPAN [as 别名]
def testJSON(self):
        # the main and documented "way" is to use the json() function
        # it has a few corner-cases that make json() be somewhat
        # different from the standard buyt being compliant
        # it's just a matter of conventions

        # incompatible spacing, newer simplejson already account
        # for this but it's still better to remember
        weird = {'JSON': u"ro" + u'\u2028' + u'ck' + u'\u2029' + u's!'}
        rtn = json(weird)
        self.assertEqual(rtn, u'{"JSON": "ro\\u2028ck\\u2029s!"}')
        # date, datetime, time strictly as strings in isoformat, minus the T
        objs = [
            datetime.datetime(2014, 1, 1, 12, 15, 35),
            datetime.date(2014, 1, 1),
            datetime.time(12, 15, 35)
            ]
        iso_objs = [obj.isoformat()[:19].replace('T', ' ') for obj in objs]
        json_objs = [json(obj) for obj in objs]
        json_web2pyfied = [json(obj) for obj in iso_objs]
        self.assertEqual(json_objs, json_web2pyfied)
        # int or long int()ified
        self.assertEqual(json(1), json(1L))
        # decimal stringified
        obj = {'a': decimal.Decimal('4.312312312312')}
        self.assertEqual(json(obj), u'{"a": "4.312312312312"}')
        # lazyT translated
        T = translator('', 'en')
        lazy_translation = T('abc')
        self.assertEqual(json(lazy_translation), u'"abc"')
        # html helpers are xml()ed before too
        self.assertEqual(json(SPAN('abc')), u'"<span>abc</span>"')
        # unicode keys make a difference with loads_json
        base = {u'è': 1, 'b': 2}
        base_enc = json(base)
        base_load = loads_json(base_enc)
        self.assertTrue(base == base_load)
        # if unicode_keys is false, the standard behaviour is assumed
        base_load = loads_json(base_enc, unicode_keys=False)
        self.assertFalse(base == base_load) 
开发者ID:lucadealfaro,项目名称:true_review_web2py,代码行数:42,代码来源:test_serializers.py

示例5: formstyle_bootstrap3_stacked

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import SPAN [as 别名]
def formstyle_bootstrap3_stacked(form, fields):
    """ bootstrap 3 format form layout

    Note:
        Experimental!
    """
    parent = CAT()
    for id, label, controls, help in fields:
        # wrappers
        _help = SPAN(help, _class='help-block')
        # embed _help into _controls
        _controls = CAT(controls, _help)
        if isinstance(controls, INPUT):
            if controls['_type'] == 'submit':
                controls.add_class('btn btn-primary')
            if controls['_type'] == 'button':
                controls.add_class('btn btn-default')
            elif controls['_type'] == 'file':
                controls.add_class('input-file')
            elif controls['_type'] == 'text':
                controls.add_class('form-control')
            elif controls['_type'] == 'password':
                controls.add_class('form-control')
            elif controls['_type'] == 'checkbox':
                label['_for'] = None
                label.insert(0, controls)
                _controls = DIV(label, _help, _class="checkbox")
                label = ''
            elif isinstance(controls, SELECT):
                controls.add_class('form-control')
            elif isinstance(controls, TEXTAREA):
                controls.add_class('form-control')

        elif isinstance(controls, SPAN):
             _controls = P(controls.components)

        if isinstance(label, LABEL):
            label['_class'] = 'control-label'

        parent.append(DIV(label, _controls, _class='form-group', _id=id))
    return parent 
开发者ID:StuffShare,项目名称:StuffShare,代码行数:43,代码来源:sqlhtml.py

示例6: widget

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import SPAN [as 别名]
def widget(cls, field, value, download_url=None, **attributes):
        """
        generates a INPUT file tag.

        Optionally provides an A link to the file, including a checkbox so
        the file can be deleted.

        All is wrapped in a DIV.

        see also: `FormWidget.widget`

        Args:
            field: the field
            value: the field value
            download_url: url for the file download (default = None)
        """

        default = dict(_type='file', )
        attr = cls._attributes(field, default, **attributes)

        inp = INPUT(**attr)

        if download_url and value:
            if callable(download_url):
                url = download_url(value)
            else:
                url = download_url + '/' + value
            (br, image) = ('', '')
            if UploadWidget.is_image(value):
                br = BR()
                image = IMG(_src=url, _width=cls.DEFAULT_WIDTH)

            requires = attr["requires"]
            if requires == [] or isinstance(requires, IS_EMPTY_OR):
                inp = DIV(inp,
                          SPAN('[',
                               A(current.T(
                                UploadWidget.GENERIC_DESCRIPTION), _href=url),
                               '|',
                               INPUT(_type='checkbox',
                                     _name=field.name + cls.ID_DELETE_SUFFIX,
                                     _id=field.name + cls.ID_DELETE_SUFFIX),
                               LABEL(current.T(cls.DELETE_FILE),
                                     _for=field.name + cls.ID_DELETE_SUFFIX,
                                     _style='display:inline'),
                               ']', _style='white-space:nowrap'),
                          br, image)
            else:
                inp = DIV(inp,
                          SPAN('[',
                               A(current.T(cls.GENERIC_DESCRIPTION), _href=url),
                               ']', _style='white-space:nowrap'),
                          br, image)
        return inp 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:56,代码来源:sqlhtml.py

示例7: formstyle_bootstrap

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import SPAN [as 别名]
def formstyle_bootstrap(form, fields):
    """ bootstrap 2.3.x format form layout """
    form.add_class('form-horizontal')
    parent = FIELDSET()
    for id, label, controls, help in fields:
        # wrappers
        _help = SPAN(help, _class='help-block')
        # embed _help into _controls
        _controls = DIV(controls, _help, _class='controls')
        # submit unflag by default
        _submit = False

        if isinstance(controls, INPUT):
            controls.add_class('span4')
            if controls['_type'] == 'submit':
                # flag submit button
                _submit = True
                controls['_class'] = 'btn btn-primary'
            if controls['_type'] == 'file':
                controls['_class'] = 'input-file'

        # For password fields, which are wrapped in a CAT object.
        if isinstance(controls, CAT) and isinstance(controls[0], INPUT):
            controls[0].add_class('span4')

        if isinstance(controls, SELECT):
            controls.add_class('span4')

        if isinstance(controls, TEXTAREA):
            controls.add_class('span4')

        if isinstance(label, LABEL):
            label['_class'] = add_class(label.get('_class'), 'control-label')

        if _submit:
            # submit button has unwrapped label and controls, different class
            parent.append(DIV(label, controls, _class='form-actions', _id=id))
            # unflag submit (possible side effect)
            _submit = False
        else:
            # unwrapped label
            parent.append(DIV(label, _controls, _class='control-group', _id=id))
    return parent 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:45,代码来源:sqlhtml.py

示例8: formstyle_bootstrap3_stacked

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import SPAN [as 别名]
def formstyle_bootstrap3_stacked(form, fields):
    """ bootstrap 3 format form layout

    Note:
        Experimental!
    """
    parent = CAT()
    for id, label, controls, help in fields:
        # wrappers
        _help = SPAN(help, _class='help-block')
        # embed _help into _controls
        _controls = CAT(controls, _help)
        if isinstance(controls, INPUT):
            if controls['_type'] == 'submit':
                controls.add_class('btn btn-primary')
            if controls['_type'] == 'button':
                controls.add_class('btn btn-default')
            elif controls['_type'] == 'file':
                controls.add_class('input-file')
            elif controls['_type'] in ('text', 'password'):
                controls.add_class('form-control')
            elif controls['_type'] == 'checkbox':
                label['_for'] = None
                label.insert(0, controls)
                label.insert(0, ' ')
                _controls = DIV(label, _help, _class="checkbox")
                label = ''
            elif isinstance(controls, (SELECT, TEXTAREA)):
                controls.add_class('form-control')

        elif isinstance(controls, SPAN):
            _controls = P(controls.components)

        elif isinstance(controls, UL):
            for e in controls.elements("input"):
                e.add_class('form-control')

        elif isinstance(controls, CAT) and isinstance(controls[0], INPUT):
            controls[0].add_class('form-control')

        if isinstance(label, LABEL):
            label['_class'] = add_class(label.get('_class'), 'control-label')

        parent.append(DIV(label, _controls, _class='form-group', _id=id))
    return parent 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:47,代码来源:sqlhtml.py

示例9: formstyle_bootstrap3_inline_factory

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import SPAN [as 别名]
def formstyle_bootstrap3_inline_factory(col_label_size=3):
    """ bootstrap 3 horizontal form layout

    Note:
        Experimental!
    """
    def _inner(form, fields):
        form.add_class('form-horizontal')
        label_col_class = "col-sm-%d" % col_label_size
        col_class = "col-sm-%d" % (12 - col_label_size)
        offset_class = "col-sm-offset-%d" % col_label_size
        parent = CAT()
        for id, label, controls, help in fields:
            # wrappers
            _help = SPAN(help, _class='help-block')
            # embed _help into _controls
            _controls = DIV(controls, _help, _class="%s" % (col_class))
            if isinstance(controls, INPUT):
                if controls['_type'] == 'submit':
                    controls.add_class('btn btn-primary')
                    _controls = DIV(controls, _class="%s %s" % (col_class, offset_class))
                if controls['_type'] == 'button':
                    controls.add_class('btn btn-default')
                elif controls['_type'] == 'file':
                    controls.add_class('input-file')
                elif controls['_type'] in ('text', 'password'):
                    controls.add_class('form-control')
                elif controls['_type'] == 'checkbox':
                    label['_for'] = None
                    label.insert(0, controls)
                    label.insert(1, ' ')
                    _controls = DIV(DIV(label, _help, _class="checkbox"),
                                    _class="%s %s" % (offset_class, col_class))
                    label = ''
                elif isinstance(controls, (SELECT, TEXTAREA)):
                    controls.add_class('form-control')

            elif isinstance(controls, SPAN):
                _controls = P(controls.components,
                              _class="form-control-static %s" % col_class)
            elif isinstance(controls, UL):
                for e in controls.elements("input"):
                    e.add_class('form-control')
            elif isinstance(controls, CAT) and isinstance(controls[0], INPUT):
                    controls[0].add_class('form-control')
            if isinstance(label, LABEL):
                label['_class'] = add_class(label.get('_class'), 'control-label %s' % label_col_class)

            parent.append(DIV(label, _controls, _class='form-group', _id=id))
        return parent
    return _inner 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:53,代码来源:sqlhtml.py

示例10: formstyle_bootstrap

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import SPAN [as 别名]
def formstyle_bootstrap(form, fields):
    """ bootstrap 2.3.x format form layout """
    form.add_class('form-horizontal')
    parent = FIELDSET()
    for id, label, controls, help in fields:
        # wrappers
        _help = SPAN(help, _class='help-block')
        # embed _help into _controls
        _controls = DIV(controls, _help, _class='controls')
        # submit unflag by default
        _submit = False

        if isinstance(controls, INPUT):
            controls.add_class('span4')
            if controls['_type'] == 'submit':
                # flag submit button
                _submit = True
                controls['_class'] = 'btn btn-primary'
            if controls['_type'] == 'file':
                controls['_class'] = 'input-file'

        # For password fields, which are wrapped in a CAT object.
        if isinstance(controls, CAT) and isinstance(controls[0], INPUT):
            controls[0].add_class('span4')

        if isinstance(controls, SELECT):
            controls.add_class('span4')

        if isinstance(controls, TEXTAREA):
            controls.add_class('span4')

        if isinstance(label, LABEL):
            label['_class'] = add_class(label.get('_class'),'control-label')

        if _submit:
            # submit button has unwrapped label and controls, different class
            parent.append(DIV(label, controls, _class='form-actions', _id=id))
            # unflag submit (possible side effect)
            _submit = False
        else:
            # unwrapped label
            parent.append(DIV(label, _controls, _class='control-group', _id=id))
    return parent 
开发者ID:lucadealfaro,项目名称:true_review_web2py,代码行数:45,代码来源:sqlhtml.py

示例11: formstyle_bootstrap3_inline_factory

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import SPAN [as 别名]
def formstyle_bootstrap3_inline_factory(col_label_size=3):
    """ bootstrap 3 horizontal form layout

    Note:
        Experimental!
    """
    def _inner(form, fields):
        form.add_class('form-horizontal')
        label_col_class = "col-sm-%d" % col_label_size
        col_class = "col-sm-%d" % (12 - col_label_size)
        offset_class = "col-sm-offset-%d" % col_label_size
        parent = CAT()
        for id, label, controls, help in fields:
            # wrappers
            _help = SPAN(help, _class='help-block')
            # embed _help into _controls
            _controls = DIV(controls, _help, _class=col_class)
            if isinstance(controls, INPUT):
                if controls['_type'] == 'submit':
                    controls.add_class('btn btn-primary')
                    _controls = DIV(controls, _class="%s %s" % (col_class, offset_class))
                if controls['_type'] == 'button':
                    controls.add_class('btn btn-default')
                elif controls['_type'] == 'file':
                    controls.add_class('input-file')
                elif controls['_type'] in ('text', 'password'):
                    controls.add_class('form-control')
                elif controls['_type'] == 'checkbox':
                    label['_for'] = None
                    label.insert(0, controls)
                    _controls = DIV(DIV(label, _help, _class="checkbox"),
                                    _class="%s %s" % (offset_class, col_class))
                    label = ''
                elif isinstance(controls, (SELECT, TEXTAREA)):
                    controls.add_class('form-control')

            elif isinstance(controls, SPAN):
                _controls = P(controls.components,
                              _class="form-control-static %s" % col_class)
            elif isinstance(controls, UL):
                for e in controls.elements("input"):
                    e.add_class('form-control')
            elif controls is None or isinstance(controls, basestring):
                _controls = P(controls, _class="form-control-static %s" % col_class)
            if isinstance(label, LABEL):
                label['_class'] = add_class(label.get('_class'),'control-label %s' % label_col_class)

            parent.append(DIV(label, _controls, _class='form-group', _id=id))
        return parent
    return _inner 
开发者ID:lucadealfaro,项目名称:true_review_web2py,代码行数:52,代码来源:sqlhtml.py

示例12: formstyle_bootstrap3_stacked

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import SPAN [as 别名]
def formstyle_bootstrap3_stacked(form, fields):
    """ bootstrap 3 format form layout

    Note:
        Experimental!
    """
    parent = CAT()
    for id, label, controls, help in fields:
        # wrappers
        _help = SPAN(help, _class='help-block')
        # embed _help into _controls
        _controls = CAT(controls, _help)
        if isinstance(controls, INPUT):
            if controls['_type'] == 'submit':
                controls.add_class('btn btn-primary')
            if controls['_type'] == 'button':
                controls.add_class('btn btn-default')
            elif controls['_type'] == 'file':
                controls.add_class('input-file')
            elif controls['_type'] in ('text', 'password'):
                controls.add_class('form-control')
            elif controls['_type'] == 'checkbox':
                label['_for'] = None
                label.insert(0, controls)
                label.insert(0, ' ')
                _controls = DIV(label, _help, _class="checkbox")
                label = ''
            elif isinstance(controls, (SELECT, TEXTAREA)):
                controls.add_class('form-control')

        elif isinstance(controls, SPAN):
            _controls = P(controls.components)

        elif isinstance(controls, UL):
            for e in controls.elements("input"):
                e.add_class('form-control')

        if isinstance(label, LABEL):
            label['_class'] = add_class(label.get('_class'),'control-label')

        parent.append(DIV(label, _controls, _class='form-group', _id=id))
    return parent 
开发者ID:TechMaz,项目名称:Problematica-public,代码行数:44,代码来源:sqlhtml.py

示例13: formstyle_bootstrap3_inline_factory

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import SPAN [as 别名]
def formstyle_bootstrap3_inline_factory(col_label_size=3):
    """ bootstrap 3 horizontal form layout

    Note:
        Experimental!
    """
    def _inner(form, fields):
        form.add_class('form-horizontal')
        label_col_class = "col-sm-%d" % col_label_size
        col_class = "col-sm-%d" % (12 - col_label_size)
        offset_class = "col-sm-offset-%d" % col_label_size
        parent = CAT()
        for id, label, controls, help in fields:
            # wrappers
            _help = SPAN(help, _class='help-block')
            # embed _help into _controls
            _controls = DIV(controls, _help, _class="%s" % (col_class))
            if isinstance(controls, INPUT):
                if controls['_type'] == 'submit':
                    controls.add_class('btn btn-primary')
                    _controls = DIV(controls, _class="%s %s" % (col_class, offset_class))
                if controls['_type'] == 'button':
                    controls.add_class('btn btn-default')
                elif controls['_type'] == 'file':
                    controls.add_class('input-file')
                elif controls['_type'] in ('text', 'password'):
                    controls.add_class('form-control')
                elif controls['_type'] == 'checkbox':
                    label['_for'] = None
                    label.insert(0, controls)
                    label.insert(1, ' ')
                    _controls = DIV(DIV(label, _help, _class="checkbox"),
                                    _class="%s %s" % (offset_class, col_class))
                    label = ''
                elif isinstance(controls, (SELECT, TEXTAREA)):
                    controls.add_class('form-control')

            elif isinstance(controls, SPAN):
                _controls = P(controls.components,
                              _class="form-control-static %s" % col_class)
            elif isinstance(controls, UL):
                for e in controls.elements("input"):
                    e.add_class('form-control')
            if isinstance(label, LABEL):
                label['_class'] = add_class(label.get('_class'),'control-label %s' % label_col_class)

            parent.append(DIV(label, _controls, _class='form-group', _id=id))
        return parent
    return _inner 
开发者ID:TechMaz,项目名称:Problematica-public,代码行数:51,代码来源:sqlhtml.py

示例14: formstyle_bootstrap3_inline_factory

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import SPAN [as 别名]
def formstyle_bootstrap3_inline_factory(col_label_size=3):
    """ bootstrap 3 horizontal form layout

    Note:
        Experimental!
    """
    def _inner(form, fields):
        form.add_class('form-horizontal')
        label_col_class = "col-sm-%d" % col_label_size
        col_class = "col-sm-%d" % (12 - col_label_size)
        offset_class = "col-sm-offset-%d" % col_label_size
        parent = CAT()
        for id, label, controls, help in fields:
            # wrappers
            _help = SPAN(help, _class='help-block')
            # embed _help into _controls
            _controls = DIV(controls, _help, _class="%s %s" % (offset_class, col_class))
            if isinstance(controls, INPUT):
                if controls['_type'] == 'submit':
                    controls.add_class('btn btn-primary')
                    _controls = DIV(controls, _class="%s %s" % (col_class, offset_class))
                if controls['_type'] == 'button':
                    controls.add_class('btn btn-default')
                elif controls['_type'] == 'file':
                    controls.add_class('input-file')
                elif controls['_type'] in ('text', 'password'):
                    controls.add_class('form-control')
                elif controls['_type'] == 'checkbox':
                    label['_for'] = None
                    label.insert(0, controls)
                    _controls = DIV(DIV(label, _help, _class="checkbox"),
                                    _class="%s %s" % (offset_class, col_class))
                    label = ''
                elif isinstance(controls, (SELECT, TEXTAREA)):
                    controls.add_class('form-control')

            elif isinstance(controls, SPAN):
                _controls = P(controls.components,
                              _class="form-control-static %s" % col_class)
            elif isinstance(controls, UL):
                for e in controls.elements("input"):
                    e.add_class('form-control')
            if isinstance(label, LABEL):
                label['_class'] = add_class(label.get('_class'),'control-label %s' % label_col_class)

            parent.append(DIV(label, _controls, _class='form-group', _id=id))
        return parent
    return _inner 
开发者ID:slugiot,项目名称:slugiot-client,代码行数:50,代码来源:sqlhtml.py

示例15: formstyle_bootstrap

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import SPAN [as 别名]
def formstyle_bootstrap(form, fields):
    """ bootstrap 2.3.x format form layout """
    form.add_class('form-horizontal')
    parent = FIELDSET()
    for id, label, controls, help in fields:
        # wrappers
        _help = SPAN(help, _class='help-block')
        # embed _help into _controls
        _controls = DIV(controls, _help, _class='controls')
        # submit unflag by default
        _submit = False

        if isinstance(controls, INPUT):
            controls.add_class('span4')
            if controls['_type'] == 'submit':
                # flag submit button
                _submit = True
                controls['_class'] = 'btn btn-primary'
            if controls['_type'] == 'file':
                controls['_class'] = 'input-file'

        # For password fields, which are wrapped in a CAT object.
        if isinstance(controls, CAT) and isinstance(controls[0], INPUT):
            controls[0].add_class('span4')

        if isinstance(controls, SELECT):
            controls.add_class('span4')

        if isinstance(controls, TEXTAREA):
            controls.add_class('span4')

        if isinstance(label, LABEL):
            label['_class'] = 'control-label'

        if _submit:
            # submit button has unwrapped label and controls, different class
            parent.append(DIV(label, controls, _class='form-actions', _id=id))
            # unflag submit (possible side effect)
            _submit = False
        else:
            # unwrapped label
            parent.append(DIV(label, _controls, _class='control-group', _id=id))
    return parent 
开发者ID:StuffShare,项目名称:StuffShare,代码行数:45,代码来源:sqlhtml.py


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