本文整理汇总了Python中pyasm.web.SpanWdg.add_behavior方法的典型用法代码示例。如果您正苦于以下问题:Python SpanWdg.add_behavior方法的具体用法?Python SpanWdg.add_behavior怎么用?Python SpanWdg.add_behavior使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.web.SpanWdg
的用法示例。
在下文中一共展示了SpanWdg.add_behavior方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_tool_bar
# 需要导入模块: from pyasm.web import SpanWdg [as 别名]
# 或者: from pyasm.web.SpanWdg import add_behavior [as 别名]
def get_tool_bar(self):
widget = Widget()
trash_div = SpanWdg()
trash_div.set_id('trash_me')
trash_div.add(IconWdg('Trash', IconWdg.TRASH))
trash_div.add("TRASH!")
trash_div.add_class("hand")
trash_div.add_class("spt_side_bar_trash")
trash_div.set_attr("SPT_ACCEPT_DROP", "manageSideBar")
bvr = { "type": "click_up",\
'cbjs_action': "alert('Drag and drop element name here to remove it.')"}
trash_div.add_behavior(bvr)
widget.add(trash_div)
save_div = SpanWdg(css='med hand spt_side_bar_trash')
save_div.add(IconWdg('Save', IconWdg.SAVE))
bvr = { "type": "click_up",\
'cbjs_action': "spt.custom_project.manage_action_cbk({'value':'save'},'%s');" % self.view}
save_div.add_behavior(bvr)
widget.add(save_div)
return widget
示例2: get_related_wdg
# 需要导入模块: from pyasm.web import SpanWdg [as 别名]
# 或者: from pyasm.web.SpanWdg import add_behavior [as 别名]
def get_related_wdg(my, aliases):
div = DivWdg()
div.add("<b>Related links</b>:  ")
div.add_style("margin-top: 5px")
div.add_style("margin-bottom: 5px")
div.add_style("margin-left: 10px")
titles = [Common.get_display_title(x.replace("-"," ")) for x in aliases]
for alias, title in zip(aliases, titles):
link_div = SpanWdg()
div.add(link_div)
link_div.add_color("background", "background")
link_div.add(title)
link_div.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
spt.help.set_top();
spt.help.load_alias("%s");
''' % alias
} )
link_div.add_class("spt_link")
link_div.add_class("hand")
return div
示例3: get_license_info_wdg
# 需要导入模块: from pyasm.web import SpanWdg [as 别名]
# 或者: from pyasm.web.SpanWdg import add_behavior [as 别名]
def get_license_info_wdg(self):
div = DivWdg()
license = Environment.get_security().get_license()
if self.first_error:
return div
#if not license.is_licensed():
# return div
msg = DivWdg()
div.add(msg)
msg.add("The following describes the details of the installed license:<br/><br/>")
info_wdg = DivWdg()
div.add(info_wdg)
info_wdg.add_style("margin: 10px 30px")
info_wdg.add_style("font-size: 12px")
version = license.get_data("tactic_version")
if version:
info_wdg.add("TACTIC Version: ")
if version == "ALL":
version = "ALL (Open Source)"
info_wdg.add(version)
info_wdg.add(HtmlElement.br(2))
company = license.get_data("company")
info_wdg.add("Licensed To: ")
if company.find("Southpaw EPL") != -1:
company = SpanWdg("<a name='license'>Eclipse Public License v1.0</a> ")
icon = IconWdg("EPL v1.0", IconWdg.ZOOM)
company.add(icon)
company.add_class("hand")
company.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
spt.help.load_alias("license")
'''
} )
info_wdg.add(company)
info_wdg.add(HtmlElement.br(2))
info_wdg.add("Max Users: ")
info_wdg.add(license.get_data("max_users") )
info_wdg.add(HtmlElement.br(2))
info_wdg.add("Current Users: ")
info_wdg.add(license.get_current_users() )
info_wdg.add(HtmlElement.br(2))
info_wdg.add("Expiry Date: ")
expiry_date = license.get_data("expiry_date")
if not expiry_date:
expiry_date = "Permanent"
info_wdg.add(expiry_date)
info_wdg.add(HtmlElement.br(2))
return div
示例4: get_link_wdg
# 需要导入模块: from pyasm.web import SpanWdg [as 别名]
# 或者: from pyasm.web.SpanWdg import add_behavior [as 别名]
def get_link_wdg(my, section_id, target_id, title, options):
view_link_wdg = SpanWdg(css="hand")
view_link_wdg.add_class("SPT_DTS")
view_link_wdg.add_style("color: #292929")
view_link_wdg.add_event("onmouseover", "this.style.background='#696969'")
view_link_wdg.add_event("onmouseout", "this.style.background='#949494'")
view_link_wdg.add(title)
path = title
options['path'] = "/%s" % title
if not options.get('class_name'):
options['class_name'] = "tactic.ui.panel.ViewPanelWdg"
behavior = {
'type': 'click_up',
'cbfn_action': 'spt.side_bar.display_link_cbk',
'target_id': target_id,
'title': title,
'options': options,
}
view_link_wdg.add_behavior( behavior )
options2 = options.copy()
options2['inline_search'] = "true"
behavior = {
'type': 'click_up',
'modkeys': 'SHIFT',
'cbfn_action': 'spt.side_bar.display_link_cbk',
'is_popup': 'true',
'target_id': path,
'title': title,
'options': options2,
}
view_link_wdg.add_behavior( behavior )
return view_link_wdg
示例5: get_tool_bar
# 需要导入模块: from pyasm.web import SpanWdg [as 别名]
# 或者: from pyasm.web.SpanWdg import add_behavior [as 别名]
def get_tool_bar(my):
widget = Widget()
trash_div = SpanWdg()
# reset some global variables on load
trash_div.add_behavior({'type':'load', 'cbjs_action':'spt.side_bar.trashed_items=[]; spt.side_bar.changed_views={}'})
trash_div.set_id('trash_me')
trash_div.add(IconWdg('Trash', IconWdg.TRASH))
trash_div.add("TRASH!")
trash_div.add_class("hand")
trash_div.add_class("spt_side_bar_trash")
trash_div.set_attr("SPT_ACCEPT_DROP", "manageSideBar")
bvr = { "type": "click_up",\
'cbjs_action': "alert('Drag and drop link or folder here to remove it.')"}
trash_div.add_behavior(bvr)
widget.add(trash_div)
save_div = SpanWdg(css='med hand spt_side_bar_trash')
save_div.add(IconWdg('Save Ordering', IconWdg.SAVE))
# FIXME: is_personal???
is_personal = 'false'
bvr = { "type": "click_up",\
'cbjs_action': "spt.side_bar.manage_section_action_cbk({'value':'save'},'%s',%s);" % (my.view, is_personal)}
save_div.add_behavior(bvr)
widget.add(save_div)
return widget
示例6: SpanWdg
# 需要导入模块: from pyasm.web import SpanWdg [as 别名]
# 或者: from pyasm.web.SpanWdg import add_behavior [as 别名]
xml.set_attribute(node, "id", unique_id)
div = SpanWdg()
elements.append(div)
div.add_class("spt_replace_element")
div.add_attr("spt_replace_id", unique_id)
div.add_class("hand")
div.add_class("spt_link")
div.add_color("background", "background")
text = xml.get_node_value(node)
div.add(text)
div.add_behavior( {
'type': 'click_up',
'rel_path': link_rel_path,
'cbjs_action': '''
spt.help.set_top();
spt.help.load_rel_path( bvr.rel_path );
'''
} )
# dummy div to get color
div = DivWdg()
# convert pre-elements to have < and >
pre_nodes = xml.get_nodes("//pre")
for node in pre_nodes:
html = xml.to_string(node)
html = html.replace('''<pre class="screen">''','')
html = html.replace('''</pre>''','')
if not html:
示例7: get_tool_bar
# 需要导入模块: from pyasm.web import SpanWdg [as 别名]
# 或者: from pyasm.web.SpanWdg import add_behavior [as 别名]
def get_tool_bar(my):
widget = DivWdg()
widget.add_style("width: 250px")
refresh = IconButtonWdg("Refresh", IconWdg.REFRESH)
refresh.add_behavior(
{
"type": "click_up",
"cbjs_action": """
var top = bvr.src_el.getParent(".spt_panel");
spt.panel.refresh(top);
""",
}
)
widget.add(refresh)
widget.add(" ")
trash_div = SpanWdg()
# reset some global variables on load
trash_div.add_behavior(
{"type": "load", "cbjs_action": "spt.side_bar.trashed_items=[]; spt.side_bar.changed_views={}"}
)
trash_div.set_id("trash_me")
trash_div.add(IconWdg("Trash", IconWdg.TRASH))
trash_div.add_class("hand")
trash_div.add_class("spt_side_bar_trash")
trash_div.set_attr("SPT_ACCEPT_DROP", "manageSideBar")
bvr = {"type": "click_up", "cbjs_action": "alert('Drag and drop link or folder here to remove it.')"}
trash_div.add_behavior(bvr)
widget.add(trash_div)
save_div = SpanWdg(css="med hand spt_side_bar_trash")
save_div.add(IconWdg("Save Ordering", IconWdg.SAVE))
bvr = {
"type": "click_up",
"search_type": my.search_type,
"view": my.view,
"cbjs_action": """
if (confirm("Save ordering of this view [" + bvr.view + "] ?") ) {
var top = bvr.src_el.getParent(".spt_view_manager_top");
var list_top = top.getElement(".spt_menu_item_list");
var server = TacticServerStub.get();
server.start({"title": "Updating views"});
var is_personal = false;
spt.app_busy.show("Saving", "Saving view ["+bvr.view+"]");
spt.side_bar.save_view(bvr.search_type, bvr.view, is_personal, list_top);
server.finish();
spt.app_busy.hide();
}
""",
}
save_div.add_behavior(bvr)
widget.add(save_div)
gear = my.get_gear_menu()
gear.add_style("float: right")
widget.add(gear)
return widget
示例8: get_display
# 需要导入模块: from pyasm.web import SpanWdg [as 别名]
# 或者: from pyasm.web.SpanWdg import add_behavior [as 别名]
def get_display(my):
web = WebContainer.get_web()
widget = DivWdg()
widget.add_class("spt_search_limit_top")
#widget.add_style("border", "solid 1px blue")
widget.add_color("background", "background")
widget.add_color("color", "color")
widget.add_style("padding: 5px")
hidden = HiddenWdg("prefix", my.prefix)
widget.add(hidden)
if not my.search and not my.sobjects:
widget.add("No search or sobjects found")
return widget
# my.count should have been set in alter_search()
# which can be called explicitly thru this instance, my.
if not my.count:
my.count = my.search.get_count(no_exception=True)
# if my.sobjects exist thru inheriting from parent widgets
# or explicitly set, (this is not mandatory though)
if my.sobjects and len(my.sobjects) < my.search_limit:
limit = len(my.sobjects)
elif my.search and my.count < my.search_limit:
# this is only true if the total result of the search is
# less than the limit and so this wdg will not display
limit = my.count
else:
limit = my.search_limit
if not limit:
limit = 50
my.search_limit = limit
if my.refresh:
prev = SpanWdg( IconButtonWdg("Prev", IconWdg.LEFT, False ) )
prev.add_style("margin-left: 8px")
prev.add_style("margin-right: 6px")
prev.add_style("margin-top: -2px")
next = IconButtonWdg("Next", IconWdg.RIGHT, False, icon_pos="right" )
next.add_style("margin-left: 6px")
prev.add_behavior( {
'type': 'click_up',
'cbjs_action': my.refresh_script
} )
next.add_behavior( {
'type': 'click_up',
'cbjs_action': my.refresh_script
} )
else: # the old code pre 2.5
prev = IconButtonWdg("Prev", IconWdg.LEFT, False )
hidden_name = my.prev_hidden_name
hidden = HiddenWdg(hidden_name,"")
prev.add(hidden)
prev.add_event('onclick'," spt.api.Utility.get_input(document,'%s').value ='Prev';%s"\
%(hidden_name, my.refresh_script))
next = IconButtonWdg("Next", IconWdg.RIGHT, False, icon_pos="right" )
hidden_name = my.next_hidden_name
hidden = HiddenWdg(hidden_name,"")
next.add(hidden)
next.add_event('onclick',"spt.api.Utility.get_input(document,'%s').value ='Next';%s" \
%(hidden_name, my.refresh_script))
showing_wdg = DivWdg()
widget.add(showing_wdg)
showing_wdg.add_style("padding: 10px")
showing_wdg.add_style("margin: 10px")
showing_wdg.add_color("background", "background", -5)
showing_wdg.add_border()
label_span = SpanWdg("Showing: ")
showing_wdg.add(label_span)
showing_wdg.add( prev )
# this min calculation is used so that if my.sobjects is not set
# above for the calculation of the limit, which will make the last
# set of range numbers too big
left_bound = my.current_offset+1
if not limit:
# prevent error in ItemsNavigatorWdg if a search encounters query error
limit = 50
my.search_limit = limit
right_bound = min(my.current_offset+limit, my.count)
if left_bound > right_bound:
left_bound = 1
current_value = "%d - %d" % (left_bound, right_bound)
if my.style == my.SIMPLE:
showing_wdg.add( current_value )
#.........这里部分代码省略.........
示例9: get_display
# 需要导入模块: from pyasm.web import SpanWdg [as 别名]
# 或者: from pyasm.web.SpanWdg import add_behavior [as 别名]
def get_display(my):
my.collection_key = my.kwargs.get("collection_key")
collection = Search.get_by_search_key(my.collection_key)
top = my.top
my.kwargs["scale"] = 75;
my.kwargs["show_scale"] = False;
my.kwargs["expand_mode"] = "plain"
from tile_layout_wdg import TileLayoutWdg
tile = TileLayoutWdg(
**my.kwargs
)
parent_dict = my.kwargs.get("parent_dict")
has_parent=False
if parent_dict:
has_parent = True
path = my.kwargs.get("path")
if collection and path:
title_div = DivWdg()
top.add(title_div)
title_div.add_style("float: left")
title_div.add_style("margin: 15px 0px 15px 30px")
asset_lib_span_div = SpanWdg()
title_div.add(asset_lib_span_div)
icon = IconWdg(name="Asset Library", icon="BS_FOLDER_OPEN")
asset_lib_span_div.add(icon)
asset_lib_span_div.add(" <a><b>Asset Library</b></a> ")
path = path.strip("/")
parts = path.split("/")
for idx, part in enumerate(parts):
title_div.add(" / ")
# the last spt_collection_link does not need a search_key
if has_parent and (idx is not len(parts) - 1):
search_key = parent_dict.get(part)
title_div.add(" <a class='spt_collection_link' search_key=%s><b>%s</b></a> " % (search_key, part))
else:
title_div.add(" <a class='spt_collection_link'><b>%s</b></a> " % part)
title_div.add_style("margin-top: 10px")
# Adding behavior to collections link
parts = my.kwargs.get("search_type").split("/")
collection_type = "%s/%s_in_%s" % (parts[0], parts[1], parts[1])
exists = SearchType.get(collection_type, no_exception=True)
if not exists:
title_div.add("SearchType %s is not registered." % collection_type)
return top
# These behaviors are only activated if the view is within collection layout,
# "is_new_tab" is a kwargs set to true, if opening a new tab
if not my.kwargs.get("is_new_tab"):
icon.add_class("hand")
icon.add_behavior( {
'type': 'mouseover',
'cbjs_action': '''
bvr.src_el.setStyle('opacity', 1.0);
'''
} )
icon.add_behavior( {
'type': 'mouseout',
'cbjs_action': '''
bvr.src_el.setStyle('opacity', 0.6);
'''
} )
# make icon and All Assets title clickable to return to view all assets
asset_lib_span_div.add_class("hand")
asset_lib_span_div.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_collection_top");
var content = top.getElements(".spt_collection_content");
spt.panel.refresh(top);
'''
} )
title_div.add_class("hand")
title_div.add_relay_behavior( {
'type': 'mouseup',
'search_type': my.kwargs.get("search_type"),
'collection_type': collection_type,
'bvr_match_class': 'spt_collection_link',
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_collection_top");
var content = top.getElement(".spt_collection_content");
var collection_key = bvr.src_el.getAttribute("search_key");
#.........这里部分代码省略.........
示例10: SpanWdg
# 需要导入模块: from pyasm.web import SpanWdg [as 别名]
# 或者: from pyasm.web.SpanWdg import add_behavior [as 别名]
div = SpanWdg()
elements.append(div)
div.add_class("spt_replace_element")
div.add_attr("spt_replace_id", unique_id)
div.add_class("hand")
div.add_class("spt_link")
div.add_color("background", "background")
text = xml.get_node_value(node)
div.add(text)
div.add_behavior(
{
"type": "click_up",
"rel_path": link_rel_path,
"cbjs_action": """
spt.help.set_top();
spt.help.load_rel_path( bvr.rel_path );
""",
}
)
# dummy div to get color
div = DivWdg()
# convert pre-elements to have < and >
pre_nodes = xml.get_nodes("//pre")
for node in pre_nodes:
html = xml.to_string(node)
html = html.replace("""<pre class="screen">""", "")
html = html.replace("""</pre>""", "")
if not html: