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


Python HTML.tr方法代码示例

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


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

示例1: display_user_list

# 需要导入模块: from webhelpers.html import HTML [as 别名]
# 或者: from webhelpers.html.HTML import tr [as 别名]
    def display_user_list(self, users, user):
        page = context.page
        request = context.request

        page.title = "User List"
        page.heading = "User List"
        page.add_block(NavBlock(force_pager=True))

        headers = []
        tds = [
            HTML.th("ID", width="16"),
            HTML.th("Av.", width="16", title="Avatar"),
            HTML.th("Username"),
            HTML.th("Join Date"),
            HTML.th("Ps.", width="16", title="Post Count"),
            HTML.th("Cs.", width="16", title="Comment Count"),
        ]
        if user.can("view_user_email"):
            tds.append(HTML.th("Email Address"))
        tds.append(HTML.th("Action"))
        headers.append(HTML.tr(*tds))

        tds = [
            "",  # HTML.input(name="page", type="hidden", value=request.args.get("page", "1")),
            tags.checkbox("avatar", checked=request.args.get("avatar")),
            tags.text("username", value=request.args.get("username")),
            "",
            tags.checkbox("posts", value="1", checked=request.args.get("posts")),
            tags.checkbox("comments", value="1", checked=request.args.get("comments")),
        ]
        if user.can("view_user_email"):
            tds.append(tags.text("email", value=request.args.get("email")))
        tds.append(tags.submit(name="submit", value="Search"))
        headers.append(HTML.tr(HTML.form(*[HTML.td(x) for x in tds], action="#", method="GET")))

        rows = []
        for duser in users:
            assert isinstance(duser, User)
            tds = [
                duser.id,
                duser.get_avatar_html(16),
                HTML.a(duser.username, href=make_link("user/"+duser.username)),
                str(duser.join_date)[:16],
                HTML.a(duser.post_count, href=make_link("post/list/uploaded_by_id=%d/1" % duser.id)),
                duser.comment_count,
            ]
            if user.can("view_user_email"):
                tds.append(duser.email)
            tds.append("")
            rows.append(HTML.tr(*[HTML.td(x) for x in tds]))

        page.add_block(Block(
            "Users",
            HTML.table(HTML.thead(*headers), HTML.tbody(*rows), class_="zebra")
        ))
开发者ID:shish,项目名称:shimpy,代码行数:57,代码来源:theme.py

示例2: display_login_block

# 需要导入模块: from webhelpers.html import HTML [as 别名]
# 或者: from webhelpers.html.HTML import tr [as 别名]
 def display_login_block(self):
     page = context.page
     table = HTML.table(
         HTML.tr(
             HTML.th("Username"),
             HTML.td(tags.text("username")),
         ),
         HTML.tr(
             HTML.th("Password"),
             HTML.td(tags.password("password")),
         ),
         HTML.tr(
             HTML.td(tags.submit(name="submit", value="Log In"), colspan=2)
         ),
         HTML.tr(
             HTML.td(HTML.small(HTML.a("Create Account", href=make_link("user_admin/create"))), colspan=2)
         ),
         # class_="form",
     )
     form = HTML.form(table, action=make_link("user_admin/login"), method="POST")
     page.add_block(Block("Login", form, self._user_block_location(), 90))
开发者ID:shish,项目名称:shimpy,代码行数:23,代码来源:theme.py

示例3: field

# 需要导入模块: from webhelpers.html import HTML [as 别名]
# 或者: from webhelpers.html.HTML import tr [as 别名]
def field(
    label='', 
    field='',
    required=False, 
    label_desc='', 
    field_desc='',
    help='',
    error='',
    field_pre='',
):
    """\
    Format a field with a label. 

    ``label``
        The label for the field

    ``field``
        The HTML representing the field, wrapped in ``literal()``

    ``required``
         Can be ``True`` or ``False`` depending on whether the label should be 
         formatted as required or not. By default required fields have an
         asterix.

    ``label_desc``
        Any text to appear underneath the label, level with ``field_desc`` 

    ``field_desc``
        Any text to appear underneath the field

    ``help``
        Any HTML or JavaScript to appear imediately to the right of the field 
        which could be used to implement a help system on the form

    ``error``
        Any text to appear immediately before the HTML field, usually used for
        an error message.

        It should be noted that when used with FormEncode's ``htmlfill`` module, 
        errors appear immediately before the HTML field in the position of the
        ``error`` argument. No ``<form:error>`` tags are added automatically by
        this helper because errors are placed there anyway and adding the tags
        would lead to this helper generating invalid HTML.

    ``field_pre``
        Any HTML to appear immediately above the field.

    TIP: For future compatibility, always specify arguments explicitly and do
    not rely on their order in the function definition.

    Here are some examples:

    >>> print field('email >', literal('<input type="text" name="test" value="" />'), required=True)
    <tr class="field">
    <td class="label" valign="top"><span class="required">*</span><label>email &gt;:</label></td>
    <td class="field" colspan="2" valign="top"><input type="text" name="test" value="" /></td>
    </tr>
    >>> print field(
    ...     label='email >',
    ...     field=literal('<input type="text" name="test" value="" />'), 
    ...     label_desc='including the @ sign',
    ...     field_desc='Please type your email carefully',
    ...     error='This is an error message <br />',
    ...     help = 'No help available for this field',
    ...     required=True,
    ... )
    ...
    <tr class="field">
    <td class="label" valign="top"><span class="required">*</span><label>email &gt;:</label></td>
    <td class="field" valign="top"><div class="error">This is an error message &lt;br /&gt;</div><input type="text" name="test" value="" /></td>
    <td class="help" valign="top">No help available for this field</td>
    </tr>
    <tr class="description">
    <td class="label_desc" valign="top"><span class="small">including the @ sign</span></td>
    <td class="field_desc" colspan="2" valign="top"><span class="small">Please type your email carefully</span></td>
    </tr>

    An appropriate stylesheet to use to style forms generated with field() when
    the table class is specified as "formbuild" would be::

        table.formbuild span.error-message, table.formbuild div.error, table.formbuild span.required {
            font-weight: bold;
            color: #f00;
        }
        table.formbuild span.small {
            font-size: 85%;
        }
        table.formbuild form {
            margin-top: 20px;
        }
        table.formbuild form table td {
            padding-bottom: 3px;
        }

    """
    if error:
        field = HTML.div(class_='error', c=error)+field
    if label:
        label = label + literal(':')
    if field_pre:
#.........这里部分代码省略.........
开发者ID:Administrator37157192201,项目名称:DevContest,代码行数:103,代码来源:helpers.py


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