本文整理汇总了Python中tactic.ui.container.SmartMenu类的典型用法代码示例。如果您正苦于以下问题:Python SmartMenu类的具体用法?Python SmartMenu怎么用?Python SmartMenu使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SmartMenu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_section_wdg
def get_section_wdg(my, title, description, image, behavior):
section_wdg = DivWdg()
section_wdg.set_round_corners()
section_wdg.add_border()
section_wdg.add_class("spt_report_top")
section_wdg.add_style("width: 200px")
section_wdg.add_style("height: 100px")
section_wdg.add_style("overflow: hidden")
section_wdg.add_style("margin: 10px")
section_wdg.set_box_shadow("0px 0px 10px")
title_wdg = DivWdg()
section_wdg.add(title_wdg)
title_wdg.add(title)
title_wdg.add_style("height: 20px")
title_wdg.add_style("padding: 3px")
title_wdg.add_style("margin-top: 3px")
title_wdg.add_style("font-weight: bold")
title_wdg.add_gradient("background", "background")
button = IconButtonWdg(title="Options", icon=IconWdg.ARROWHEAD_DARK_DOWN)
title_wdg.add(button)
button.add_style("float: right")
# set up menus
menu = my.get_menu()
SmartMenu.add_smart_menu_set( button, { 'MENU_ITEM': menu } )
SmartMenu.assign_as_local_activator( button, "MENU_ITEM", True )
section_wdg.add_color("background", "background")
#section_wdg.add_gradient("background", "background", 0, -3)
section_wdg.add_behavior( {
'type': 'hover',
'add_color_modifier': -5,
'cb_set_prefix': 'spt.mouse.table_layout_hover',
} )
desc_div = DivWdg()
desc_div.add(description)
desc_div.add_style("padding: 5px 10px 10px 5px")
div = DivWdg()
section_wdg.add(div)
div.add_style("padding: 3px")
div.add_style("margin: 5px")
div.add_style("width: 65px")
div.add_style("height: 50px")
div.add_style("float: left")
div.add(image)
section_wdg.add(desc_div)
div.add_style("overflow: hidden")
section_wdg.add_behavior( behavior )
section_wdg.add_class("hand")
return section_wdg
示例2: get_display
def get_display(my):
security = Environment.get_security()
if security.check_access("builtin", "view_site_admin", "allow"):
menus = [my.get_main_menu(), my.get_add_menu(), my.get_edit_menu(), my.get_tools_menu(), my.get_help_menu()]
else:
menus = [my.get_main_menu(), my.get_edit_menu(), my.get_help_menu()]
"""
btn_dd = DivWdg()
btn_dd.add_styles("width: 36px; height: 18px; padding: none; padding-top: 1px;")
btn_dd.add( "<img src='/context/icons/common/transparent_pixel.gif' alt='' " \
# "title='TACTIC Actions Menu' class='tactic_tip' " \
"style='text-decoration: none; padding: none; margin: none; width: 4px;' />" )
btn_dd.add( "<img src='/context/icons/silk/cog.png' alt='' " \
"title='TACTIC Actions Menu' class='tactic_tip' " \
"style='text-decoration: none; padding: none; margin: none;' />" )
btn_dd.add( "<img src='/context/icons/silk/bullet_arrow_down.png' alt='' " \
"title='TACTIC Actions Menu' class='tactic_tip' " \
"style='text-decoration: none; padding: none; margin: none;' />" )
"""
from tactic.ui.widget import SingleButtonWdg
btn_dd = SingleButtonWdg(title="Global Options", icon=IconWdg.GEAR, show_arrow=True)
# btn_dd.add_behavior( { 'type': 'hover',
# 'mod_styles': 'background-image: url(/context/icons/common/gear_menu_btn_bkg_hilite.png); ' \
# 'background-repeat: no-repeat;' } )
smenu_set = SmartMenu.add_smart_menu_set(btn_dd, {"DG_TABLE_GEAR_MENU": menus})
SmartMenu.assign_as_local_activator(btn_dd, "DG_TABLE_GEAR_MENU", True)
return btn_dd
示例3: get_content_wdg
def get_content_wdg(self):
div = DivWdg()
inner = DivWdg()
div.add(inner)
# set up the context menus
menus_in = {
#'DG_HEADER_CTX': [ self.get_smart_header_context_menu_data() ],
'DG_DROW_SMENU_CTX': [ self.get_data_row_smart_context_menu_details() ]
}
SmartMenu.attach_smart_context_menu( inner, menus_in, False )
if self.sobjects:
for i, sobject in enumerate(self.sobjects):
if i == 0:
self.first = True
else:
self.first = False
inner.add(self.get_item_wdg(sobject))
inner.add("<hr/>")
else:
table = Table()
inner.add(table)
self.handle_no_results(table);
return div
示例4: get_tile_wdg
def get_tile_wdg(my, sobject):
div = DivWdg()
div.add_class("spt_tile_top")
div.add_class("spt_table_row")
top_view = my.kwargs.get("top_view")
if top_view:
title_wdg = my.get_view_wdg(sobject, top_view)
else:
title_wdg = my.get_title(sobject)
div.add( title_wdg )
div.add_attr("spt_search_key", sobject.get_search_key())
div.add_attr("spt_name", sobject.get_name())
div.add_attr("spt_search_code", sobject.get_code())
SmartMenu.assign_as_local_activator( div, 'DG_DROW_SMENU_CTX' )
div.add_border()
div.set_box_shadow()
div.add_color("background", "background", -3)
div.add_style("margin: 10px")
div.add_style("overflow: hidden")
div.add_style("float: left")
thumb_div = DivWdg()
thumb_div.add_class("spt_tile_content")
#thumb_div.add_class("spt_tile_detail")
div.add(thumb_div)
width = 240
height = 160
thumb_div.add_style("width: %s" % width)
thumb_div.add_style("height: %s" % height)
thumb_div.add_style("overflow: hidden")
thumb = ThumbWdg2()
thumb.set_sobject(sobject)
thumb_div.add(thumb)
bottom_view = my.kwargs.get("bottom_view")
if bottom_view:
div.add( my.get_view_wdg(sobject, bottom_view) )
div.add_attr("ondragenter", "return false")
div.add_attr("ondragover", "return false")
div.add_attr("ondrop", "spt.thumb.noop(event, this)")
return div
示例5: add_menu_wdg
def add_menu_wdg(my, button, menus):
from tactic.ui.container import SmartMenu
my.menus = []
my.menus.append(menu.get_data())
smenu_set = SmartMenu.add_smart_menu_set( button, { 'BUTTON_MENU': my.menus } )
SmartMenu.assign_as_local_activator( button, "BUTTON_MENU", True )
示例6: add_file_behaviors
def add_file_behaviors(my, item_div, dirname, basename):
path = "%s/%s" % (dirname, basename)
item_div.add_attr("spt_path", path)
item_div.add_class("spt_dir_list_item")
SmartMenu.assign_as_local_activator( item_div, 'FILE_MENU_CTX' )
# for explicit Browse
if my.preselected:
item_div.add_class("spt_preselected")
super(CheckinDirListWdg, my).add_file_behaviors(item_div, dirname, basename)
示例7: get_item_wdg
def get_item_wdg(my, sobject):
div = DivWdg()
div.add_class("spt_item_top")
div.add_style("padding: 10px")
SmartMenu.assign_as_local_activator( div, 'DG_DROW_SMENU_CTX' )
div.add_class("spt_table_row")
div.add_attr("spt_search_key", sobject.get_search_key(use_id=True))
div.add_attr("spt_search_code", sobject.get_code())
name = sobject.get_value("name", no_exception=True)
if not name:
name = sobject.get_code()
div.add_attr("spt_name", name)
table = Table()
div.add(table)
table.set_max_width()
tr = table.add_row()
width = my.kwargs.get("preview_width")
if not width:
width = "240px"
td = table.add_cell()
td.add_style("width: %s" % width);
td.add_style("vertical-align: top")
"""
from tile_layout_wdg import ThumbWdg2
thumb_div = DivWdg()
#td.add(thumb_div)
thumb_div.add_border()
thumb_div.set_box_shadow("0px 0px 5px")
thumb_div.add_color("background", "background", -5)
thumb_div.add_class("spt_item_content")
#thumb_div.add_style("min-height: 120px")
thumb = ThumbWdg2()
thumb_div.add(thumb)
thumb.set_sobject(sobject)
"""
tile_wdg = my.tile_layout.get_tile_wdg(sobject)
td.add(tile_wdg)
info_div = my.get_info_wdg(sobject)
td = table.add_cell(info_div)
td.add_style("vertical-align: top")
return div
示例8: add_dir_behaviors
def add_dir_behaviors(my, dir_div, dirname, basename):
path = "%s/%s" % (dirname, basename)
dir_div.add_attr("spt_path", path)
dir_div.add_class("spt_dir_list_item")
SmartMenu.assign_as_local_activator( dir_div, 'FILE_MENU_CTX' )
dir_div.add_class("spt_dir")
# for explicit Browse
if my.preselected:
dir_div.add_class("spt_preselected")
# for dir, only preselect the first one
my.preselected = False
super(CheckinDirListWdg, my).add_dir_behaviors(dir_div, dirname, basename)
示例9: add_file_behaviors
def add_file_behaviors(my, item_div, dirname, basename):
path = "%s/%s" % (dirname, basename)
file_objects = my.kwargs.get("files")
file_object = file_objects.get(path)
if not file_object:
print "WARNING: No file object for [%s]" % path
return
file_search_key = file_object.get_search_key()
item_div.add_class("spt_dir_list_item")
item_div.add_attr("spt_path", path)
item_div.add_attr("spt_file_search_key", file_search_key)
SmartMenu.assign_as_local_activator( item_div, 'FILE_MENU_CTX' )
示例10: get_content_wdg
def get_content_wdg(my):
div = DivWdg()
inner = DivWdg()
div.add(inner)
# set up the context menus
menus_in = {
#'DG_HEADER_CTX': [ my.get_smart_header_context_menu_data() ],
'DG_DROW_SMENU_CTX': [ my.get_data_row_smart_context_menu_details() ]
}
SmartMenu.attach_smart_context_menu( inner, menus_in, False )
for sobject in my.sobjects:
inner.add(my.get_item_wdg(sobject))
return div
示例11: get_content_wdg
def get_content_wdg(my):
div = DivWdg()
div.add_class("spt_tile_layout_top")
inner = DivWdg()
div.add(inner)
# set up the context menus
menus_in = {
'DG_HEADER_CTX': [ my.get_smart_header_context_menu_data() ],
'DG_DROW_SMENU_CTX': [ my.get_data_row_smart_context_menu_details() ]
}
SmartMenu.attach_smart_context_menu( inner, menus_in, False )
from tactic.ui.filter import FilterData
filter_data = FilterData.get()
data_list = filter_data.get_values_by_prefix("tile_layout")
if data_list:
data = data_list[0]
else:
data = {}
my.scale = data.get("scale")
if my.scale == None:
my.scale = my.kwargs.get("scale")
inner.add_style("margin-left: 20px")
if my.sobjects:
inner.add( my.get_scale_wdg() )
for sobject in my.sobjects:
kwargs = my.kwargs.copy()
tile = my.get_tile_wdg(sobject)
inner.add(tile)
else:
table = Table()
inner.add(table)
my.handle_no_results(table)
inner.add("<br clear='all'/>")
return div
示例12: get_display
def get_display(my):
assert my.load_script
widget = DivWdg()
widget.add_style('float', 'right')
load_button = TextOptionBtnWdg(label=' Load ', size='medium')
load_button.get_top_el().add_style('float', 'left')
load_button.get_top_el().set_id(my.LOAD_BUTTON_ID)
load_button.add_behavior(
{'type': "click_up",
"cbjs_action":
"setTimeout(function() {%s}, 200) "% my.load_script
})
widget.add(load_button)
arrow_button = load_button.get_option_widget()
#widget.add(arrow_button)
suffix = "ASSET_LOADER_FUNCTIONS"
menus_in = [ my.smart_menu_data ]
SmartMenu.add_smart_menu_set( arrow_button, menus_in)
SmartMenu.assign_as_local_activator(arrow_button, None, True)
#SmartMenu.attach_smart_context_menu( load_button, menus_in, False )
x_div = FloatDivWdg("x")
x_div.add_color('color','color')
x_div.add_style('margin-right: 6px')
widget.add(x_div)
multiplier = TextWdg()
multiplier.set_id("load_multiplier")
multiplier.set_option("size", "1.5")
multiplier.add_style("font-size: 0.8em")
multiplier.add_style("float: left")
multiplier.add_class("load_multiplier")
widget.add( multiplier )
return widget
示例13: handle_is_test
def handle_is_test(my, content):
content.add_behavior( {
'type': 'mouseover',
'cbjs_action': '''
bvr.src_el.setStyle("border", "solid 1px blue");
bvr.src_el.setStyle("margin", "-1px");
var els = bvr.src_el.getElements(".spt_test");
for (var i = 0; i < els.length; i++) {
els[i].setStyle("display", "");
break;
}
'''
} )
content.add_behavior( {
'type': 'mouseleave',
'cbjs_action': '''
bvr.src_el.setStyle("border", "none");
bvr.src_el.setStyle("margin", "0px");
var els = bvr.src_el.getElements(".spt_test");
for (var i = 0; i < els.length; i++) {
els[i].setStyle("display", "none");
break;
}
'''
} )
div = DivWdg()
content.add(div)
div.add_style("position: absolute")
div.add(my.view)
div.add_class("spt_test")
div.add_border()
div.set_box_shadow("1px 1px 1px 1px")
div.add_style("display: none")
div.add_style("padding: 3px")
div.add_style("left: 0px")
div.add_style("top: -15px")
#div.add_style("opacity: 0.5")
div.add_style("inherit: false")
div.add_style("z-index: 1000")
div.add_style("background-color: white")
div.add_class("hand")
div.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_custom_top");
top.setAttribute("spt_is_test", "true");
var size = top.getSize();
top.innerHTML = "<div style='width: "+size.x+";height: "+size.y+";padding: 10px; font-weight: bold'>Loading ...</div>";
spt.panel.refresh(top);
'''
} )
# add in a context menu
menu = my.get_test_context_menu()
menus = [menu.get_data()]
menus_in = {
'TEST_CTX': menus,
}
SmartMenu.attach_smart_context_menu( div, menus_in, False )
SmartMenu.assign_as_local_activator( div, 'TEST_CTX' )
示例14: get_container
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
示例15: get_content_wdg
def get_content_wdg(my):
div = DivWdg()
div.add_class("spt_tile_layout_top")
inner = DivWdg()
div.add(inner)
# set up the context menus
show_context_menu = my.kwargs.get("show_context_menu")
if show_context_menu in ['false', False]:
show_context_menu = False
else:
show_context_menu = True
menus_in = {}
if show_context_menu:
menus_in['DG_HEADER_CTX'] = [ my.get_smart_header_context_menu_data() ]
menus_in['DG_DROW_SMENU_CTX'] = [ my.get_data_row_smart_context_menu_details() ]
if menus_in:
SmartMenu.attach_smart_context_menu( inner, menus_in, False )
temp = my.kwargs.get("temp")
has_loading = False
inner.add_style("margin-left: 20px")
inner.add_attr("ondragenter", "return false")
inner.add_attr("ondragover", "return false")
inner.add_attr("ondrop", "spt.thumb.background_drop(event, this)")
if my.sobjects:
inner.add( my.get_scale_wdg() )
for row, sobject in enumerate(my.sobjects):
if False and not temp and row > 4:
tile_wdg = DivWdg()
inner.add(tile_wdg)
tile_wdg.add_style("width: 120px")
tile_wdg.add_style("height: 120px")
tile_wdg.add_style("float: left")
tile_wdg.add_style("padding: 20px")
tile_wdg.add_style("text-align: center")
tile_wdg.add('<img src="/context/icons/common/indicator_snake.gif" border="0"/>')
tile_wdg.add(" Loading ...")
tile_wdg.add_attr("spt_search_key", sobject.get_search_key())
tile_wdg.add_class("spt_loading")
has_loading = True
continue
kwargs = my.kwargs.copy()
tile = my.get_tile_wdg(sobject)
inner.add(tile)
else:
table = Table()
inner.add(table)
my.handle_no_results(table)
chunk_size = 5
if has_loading:
inner.add_behavior( {
'type': 'load',
'chunk': chunk_size,
'cbjs_action': '''
var layout = bvr.src_el.getParent(".spt_layout");
spt.table.set_layout(layout);
var rows = layout.getElements(".spt_loading");
var jobs = [];
var count = 0;
var chunk = bvr.chunk;
while (true) {
var job_item = rows.slice(count, count+chunk);
if (job_item.length == 0) {
break;
}
jobs.push(job_item);
count += chunk;
}
var count = -1;
var func = function() {
count += 1;
var rows = jobs[count];
if (! rows || rows.length == 0) {
return;
}
for (var i = 0; i < rows.length; i++) {
rows[i].removeClass("spt_loading");
}
spt.table.refresh_rows(rows, null, null, {on_complete: func});
}
func();
#.........这里部分代码省略.........