本文整理汇总了Python中pyasm.web.HtmlElement.img方法的典型用法代码示例。如果您正苦于以下问题:Python HtmlElement.img方法的具体用法?Python HtmlElement.img怎么用?Python HtmlElement.img使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.web.HtmlElement
的用法示例。
在下文中一共展示了HtmlElement.img方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_display
# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import img [as 别名]
def get_display(my):
dd_activator = DivWdg()
if my.style:
dd_activator.add_styles( my.style )
dd_activator.add_style( "width: %spx" % my.width )
dd_activator.add_class("SPT_DTS");
if my.nudge_menu_horiz != 0:
dd_activator.set_attr("spt_nudge_menu_horiz", my.nudge_menu_horiz)
if my.nudge_menu_vert != 0:
dd_activator.set_attr("spt_nudge_menu_vert", my.nudge_menu_vert)
# Generate button ...
#
table = Table()
table.add_row()
table.add_styles("width: 100%; padding: 0px; margin: 0px;")
td = table.add_cell()
td.add_looks("menu border curs_default")
td.add_styles( "padding: 0px; width: 100%; overflow: hidden; height: 12px; max-height: 12px;" )
title_div = DivWdg()
title_div.add_styles( "padding: 0px; margin-left: 4px; margin-top: 1px;" )
if my.icon_path:
img = HtmlElement.img()
img.set_attr("src", my.icon_path)
img.set_attr("title", my.title)
img.add_styles("padding: 0px; padding-bottom: 1px; margin: 0px; text-decoration: none;")
title_div.add(img)
title_div.add_looks("menu")
else:
title_div.add(my.title)
title_div.add_looks("menu fnt_text")
td.add( title_div )
td = table.add_cell()
# -- Example of setting only some of the borders with dotted style ...
# td.add_looks( "menu_btn_icon clear_borders border_bottom border_right dotted" )
td.add_looks( "menu_btn_icon border curs_default" )
td.add_styles( "padding: 0px; text-align: center; overflow: hidden; " \
"width: 15px; min-width: 15px;" \
"height: 12px; max-height: 12px;" )
arrow_img = HtmlElement.img("/context/icons/silk/_spt_bullet_arrow_down_dark_8x8.png")
arrow_img.add_styles( "border: 0px; margin-left: 1px; margin-top: 0px;" )
td.add( arrow_img )
dd_activator.add(table)
dd_activator.add( my.kwargs.get("smart_menu_set") )
dd_activator.add_class("SPT_SMENU_ACTIVATOR")
dd_activator.add_behavior( { 'type': 'click_up', 'activator_type' : 'smart_menu',
'cbjs_action': 'spt.smenu.show_on_dropdown_click_cbk( evt, bvr )' } )
return dd_activator
示例2: get_no_icon_wdg
# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import img [as 别名]
def get_no_icon_wdg(my, missing=False):
sobject = my.get_current_sobject()
if not sobject:
return ''
div = my.top
div.add_style("position: relative")
div.add_style("margin: 3px")
div.add_class("spt_thumb_top")
div.set_id( "thumb_%s" % sobject.get_search_key() )
icon_size = my.get_icon_size()
if icon_size:
div.add_style("%s: %s" % (my.aspect, icon_size) )
if missing:
img = HtmlElement.img(ThumbWdg.get_missing_image())
elif sobject.get_value("_is_collection", no_exception=True):
img = HtmlElement.img("/context/icons/mime-types/folder2.jpg")
else:
img = HtmlElement.img(ThumbWdg.get_no_image())
img.add_class("spt_image")
#from tactic.ui.table import SObjectDetailElementWdg
#detail = SObjectDetailElementWdg()
#detail.set_widget(img)
#detail.set_sobject(sobject)
#div.add(detail)
div.add(img)
div.add_class("hand")
if my.SQL_ERROR:
warning_div = DivWdg('<i>-- preprocess error --</i>')
warning_div.add_styles('position: absolute; z-index: 100; float: left; top: 0; left: 0; font-size: smaller;')
div.add_style('position: relative')
div.add(warning_div)
search_key = SearchKey.get_by_sobject(sobject)
code = sobject.get_code()
detail = my.get_option("detail")
if detail != 'false':
my.add_icon_behavior(div, sobject)
unit = None
if isinstance(icon_size, basestring):
icon_size, unit = my.split_icon_size(icon_size)
img.add_style("%s: 100%%" % my.aspect )
else:
img.add_style("%s: %s" % (my.aspect, my.get_icon_size()) )
img.add_style("min-%s: 15px" % my.aspect)
return div
示例3: get_display
# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import img [as 别名]
def get_display(my):
width = my.kwargs.get("width")
if not width:
width = "100%"
height = my.kwargs.get("height")
sobject = my.get_current_sobject()
div = DivWdg()
div.add_class("spt_thumb_top")
path = my.path
if path:
img = HtmlElement.img(src=path)
else:
search_type = sobject.get_search_type_obj()
path = my.get_path_from_sobject(search_type)
if path:
img = DivWdg()
img.add_style("opacity: 0.2")
img_inner = HtmlElement.img(src=path)
img.add(img_inner)
img_inner.add_style("width: %s" % width)
if path and path.startswith("/context"):
img.add_style("padding: 10px 15%")
img.add_style("width: 70%")
elif path:
img.add_style("width: %s" % width)
if height:
img.add_style("height: %s" % height)
img.add_style('margin-left','auto')
img.add_style('margin-right','auto')
if not path:
img = DivWdg()
img.add_class("spt_image")
div.add(img)
if height or my.show_name_hover in ["True","true",True]:
div.add_style("height: 100%")
if my.show_name_hover in ["True","true",True]:
name_hover = DivWdg()
name_hover.add_class("spt_name_hover")
name_hover.add(sobject.get('name'))
name_hover.add_attr('onmouseenter',"this.setStyle('opacity',1)")
name_hover.add_attr('onmouseleave',"this.setStyle('opacity',0)")
name_hover.add_styles('opacity: 0; font-size: 16px; color: rgb(217, 217, 217); top: 0px; \
transition: opacity 0s ease-out; -webkit-transition: opacity 0s ease-out; \
height: 100%; width: 100%; position: absolute; padding-top: 20px; \
text-align: center; background-color: rgba(0, 0, 0, 0.6);')
div.add(name_hover)
return div
示例4: get_no_icon_wdg
# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import img [as 别名]
def get_no_icon_wdg(my, missing=False):
sobject = my.get_current_sobject()
if not sobject:
return ''
div = my.top
div.add_style("position: relative")
div.add_style("margin: 3px")
div.add_class("spt_thumb_top")
div.set_id( "thumb_%s" % sobject.get_search_key() )
icon_size = my.get_icon_size()
if icon_size:
div.add_style("%s: %s" % (my.aspect, icon_size) )
if missing:
img = HtmlElement.img(ThumbWdg.get_missing_image())
else:
img = HtmlElement.img(ThumbWdg.get_no_image())
img.add_class("spt_image")
#from tactic.ui.table import SObjectDetailElementWdg
#detail = SObjectDetailElementWdg()
#detail.set_widget(img)
#detail.set_sobject(sobject)
#div.add(detail)
div.add(img)
div.add_class("hand")
if my.SQL_ERROR:
warning_div = DivWdg('<i>-- preprocess error --</i>')
warning_div.add_styles('position: absolute; z-index: 100; float: left; top: 0; left: 0; font-size: smaller;')
div.add_style('position: relative')
div.add(warning_div)
search_key = SearchKey.get_by_sobject(sobject)
code = sobject.get_code()
detail = my.get_option("detail")
if detail != 'false':
my.add_icon_behavior(div, sobject)
if type(icon_size) == types.StringType and icon_size.endswith("%"):
img.add_style("%s: 100%%" % my.aspect )
else:
img.add_style("%s: %spx" % (my.aspect, my.get_icon_size()) )
img.add_style("min-%s: 15px" % my.aspect)
return div
示例5: get_display
# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import img [as 别名]
def get_display(my):
top = my.top
height = my.kwargs.get("height")
if not height:
height = "100%"
width = my.kwargs.get("width")
if not width:
width = "100%"
border = my.kwargs.get("border")
src = my.kwargs.get("src")
img = HtmlElement.img(src)
img.add_style("width: %s" % width)
img.add_style("height: %s" % height)
top.add(img)
top.add_style("width: %s" % width)
top.add_style("height: %s" % height)
top.add_style("min-width: 20px")
top.add_style("min-height: 20px")
top.add_border()
return top
示例6: _add_icon
# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import img [as 别名]
def _add_icon(my):
# icon is optional
if not my.icon_path:
return
if not my.icon_path.startswith("/"):
# icon_path = "/context/icons/oo/%s" % my.icon_path
icon_path = "/context/icons/silk/%s" % my.icon_path
else:
icon_path = my.icon_path
icon = HtmlElement.img(icon_path)
icon.set_attr("title", my.name)
icon.add_styles(my.icon_styles)
if my.long:
img_id = my.generate_unique_id(my.name)
icon.add_class("icon_out")
my.add_event("onmouseover","wdg_opacity('%s','over');" % (img_id))
my.add_event("onmouseout","wdg_opacity('%s','out');" % (img_id))
icon.set_id(img_id)
else:
icon.add_class("simple_button")
if WebContainer.get_web().is_IE():
icon.add_style("vertical-align: top")
else:
icon.add_style("vertical-align: middle")
my.add(icon)
示例7: init
# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import img [as 别名]
def init(self):
if self.icon_path.startswith("BS") or self.icon_path.startswith("FA"):
icon_path = self.icon_path
elif not self.icon_path.startswith("/"):
# icon_path = "/context/icons/oo/%s" % self.icon_path
icon_path = "/context/icons/silk/%s" % self.icon_path
else:
icon_path = self.icon_path
if icon_path.startswith("BS_"):
icon = HtmlElement.span()
icon.add_class("glyphicon")
part = icon_path.replace("BS_", "")
part = part.lower()
part = part.replace("_","-")
if part == "save":
part = "floppy-disk"
icon.add_class("glyphicon-%s" % part)
if not self.size:
self.size = "16px"
icon.add_style("font-size: %s" % self.size)
if not self.opacity:
self.opacity = 0.6
elif icon_path.startswith("FA"):
icon = HtmlElement.i()
icon.add_class("fa")
part = icon_path.replace("FA_", "")
part = part.lower()
part = part.replace("_","-")
icon.add_class("fa-%s" % part)
if not self.size:
self.size = "16px"
icon.add_style("font-size: %s" % self.size)
if not self.opacity:
self.opacity = 0.6
else:
icon = HtmlElement.img(icon_path)
if self.opacity:
icon.add_style("opacity: %s" % self.opacity)
if self.text and self.text != "":
icon.set_attr("title", self.text)
if self.right_margin:
icon.add_style("margin-right: %s" % self.right_margin)
self.icon = icon
inline = self.kwargs.get("inline")
if inline in [False, 'false']:
self.add_style("float: left")
else:
self.add_style("display: inline")
示例8: get_display
# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import img [as 别名]
def get_display(my):
width = "100%"
height = "100%"
sobject = my.get_current_sobject()
div = DivWdg()
div.add_class("spt_thumb_top")
path = my.path
if path:
img = HtmlElement.img(src=path)
else:
search_type = sobject.get_search_type_obj()
path = my.get_path_from_sobject(search_type)
if path:
img = DivWdg()
img.add_style("opacity: 0.2")
img_inner = HtmlElement.img(src=path)
img.add(img_inner)
img_inner.add_style("width: %s" % width)
if path and path.startswith("/context"):
img.add_style("padding: 10px 15%")
img.add_style("width: 70%")
elif path:
img.add_style("width: %s" % width)
img.add_style("height: %s" % height)
img.add_style('margin-left','auto')
img.add_style('margin-right','auto')
if not path:
img = DivWdg()
img.add_class("spt_image")
div.add(img)
div.add_style("height: 100%")
return div
示例9: _get_loading_span
# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import img [as 别名]
def _get_loading_span(my):
span = SpanWdg()
span.add_style("display","none")
img = HtmlElement.img('/context/icons/common/loading.gif')
img.add_style("height","10px")
msg_span = SpanWdg('loading')
msg_span.set_class('small')
span.add(msg_span)
span.add(img)
span.set_id(my.img_span_name)
return span
示例10: get_display
# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import img [as 别名]
def get_display(my):
width = "100%"
div = DivWdg()
div.add_class("spt_thumb_top")
sobject = my.get_current_sobject()
path = my.get_path_from_sobject(sobject)
if path:
img = HtmlElement.img(src=path)
else:
search_type = sobject.get_search_type_obj()
path = my.get_path_from_sobject(search_type)
if path:
img = DivWdg()
img.add_style("opacity: 0.2")
img_inner = HtmlElement.img(src=path)
img.add(img_inner)
img_inner.add_style("width: %s" % width)
if path and path.startswith("/context"):
img.add_style("padding: 20px 0px")
img.add_border()
img.add_style("width: 100%")
if not path:
img = DivWdg()
img.add_class("spt_image")
div.add(img)
img.add_style("width: %s" % width)
div.add_style("height: 100%")
return div
示例11: init
# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import img [as 别名]
def init(my):
if not my.icon_path.startswith("/"):
# icon_path = "/context/icons/oo/%s" % my.icon_path
icon_path = "/context/icons/silk/%s" % my.icon_path
else:
icon_path = my.icon_path
icon = HtmlElement.img(icon_path)
if my.text and my.text != "":
icon.set_attr("title", my.text)
if my.right_margin:
icon.add_style("margin-right: %s" % my.right_margin)
my.icon = icon
inline = my.kwargs.get("inline")
if inline in [False, 'false']:
my.add_style("float: left")
else:
my.add_style("display: inline")
示例12: init
# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import img [as 别名]
def init(my):
if my.icon_path.startswith("BS"):
icon_path = my.icon_path
elif not my.icon_path.startswith("/"):
# icon_path = "/context/icons/oo/%s" % my.icon_path
icon_path = "/context/icons/silk/%s" % my.icon_path
else:
icon_path = my.icon_path
if icon_path.startswith("BS_"):
icon = HtmlElement.span()
icon.add_class("glyphicon")
part = icon_path.replace("BS_", "")
part = part.lower()
part = part.replace("_","-")
icon.add_class("glyphicon-%s" % part)
if not my.size:
my.size = "16px"
icon.add_style("font-size: %s" % my.size)
if not my.opacity:
my.opacity = 0.6
else:
icon = HtmlElement.img(icon_path)
if my.opacity:
icon.add_style("opacity: %s" % my.opacity)
if my.text and my.text != "":
icon.set_attr("title", my.text)
if my.right_margin:
icon.add_style("margin-right: %s" % my.right_margin)
my.icon = icon
inline = my.kwargs.get("inline")
if inline in [False, 'false']:
my.add_style("float: left")
else:
my.add_style("display: inline")
示例13: get_container
# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import img [as 别名]
def get_container(my, xml):
# handle the container
element_node = xml.get_node("config/tmp/element")
attrs = Xml.get_attributes(element_node)
element_name = attrs.get("name")
show_resize_scroll = attrs.get("show_resize_scroll")
if not show_resize_scroll:
show_resize_scroll = my.kwargs.get("show_resize_scroll")
if not show_resize_scroll:
show_resize_scroll = "false"
# look for attributes in the element tag for specifying a title action button to plug
# into the title bar of the custom section ...
#
title_action_icon = attrs.get("title_action_icon")
title_action_script = attrs.get("title_action_script")
title_action_label = attrs.get("title_action_label")
if title_action_script and not title_action_label:
title_action_label = '[action]'
# get the width and height for the element content ...
width = attrs.get("width")
height = attrs.get("height")
if width and height:
container = ContainerWdg( inner_width=width, inner_height=height, show_resize_scroll=show_resize_scroll )
else:
container = ContainerWdg(show_resize_scroll=show_resize_scroll)
# create the title
title = attrs.get("title")
if not title:
title = Common.get_display_title(element_name)
title_wdg = DivWdg()
SmartMenu.assign_as_local_activator( title_wdg, 'HEADER_CTX' )
title_wdg.add_style("margin: 0px 0px 5px 0px")
title_wdg.add_gradient("background", "background", 0)
title_wdg.add_color("color", "color")
title_wdg.add_style("padding", "5px")
if title_action_script:
# add an action button if an action script code was found in the attributes of the element
proj = Project.get_project_code()
script_search = Search("config/custom_script")
script_sobj = script_search.get_by_search_key( "config/custom_script?project=%s&code=%s" %
(proj, title_action_script) )
script = script_sobj.get_value('script')
icon_str = "HELP"
if title_action_icon:
icon_str = title_action_icon
action_btn = HtmlElement.img( IconWdg.get_icon_path(icon_str) )
action_btn.set_attr('title',title_action_label)
# action_btn = IconWdg( title_action_label, icon=icon)
action_btn.add_behavior( {'type': 'click_up', 'cbjs_action': script } )
action_btn.add_styles( "cursor: pointer; float: right;" )
title_wdg.add( action_btn )
title_wdg.add(title)
container.add(title_wdg)
return container
示例14: get_display
# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import img [as 别名]
def get_display(my):
top = my.top
src = my.kwargs.get("src")
file = my.kwargs.get("file")
if file:
src = file.get_web_path()
opacity = 1.0
if not src:
src = "/context/icons/logo/tactic_silver.png"
opacity = 0.6
height = my.kwargs.get("height")
width = my.kwargs.get("width")
index = my.kwargs.get("index")
if not height:
height = "auto"
if not width:
width = "100%"
width = "100%"
height = "auto"
#div = DivWdg()
#top.add(div)
div = top
div.add_class("unselectable")
div.add_style("opacity", opacity)
div.add_style("overflow-x: hidden")
div.add_style("overflow-y: hidden")
div.add_style("margin-left: auto")
div.add_style("margin-right: auto")
div.add_style("text-align: center")
if height:
div.add_style("height", height)
if width:
div.add_style("width", width)
parts = os.path.splitext(src)
ext = parts[1]
ext = ext.lower()
click = my.kwargs.get("click")
if click in [False, 'false']:
click = False
else:
click = True
thumb_path = my.kwargs.get("thumb_path")
preload = my.kwargs.get("preload")
if not preload:
preload = "none"
ext = ext.lstrip(".")
if ext in File.IMAGE_EXT:
embed = HtmlElement.img(src)
embed.add_style("width: 100%")
embed.add_style("height: auto")
elif ext in File.VIDEO_EXT:
from tactic.ui.widget import VideoWdg
embed = DivWdg()
if not thumb_path:
thumb_path = "/context/icons/logo/tactic_sml.png"
controls = my.kwargs.get("controls")
if not controls:
controls = "true"
video_id = None
sources = [src]
source_types = ["video/mp4"]
poster = thumb_path
width = '100%'
height = '100%'
#width = "640"
#height = "480"
video = VideoWdg(video_id=video_id, sources=sources, source_types=source_types, poster=poster, preload=preload, controls=controls, width=width, height=height, index=index)
embed.add(video)
video.get_video().add_class("spt_resizable")
click = False
else:
#embed = HtmlElement.embed(src)
if thumb_path:
img = HtmlElement.img(thumb_path)
else:
from pyasm.widget import ThumbWdg
link = ThumbWdg.find_icon_link(src)
img = HtmlElement.img(link)
img.add_style("width: 50%")
img.add_style("margin: 20px 20px")
embed = DivWdg(img)
#.........这里部分代码省略.........
示例15: get_display
# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import img [as 别名]
def get_display(my):
web = WebContainer.get_web()
skin = web.get_skin()
# default to 'small' size ...
h = 16
fnt_sz = 11
if my.size == 'medium':
h = 18
fnt_sz = 13
elif my.size == 'large':
h = 20
fnt_sz = 15
w = (h / 2) - 1
my.top_el.add_styles( "height: %spx;" % (h) )
t_styles = "color: #c2c2c2; border: 0px; border-collapse: collapse; padding: 0px"
bgi_open = "background-image: url(/context/themes/%(skin)s/images/text_btn/%(skin)s_btn_h%(h)s_" % \
{'skin': skin, 'h': h}
bgi_close = ".png)"
# pos_list = [ 'left', 'middle', 'right' ]
spacer = HtmlElement.img( IconWdg.get_icon_path("TRANSPARENT") )
spacer.add_styles( "width: 2px;" )
div_left = DivWdg()
div_left.add_styles( "%(bgi_open)s%(pos)s%(bgi_close)s;" %
{'bgi_open': bgi_open, 'pos': 'left', 'bgi_close': bgi_close} )
div_left.add_styles("float: left; height: %spx; width: %spx;" % (h, w) )
div_mid = DivWdg()
div_mid.add_styles( "%(bgi_open)s%(pos)s%(bgi_close)s;" %
{'bgi_open': bgi_open, 'pos': 'middle', 'bgi_close': bgi_close} )
div_mid.add_styles("float: left; height: %spx; width: auto;" % (h) )
div_mid.add_styles("color: #c2c2c2;")
div_mid.add_styles("vertical-align: middle")
# move the text lower by 1 px
div_mid.add_style('padding-top: 1px')
div_mid.add_styles( "font-family: Arial, Helvetica, sans-serif; font-size: %spx;" % fnt_sz )
div_mid.add( spacer )
span = SpanWdg(my.label)
# this is better fixed. Bold fonts don't look good
span.add_style('font-weight: 100')
span.add_style('vertical-align: middle')
div_mid.add( span )
div_mid.add( spacer )
if my.show_option:
bgi_close = '_options.png)'
w += 10
my.div_right.add_styles( "%(bgi_open)s%(pos)s%(bgi_close)s;" %
{'bgi_open': bgi_open, 'pos': 'right', 'bgi_close': bgi_close} )
my.div_right.add_styles("float: left; height: %spx; width: %spx;" % (h, w) )
my.top_el.add( div_left )
my.top_el.add( div_mid )
my.top_el.add( my.div_right )
my.top_el.add_styles("overflow: hidden;")
if my.horiz_align == 'center':
my.top_el.add_styles("margin: auto;") # margin: auto -- used for centering in non-IE brwsrs
elif my.horiz_align == 'left':
my.top_el.add_styles("margin-left: %s;" % my.horiz_offset)
if my.vert_offset:
my.top_el.add_styles("margin-top: %s;" % my.vert_offset)
if my.width:
if type(my.width) == str:
my.width.replace("px","")
my.top_el.add_styles("width: %spx" % my.width)
else:
my.top_el.add_behavior({'type': 'load', 'cbjs_action': 'spt.widget.btn_wdg.set_btn_width( bvr.src_el );' })
return my.top_el