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


Python html.P属性代码示例

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


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

示例1: test_P

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

示例2: test_BEAUTIFY

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import P [as 别名]
def test_BEAUTIFY(self):
        #self.assertEqual(BEAUTIFY(['a', 'b', {'hello': 'world'}]).xml(),
        #                 '<div><table><tr><td><div>a</div></td></tr><tr><td><div>b</div></td></tr><tr><td><div><table><tr><td style="font-weight:bold;vertical-align:top;">hello</td><td style="vertical-align:top;">:</td><td><div>world</div></td></tr></table></div></td></tr></table></div>')
        # unicode
        self.assertEqual(BEAUTIFY([P(u'àéèûôç'), 'a', 'b', {'hello': 'world'}]).xml(),
                         b'<div><table><tr><td><div><p>\xc3\xa0\xc3\xa9\xc3\xa8\xc3\xbb\xc3\xb4\xc3\xa7</p></div></td></tr><tr><td><div>a</div></td></tr><tr><td><div>b</div></td></tr><tr><td><div><table><tr><td style="font-weight:bold;vertical-align:top;">hello</td><td style="vertical-align:top;">:</td><td><div>world</div></td></tr></table></div></td></tr></table></div>') 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:8,代码来源:test_html.py

示例3: formstyle_bootstrap3_stacked

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import P [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: formstyle_bootstrap3_stacked

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import P [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

示例5: formstyle_bootstrap3_stacked

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import P [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

示例6: formstyle_bootstrap3_inline_factory

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import P [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

示例7: test_DIV

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import P [as 别名]
def test_DIV(self):
        # Empty DIV()
        self.assertEqual(DIV().xml(), b'<div></div>')
        self.assertEqual(DIV('<>', _a='1', _b='2').xml(),
                         b'<div a="1" b="2">&lt;&gt;</div>')
        # attributes can be updated like in a dict
        div = DIV('<>', _a='1')
        div['_b'] = '2'
        self.assertEqual(div.xml(),
                         b'<div a="1" b="2">&lt;&gt;</div>')
        # also with a mapping
        div.update(_b=2, _c=3)
        self.assertEqual(div.xml(),
                         b'<div a="1" b="2" c="3">&lt;&gt;</div>')
        # length of the DIV is the number of components
        self.assertEqual(len(DIV('a', 'bc')), 2)
        # also if empty, DIV is True in a boolean evaluation
        self.assertTrue(True if DIV() else False)
        # parent and siblings
        a = DIV(SPAN('a'), DIV('b'))
        s = a.element('span')
        d = s.parent
        d['_class'] = 'abc'
        self.assertEqual(a.xml(), b'<div class="abc"><span>a</span><div>b</div></div>')
        self.assertEqual([el.xml() for el in s.siblings()], [b'<div>b</div>'])
        self.assertEqual(s.sibling().xml(), b'<div>b</div>')
        # siblings with wrong args
        self.assertEqual(s.siblings('a'), [])
        # siblings with good args
        self.assertEqual(s.siblings('div')[0].xml(), b'<div>b</div>')
        # Check for siblings with wrong kargs and value
        self.assertEqual(s.siblings(a='d'), [])
        # Check for siblings with good kargs and value
        # Can't figure this one out what is a right value here??
        # Commented for now...
        # self.assertEqual(s.siblings(div='<div>b</div>'), ???)
        # No other sibling should return None
        self.assertEqual(DIV(P('First element')).element('p').sibling(), None)
        # --------------------------------------------------------------------------------------------------------------
        # This use unicode to hit xmlescape() line :
        #     """
        #     elif isinstance(data, unicode):
        #         data = data.encode('utf8', 'xmlcharrefreplace')
        #     """
        self.assertEqual(DIV(u'Texte en français avec des caractères accentués...').xml(),
                         b'<div>Texte en fran\xc3\xa7ais avec des caract\xc3\xa8res accentu\xc3\xa9s...</div>')
        # --------------------------------------------------------------------------------------------------------------
        self.assertEqual(DIV('Test with an ID', _id='id-of-the-element').xml(),
                         b'<div id="id-of-the-element">Test with an ID</div>')
        self.assertEqual(DIV().element('p'), None)

        # Corner case for raise coverage of one line
        # I think such assert fail cause of python 2.6
        # Work under python 2.7
        # with self.assertRaises(SyntaxError) as cm:
        #     DIV(BR('<>')).xml()
        # self.assertEqual(cm.exception[0], '<br/> tags cannot have components')

        # test .get('attrib')
        self.assertEqual(DIV('<p>Test</p>', _class="class_test").get('_class'), 'class_test')
        self.assertEqual(DIV(b'a').xml(), b'<div>a</div>') 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:63,代码来源:test_html.py

示例8: formstyle_bootstrap3_inline_factory

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import P [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

示例9: formstyle_bootstrap3_stacked

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import P [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

示例10: formstyle_bootstrap3_inline_factory

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import P [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

示例11: formstyle_bootstrap3_inline_factory

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import P [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

示例12: formstyle_bootstrap3_inline_factory

# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import P [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'] == '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(DIV(label, _help, _class="checkbox"),
                                _class="%s %s" % (offset_class, col_class))
                    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, _class="form-control-static %s" % col_class)

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

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


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