當前位置: 首頁>>代碼示例>>Python>>正文


Python HTML.input方法代碼示例

本文整理匯總了Python中webhelpers2.html.HTML.input方法的典型用法代碼示例。如果您正苦於以下問題:Python HTML.input方法的具體用法?Python HTML.input怎麽用?Python HTML.input使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在webhelpers2.html.HTML的用法示例。


在下文中一共展示了HTML.input方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: radio

# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import input [as 別名]
def radio(name, value, checked=False, label=None, **attrs):
    """Create a radio button.

    Arguments:
    ``name`` -- the field's name.

    ``value`` -- the value returned to the application if the button is
    pressed.

    ``checked`` -- true if the button should be initially pressed.

    ``label`` -- a text label to display to the right of the button.
    
    The id of the radio button will be set to the name + '_' + value to 
    ensure its uniqueness.  An ``id`` keyword arg overrides this.  (Note
    that this behavior is unique to the ``radio()`` helper.)
    
    To arrange multiple radio buttons in a group, see
    webhelpers2.containers.distribute().
    """
    _set_input_attrs(attrs, "radio", name, value)
    if checked:
        attrs["checked"] = "checked"
    if not "id" in attrs:
        attrs["id"] = '%s_%s' % (name, _make_safe_id_component(value))
    widget = HTML.input(**attrs)
    if label:
        widget = HTML.label(widget, label)
    return widget
開發者ID:aodag,項目名稱:WebHelpers2,代碼行數:31,代碼來源:tags.py

示例2: password

# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import input [as 別名]
def password(name, value=None, id=NotGiven, **attrs):
    """Create a password field.
    
    Takes the same options as ``text()``.
    
    """
    _set_input_attrs(attrs, "password", name, value)
    _set_id_attr(attrs, id, name)
    return HTML.input(**attrs)
開發者ID:aodag,項目名稱:WebHelpers2,代碼行數:11,代碼來源:tags.py

示例3: filtering_col_inputs2

# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import input [as 別名]
    def filtering_col_inputs2(self, col):
        filter = col.filter
        field_name = 'v2({0})'.format(col.key)
        field_name = self.grid.prefix_qs_arg_key(field_name)

        # field will get modified by JS
        inputs = ''
        if 'input2' in filter.input_types:
            ident = '{0}_input2'.format(col.key)
            inputs += _HTML.input(name=field_name, type='text', value=filter.value2_set_with,
                                  id=ident)
        return inputs
開發者ID:level12,項目名稱:webgrid,代碼行數:14,代碼來源:renderers.py

示例4: file

# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import input [as 別名]
def file(name, value=None, id=NotGiven, **attrs):
    """Create a file upload field.
    
    If you are using file uploads then you will also need to set the 
    multipart option for the form.

    Example::

        >>> file('myfile')
        literal(u'<input id="myfile" name="myfile" type="file" />')
    
    """
    _set_input_attrs(attrs, "file", name, value)
    _set_id_attr(attrs, id, name)
    return HTML.input(**attrs)
開發者ID:aodag,項目名稱:WebHelpers2,代碼行數:17,代碼來源:tags.py

示例5: filtering_col_inputs1

# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import input [as 別名]
    def filtering_col_inputs1(self, col):
        filter = col.filter
        field_name = 'v1({0})'.format(col.key)
        field_name = self.grid.prefix_qs_arg_key(field_name)

        inputs = ''
        if 'input' in filter.input_types:
            ident = '{0}_input1'.format(col.key)
            inputs += _HTML.input(name=field_name, type='text', value=filter.value1_set_with,
                                  id=ident)
        if 'select' in filter.input_types:
            ident = '{0}_select1'.format(col.key)
            current_selected = tolist(filter.value1) or []
            multiple = None
            if len(current_selected) > 1:
                multiple = 'multiple'
            inputs += tags.select(field_name, current_selected,
                                  self.filtering_filter_options(filter), multiple=multiple)
            inputs += self.filtering_toggle_image()
        return inputs
開發者ID:level12,項目名稱:webgrid,代碼行數:22,代碼來源:renderers.py

示例6: text

# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import input [as 別名]
def text(name, value=None, id=NotGiven, type="text", **attrs):
    """Create a standard text field.
    
    ``value`` is a string, the content of the text field.

    ``id`` is the HTML ID attribute, and should be passed as a keyword
    argument.  By default the ID is the same as the name filtered through
    ``_make_safe_id_component()``.  Pass None to suppress the
    ID attribute entirely.

    ``type`` is the input field type, normally "text". You can override it
    for HTML 5 input fields that don't have their own helper; e.g.,
    "search", "email", "date".

    
    Options:
    
    * ``disabled`` - If set to True, the user will not be able to use
        this input.
    * ``size`` - The number of visible characters that will fit in the
        input.
    * ``maxlength`` - The maximum number of characters that the browser
        will allow the user to enter.
    
    The remaining keyword args will be standard HTML attributes for the tag.

    Example, a text input field::

        >>> text("address")
        literal(u'<input id="address" name="address" type="text" />')

    HTML 5 example, a color picker:

        >>> text("color", type="color")
        literal(u'<input id="color" name="color" type="color" />')
    
    """
    _set_input_attrs(attrs, type, name, value)
    _set_id_attr(attrs, id, name)
    convert_boolean_attrs(attrs, ["disabled"])
    return HTML.input(**attrs)
開發者ID:aodag,項目名稱:WebHelpers2,代碼行數:43,代碼來源:tags.py

示例7: checkbox

# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import input [as 別名]
def checkbox(name, value="1", checked=False, label=None, id=NotGiven, **attrs):
    """Create a check box.

    Arguments:
    ``name`` -- the widget's name.

    ``value`` -- the value to return to the application if the box is checked.

    ``checked`` -- true if the box should be initially checked.

    ``label`` -- a text label to display to the right of the box.

    ``id`` is the HTML ID attribute, and should be passed as a keyword
    argument.  By default the ID is the same as the name filtered through
    ``_make_safe_id_component()``.  Pass None to suppress the
    ID attribute entirely.

    The following HTML attributes may be set by keyword argument:

    * ``disabled`` - If true, checkbox will be grayed out.

    * ``readonly`` - If true, the user will not be able to modify the checkbox.

    To arrange multiple checkboxes in a group, see
    webhelpers2.containers.distribute().

    Example::
    
        >>> checkbox("hi")
        literal(u'<input id="hi" name="hi" type="checkbox" value="1" />')
    """
    _set_input_attrs(attrs, "checkbox", name, value)
    _set_id_attr(attrs, id, name)
    if checked:
        attrs["checked"] = "checked"
    convert_boolean_attrs(attrs, ["disabled", "readonly"])
    widget = HTML.input(**attrs)
    if label:
        widget = HTML.label(widget, label)
    return widget
開發者ID:aodag,項目名稱:WebHelpers2,代碼行數:42,代碼來源:tags.py

示例8: button_to

# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import input [as 別名]
def button_to(name, url='', **html_attrs):
    """Generate a form containing a sole button that submits to
    ``url``. 
    
    Use this method instead of ``link_to`` for actions that do not have
    the safe HTTP GET semantics implied by using a hypertext link.
    
    The parameters are the same as for ``link_to``.  Any 
    ``html_attrs`` that you pass will be applied to the inner
    ``input`` element. In particular, pass
    
        disabled = True/False
    
    as part of ``html_attrs`` to control whether the button is
    disabled.  The generated form element is given the class
    'button-to', to which you can attach CSS styles for display
    purposes.
    
    The submit button itself will be displayed as an image if you 
    provide both ``type`` and ``src`` as followed:

         type='image', src='icon_delete.gif'

    The ``src`` path should be the exact URL desired.  A previous version of
    this helper added magical prefixes but this is no longer the case.

    Example 1::
    
        # inside of controller for "feeds"
        >> button_to("Edit", url(action='edit', id=3))
        <form method="post" action="/feeds/edit/3" class="button-to">
        <div><input value="Edit" type="submit" /></div>
        </form>
    
    Example 2::
    
        >> button_to("Destroy", url(action='destroy', id=3), 
        .. method='DELETE')
        <form method="POST" action="/feeds/destroy/3" 
         class="button-to">
        <div>
            <input type="hidden" name="_method" value="DELETE" />
            <input value="Destroy" type="submit" />
        </div>
        </form>

    Example 3::

        # Button as an image.
        >> button_to("Edit", url(action='edit', id=3), type='image', 
        .. src='icon_delete.gif')
        <form method="POST" action="/feeds/edit/3" class="button-to">
        <div><input alt="Edit" src="/images/icon_delete.gif"
         type="image" value="Edit" /></div>
        </form>
    
    .. note::
        This method generates HTML code that represents a form. Forms
        are "block" content, which means that you should not try to
        insert them into your HTML where only inline content is
        expected. For example, you can legally insert a form inside of
        a ``div`` or ``td`` element or in between ``p`` elements, but
        not in the middle of a run of text, nor can you place a form
        within another form.
        (Bottom line: Always validate your HTML before going public.)

    Changed in WebHelpers 1.2: Preserve case of "method" arg for XHTML
    compatibility. E.g., "POST" or "PUT" causes *method="POST"*; "post" or
    "put" causes *method="post"*.
    
    """
    if html_attrs:
        tags.convert_boolean_attrs(html_attrs, ['disabled'])
    
    method_tag = ''
    method = html_attrs.pop('method', '')
    if method.upper() in ['PUT', 'DELETE']:
        method_tag = HTML.input(
            type='hidden', id='_method', name_='_method', value=method)
  
    if method.upper() in ('GET', 'POST'):
        form_method = method
    elif method in ('put', 'delete'):
        # preserve lowercasing of verb
        form_method = 'post'
    else:
        form_method = 'POST'
    
    url, name = url, name or url
    
    submit_type = html_attrs.get('type')
    img_source = html_attrs.get('src')
    if submit_type == 'image' and img_source:
        html_attrs["value"] = name
        html_attrs.setdefault("alt", name)
    else:
        html_attrs["type"] = "submit"
        html_attrs["value"] = name
    
    return HTML.form(method=form_method, action=url, class_="button-to",
#.........這裏部分代碼省略.........
開發者ID:aodag,項目名稱:WebHelpers2,代碼行數:103,代碼來源:tools.py

示例9: submit

# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import input [as 別名]
def submit(name, value, id=NotGiven, **attrs):
    """Create a submit button with the text ``value`` as the caption."""
    _set_input_attrs(attrs, "submit", name, value)
    _set_id_attr(attrs, id, name)
    return HTML.input(**attrs)
開發者ID:aodag,項目名稱:WebHelpers2,代碼行數:7,代碼來源:tags.py

示例10: hidden

# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import input [as 別名]
def hidden(name, value=None, id=NotGiven, **attrs):
    """Create a hidden field.
    """
    _set_input_attrs(attrs, "hidden", name, value)
    _set_id_attr(attrs, id, name)
    return HTML.input(**attrs)
開發者ID:aodag,項目名稱:WebHelpers2,代碼行數:8,代碼來源:tags.py

示例11: paging_input

# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import input [as 別名]
 def paging_input(self):
     pp_qsk = self.grid.prefix_qs_arg_key('perpage')
     return _HTML.input(type='text', name=pp_qsk, value=self.grid.per_page)
開發者ID:level12,項目名稱:webgrid,代碼行數:5,代碼來源:renderers.py

示例12: filtering_session_key

# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import input [as 別名]
 def filtering_session_key(self):
     return _HTML.input(
         name='session_key',
         type='hidden',
         value=self.grid.session_key
     )
開發者ID:level12,項目名稱:webgrid,代碼行數:8,代碼來源:renderers.py


注:本文中的webhelpers2.html.HTML.input方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。