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


Python html.IMG屬性代碼示例

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


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

示例1: represent

# 需要導入模塊: from gluon import html [as 別名]
# 或者: from gluon.html import IMG [as 別名]
def represent(cls, field, value, download_url=None):
        """
        How to represent the file:

        - with download url and if it is an image: <A href=...><IMG ...></A>
        - otherwise with download url: <A href=...>file</A>
        - otherwise: file

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

        inp = current.T(cls.GENERIC_DESCRIPTION)

        if download_url and value:
            if callable(download_url):
                url = download_url(value)
            else:
                url = download_url + '/' + value
            if cls.is_image(value):
                inp = IMG(_src=url, _width=cls.DEFAULT_WIDTH)
            inp = A(inp, _href=url)

        return inp 
開發者ID:HackPucBemobi,項目名稱:touch-pay-client,代碼行數:28,代碼來源:sqlhtml.py

示例2: test_IMG

# 需要導入模塊: from gluon import html [as 別名]
# 或者: from gluon.html import IMG [as 別名]
def test_IMG(self):
        self.assertEqual(IMG(_a='1', _b='2').xml(),
                         b'<img a="1" b="2" />') 
開發者ID:HackPucBemobi,項目名稱:touch-pay-client,代碼行數:5,代碼來源:test_html.py

示例3: widget

# 需要導入模塊: from gluon import html [as 別名]
# 或者: from gluon.html import IMG [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


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