本文整理汇总了Python中etgen.html.E.img方法的典型用法代码示例。如果您正苦于以下问题:Python E.img方法的具体用法?Python E.img怎么用?Python E.img使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类etgen.html.E
的用法示例。
在下文中一共展示了E.img方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: href_button
# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import img [as 别名]
def href_button(self, url, text, title=None, icon_name=None, **kw):
"""Returns an etree object of a ``<a href>`` tag to the given URL
`url`.
`url` is what goes into the `href` part. If `url` is `None`,
then we return just a ``<b>`` tag.
`text` is what goes between the ``<a>`` and the ``</a>``. This
can be either a string or a tuple (or list) of strings (or
etree elements).
"""
# logger.info('20121002 href_button %s', unicode(text))
if title:
# Remember that Python 2.6 doesn't like if title is a Promise
kw.update(title=str(title))
#~ return xghtml.E.a(text,href=url,title=title)
if not isinstance(text, (tuple, list)):
text = (text,)
text = forcetext(text)
if url is None:
return E.b(*text)
kw.update(href=url)
if icon_name is not None:
src = settings.SITE.build_static_url(
'images', 'mjames', icon_name + '.png')
img = E.img(src=src, alt=icon_name)
return E.a(img, **kw)
else:
return E.a(*text, **kw)
示例2: image
# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import img [as 别名]
def image(self, ar):
url = self.get_image_url(ar)
return E.a(E.img(src=url, width="100%"), href=url, target="_blank")