本文整理汇总了Python中pyasm.web.Table.add_class方法的典型用法代码示例。如果您正苦于以下问题:Python Table.add_class方法的具体用法?Python Table.add_class怎么用?Python Table.add_class使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.web.Table
的用法示例。
在下文中一共展示了Table.add_class方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_load_balancing
# 需要导入模块: from pyasm.web import Table [as 别名]
# 或者: from pyasm.web.Table import add_class [as 别名]
def handle_load_balancing(self, top):
# deal with asset directories
top.add(DivWdg('Load Balancing', css='spt_info_title'))
table = Table()
table.add_class("spt_loadbalance")
table.add_color("color", "color")
table.add_style("margin: 10px")
top.add(table)
table.add_row()
td = table.add_cell("Load Balancing: ")
td.add_style("width: 150px")
button = ActionButtonWdg(title='Test')
td = table.add_cell(button)
message_div = DivWdg()
message_div.add_class("spt_loadbalance_message")
table.add_cell(message_div)
button.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
var server = TacticServerStub.get()
var ports = {};
var count = 0;
for (var i = 0; i < 50; i++) {
var info = server.get_connection_info();
var port = info.port;
var num = ports[port];
if (!num) {
ports[port] = 1;
count += 1;
}
else {
ports[port] += 1;
}
// if there are 10 requests and still only one, then break
if (i == 10 && count == 1)
break;
}
// build the ports string
x = [];
for (i in ports) {
x.push(i);
}
x.sort();
x = x.join(", ");
var loadbalance_el = bvr.src_el.getParent(".spt_loadbalance");
var message_el = loadbalance_el.getElement(".spt_loadbalance_message");
if (count > 1) {
var message = "Yes (found " + count + " ports: "+x+")";
}
else {
var message = "<blink style='background: red; padding: 3px'>Not enabled (found only port " + x + ")</blink>";
}
message_el.innerHTML = message
'''
} )
示例2: get_container_with_top_row
# 需要导入模块: from pyasm.web import Table [as 别名]
# 或者: from pyasm.web.Table import add_class [as 别名]
def get_container_with_top_row(my):
# Getting [ Title| Machine Room | Blah | Blah table headings ]
container = DivWdg()
container.add_class('container')
container.add_style('width: 1500px !important;')
top_table_container = DivWdg()
top_table_container.add_style('overflow-y: scroll !important;')
top_table = Table()
top_table.add_class('table table-bordered')
top_table.add_style('table-layout: fixed;')
top_table.add_row()
title_cell = top_table.add_cell("Title")
title_cell.add_class('col-md-1')
second_cell = top_table.add_cell("Machine Room")
second_cell.add_class('col-md-1')
third_cell = top_table.add_cell("Compression")
third_cell.add_class('col-md-1')
fourth_cell = top_table.add_cell("Audio")
fourth_cell.add_class('col-md-1')
fifth_cell = top_table.add_cell("QC")
fifth_cell.add_class('col-md-1')
sixth_cell = top_table.add_cell("EDel")
sixth_cell.add_class('col-md-1')
top_table_container.add(top_table)
container.add(top_table_container)
return container
示例3: get_display
# 需要导入模块: from pyasm.web import Table [as 别名]
# 或者: from pyasm.web.Table import add_class [as 别名]
def get_display(my):
container = my.get_container_with_top_row()
overflow_container = DivWdg()
overflow_container.add_style('height: 600px !important;')
overflow_container.add_style('overflow-y: scroll !important;')
top_table_lower = Table()
top_table_lower.add_class('table table-bordered')
top_table_lower.add_style('table-layout: fixed;')
top_table_lower.add_row()
for i in range(0, 10):
my.add_lower_table_row(top_table_lower)
overflow_container.add(top_table_lower)
container.add(overflow_container)
return container
示例4: get_display
# 需要导入模块: from pyasm.web import Table [as 别名]
# 或者: from pyasm.web.Table import add_class [as 别名]
def get_display(my):
top = DivWdg()
top.add_border()
top.add_style("padding: 10px")
top.add_color("color", "color")
top.add_gradient("background", "background", 0, -5)
#top.add_style("height: 550px")
top.add_behavior( {
'type': 'load',
'cbjs_action': '''
spt.named_events.fire_event("side_bar|hide_now", {} );
'''
} )
project = Project.get()
title = DivWdg()
title.add("Project Startup and Configuration")
title.add_style("font-size: 18px")
title.add_style("font-weight: bold")
title.add_style("text-align: center")
title.add_style("padding: 10px")
title.add_style("margin: -10px -10px 10px -10px")
top.add(title)
title.add_gradient("background", "background3", 5, -10)
shelf = DivWdg()
top.add(shelf)
shelf.add_style("margin-left: -8px")
shelf.add_style("width: 130px")
button_div = DivWdg()
shelf.add(button_div)
button_div.add_style("float: left")
button_div.add_style("margin-top: -3px")
security = Environment.get_security()
view_side_bar = security.check_access("builtin", "view_side_bar", "allow", default='allow')
if view_side_bar:
button = IconButtonWdg(title="Side Bar", icon=IconWdg.ARROW_LEFT)
button_div.add(button)
shelf.add("Toggle Side Bar")
shelf.add_attr("title", "Toggle Side Bar (or press '1')")
button.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
spt.named_events.fire_event("side_bar|toggle");
'''
} )
shelf.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
spt.named_events.fire_event("side_bar|toggle");
'''
} )
shelf.add_class("hand")
else:
shelf.add(" ")
search_wdg = Table()
top.add(search_wdg)
search_wdg.add_row()
search_wdg.add_class("spt_main_top")
search_wdg.add_style("padding: 10px")
search_wdg.add_style("margin: 20px auto")
search_wdg.add_style("width: 430px")
td = search_wdg.add_cell("Search: ")
td.add_style("vertical-align: top")
td.add_style("padding-top: 8px")
custom_cbk = {}
custom_cbk['enter'] = '''
var top = bvr.src_el.getParent(".spt_main_top");
var search_el = top.getElement(".spt_main_search");
var keywords = search_el.value;
if (keywords != '') {
var class_name = 'tactic.ui.panel.ViewPanelWdg';
var kwargs = {
'search_type': 'sthpw/sobject_list',
'view': 'result_list',
'keywords': keywords,
'simple_search_view': 'simple_filter',
//'show_shelf': false,
}
spt.tab.set_main_body_tab();
spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
}
'''
from tactic.ui.input import TextInputWdg, LookAheadTextInputWdg
#.........这里部分代码省略.........
示例5: get_display
# 需要导入模块: from pyasm.web import Table [as 别名]
# 或者: from pyasm.web.Table import add_class [as 别名]
def get_display(my):
element_data_dict = {}
config = my.get_config()
element_names = config.get_element_names()
content_wdg = DivWdg()
if not element_names:
element_names = ['keywords']
my.set_content(content_wdg)
# this is somewhat duplicated logic from alter_search, but since this is called
# in ViewPanelWdg, it's a diff instance and needs to retrieve again
filter_data = FilterData.get()
data_list = filter_data.get_values_by_prefix(my.prefix)
for data in data_list:
handler = data.get("handler")
element_name = data.get("element_name")
if not element_name:
continue
element_data_dict[element_name] = data
elements_wdg = DivWdg()
content_wdg.add(elements_wdg)
elements_wdg.add_color("color", "color")
elements_wdg.add_style("padding-top: 10px")
elements_wdg.add_style("padding-bottom: 15px")
elements_wdg.add_color("background", "background3", 0)
elements_wdg.add_border()
if len(element_names) == 1:
elements_wdg.add_style("border-width: 0px 0px 0px 0px" )
elements_wdg.add_style("padding-right: 50px" )
else:
elements_wdg.add_style("border-width: 0px 1px 0px 0px" )
table = Table()
table.add_color("color", "color")
elements_wdg.add(table)
table.add_class("spt_simple_search_table")
num_rows = int(len(element_names)/2)+1
tot_rows = int(len(element_names)/2)+1
project_code = Project.get_project_code()
# my.search_type could be the same as my.base_search_type
full_search_type = SearchType.build_search_type(my.search_type, project_code)
visible_rows = my.kwargs.get("visible_rows")
if visible_rows:
visible_rows = int(visible_rows)
num_rows = visible_rows
else:
visible_rows = 0
titles = config.get_element_titles()
row_count = 0
for i, element_name in enumerate(element_names):
attrs = config.get_element_attributes(element_name)
if i % 2 == 0:
if visible_rows and row_count == visible_rows:
tr, td = table.add_row_cell("+ more ...")
td.add_class("hand")
td.add_class("SPT_DTS")
td.add_class("spt_toggle")
td.add_style("padding-left: 10px")
td.add_behavior( {
'type': 'click_up',
'visible_rows': visible_rows,
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_simple_search_table");
var expand = true;
var rows = top.getElements(".spt_simple_search_row");
for (var i = 0; i < rows.length; i++) {
var row = rows[i];
if (row.getStyle("display") == "none") {
row.setStyle("display", "");
}
else {
row.setStyle("display", "none");
expand = false;
}
}
var spacer = top.getElements(".spt_spacer");
var cell = top.getElement(".spt_toggle");
if (expand) {
spacer.setStyle("height", (rows.length+bvr.visible_rows)*20);
cell.innerHTML = "- less ...";
}
else {
spacer.setStyle("height", bvr.visible_rows*20);
#.........这里部分代码省略.........
示例6: get_example_display
# 需要导入模块: from pyasm.web import Table [as 别名]
# 或者: from pyasm.web.Table import add_class [as 别名]
def get_example_display(my):
div = DivWdg()
# Smart Menu data ...
dog_menus = [ my.get_sm_dog_main_menu_details(),
my.get_sm_dog_submenu_one_details(),
my.get_sm_dog_submenu_two_details()
]
cat_menus = [ my.get_sm_cat_main_menu_details() ]
SmartMenu.attach_smart_context_menu( div, { 'DOG': dog_menus, 'CAT': cat_menus }, False )
table = Table(css="maq_view_table")
table.set_id( "main_body_table" )
table.add_class("spt_table")
table.add_behavior( { "type": "smart_drag",
"bvr_match_class": "SPT_DO_RESIZE",
"cbjs_setup": 'spt.dg_table.resize_column_setup( evt, bvr, mouse_411 );',
"cbjs_motion": 'spt.dg_table.resize_column_motion( evt, bvr, mouse_411 );'
} )
table.add_behavior( { "type": "smart_drag",
"bvr_match_class": "SPT_DO_DRAG",
"use_copy": 'true',
"use_delta": 'true', 'dx': 10, 'dy': 10,
"drop_code": 'TableExampleSwitchContents',
"cbjs_action": "spt.ui_play.drag_cell_drop_action( evt, bvr );",
"copy_styles": 'background: blue; opacity: .5; border: 1px solid black; text-align: left;'
} )
row = table.add_row()
for c in range(10):
th = table.add_header()
th.set_attr('col_idx', str(c))
th.add_class("cell_left")
th.add_styles("width: 150px; cursor: default;")
# @@@
th.add_behavior( {
"type": "move",
"cbjs_action": '''
// log.debug( "(x,y) = (" + mouse_411.curr_x + "," + mouse_411.curr_y + ")" );
spt.ui_play.header_half_move_cbk( evt, bvr, mouse_411 );
''',
"cbjs_action_on": '''
// log.debug( "START MY MOVE!" );
''',
"cbjs_action_off": '''
// log.debug( "DONE MY MOVE!" );
spt.ui_play.header_half_move_off_cbk( evt, bvr, mouse_411 );
'''
} )
if (c%2):
th.add("H%s (Cat)" % c)
else:
th.add("H%s (Dog)" % c)
th_resize = table.add_cell()
th_resize.set_attr('col_idx', str(c+1))
th_resize.add_class("SPT_DO_RESIZE cell_right")
th_resize.add_styles("width: 4px; cursor: col-resize;")
for r in range(19):
row = table.add_row()
for c in range(10):
col = table.add_cell()
col.set_attr('col_idx', str(c))
col.set_attr('SPT_ACCEPT_DROP', 'TableExampleSwitchContents')
col.add_class("SPT_DO_DRAG cell_left")
col.add_styles("cursor: pointer;")
col.add("(%s,%s)" % (r,c))
if (c % 2) == 0:
SmartMenu.assign_as_local_activator( col, "DOG" )
else:
SmartMenu.assign_as_local_activator( col, "CAT" )
resize = table.add_cell()
resize.set_attr('col_idx', str(c+1))
resize.add_class("SPT_DO_RESIZE cell_right")
resize.add_styles("width: 6px; cursor: col-resize;")
div.add( table )
return div
示例7: get_display
# 需要导入模块: from pyasm.web import Table [as 别名]
# 或者: from pyasm.web.Table import add_class [as 别名]
def get_display(self):
self.is_refresh = self.kwargs.get('is_refresh') =='true'
if not self.is_refresh:
top = DivWdg(css='spt_view_panel')
self.set_as_panel(top)
else:
top = Widget()
div = DivWdg(css="filter_box")
div.add("<b>Current Session</b>")
top.add(div)
# the button which initiates the introspection
button = IntrospectWdg()
#button.add_style("float", "right")
top.add(button)
top.add("<br clear='all'/>")
session = SessionContents.get()
if not session:
widget.add("<h3>No contents in session</h3>")
return widget
table = Table()
table.add_class("table")
table.add_style("width: 100%")
table.add_row()
table.add_header(" ")
table.add_header("Type")
table.add_header("Asset")
table.add_header("Node Name")
table.add_header("Node Type")
table.add_header("Reference")
table.add_header("Session")
table.add_header("Latest")
node_names = session.get_node_names()
for node_name in node_names:
table.add_row()
# snapshot_code
snapshot_code = session.get_snapshot_code(node_name, "shot")
if not snapshot_code:
snapshot_code = session.get_snapshot_code(node_name, "anim")
if not snapshot_code:
snapshot_code = session.get_snapshot_code(node_name, "asset")
snapshot = Snapshot.get_by_code(snapshot_code)
sobject = None
if snapshot:
sobject = snapshot.get_sobject()
base = sobject.get_search_type_obj().get_base_search_type()
thumb = ThumbWdg()
thumb.set_icon_size(60)
# FIXME: make this more automatic
if base == "prod/shot_instance":
thumb_sobj = sobject.get_parent("prod/asset")
thumb.set_sobject(thumb_sobj)
else:
thumb.set_sobject(sobject)
table.add_cell(thumb)
title = sobject.get_search_type_obj().get_title()
table.add_cell( title )
# TODO: this should be more automatic!
if base == "prod/shot_instance":
asset_code = sobject.get_value("asset_code")
shot_code = sobject.get_value("shot_code")
name = sobject.get_value("name")
table.add_cell("%s: %s in %s" % (name,asset_code,shot_code))
else:
code = sobject.get_code()
name = sobject.get_name()
if code == name:
table.add_cell( "%s" % (code) )
else:
table.add_cell( "%s - %s" % (code, name) )
else:
table.add_cell("<i>No snapshot</i>")
table.add_cell("---")
table.add_cell("---")
# display the node name
table.add_cell(node_name)
# display node type
table.add_cell( session.get_node_type(node_name) )
#.........这里部分代码省略.........
示例8: get_display
# 需要导入模块: from pyasm.web import Table [as 别名]
# 或者: from pyasm.web.Table import add_class [as 别名]
def get_display(self):
top = self.top
top.add_class("hand")
inner = self.inner
top.add(inner)
inner.add_class("spt_swap_top")
table = Table()
inner.add(table)
table.add_color("color", "color")
table.add_class("SPT_DTS")
table.add_row()
td = table.add_cell()
title = self.kwargs.get("title")
# determine whether this widget is on or off
is_on = self.kwargs.get("is_on")
if is_on in [True, "true"]:
is_on = True
else:
is_on = False
if not self.on_wdg or not self.off_wdg:
self.set_default_wdg()
# add the content id
if self.content_id:
inner.add_attr("spt_content_id", self.content_id)
# add the behaviors
if not self.behavior_top:
self.handle_top(top)
on_div = DivWdg()
td.add(on_div)
on_div.add_class("SPT_SWAP_ON")
off_div = DivWdg()
td.add(off_div)
off_div.add_class("SPT_SWAP_OFF")
if is_on:
off_div.add_style("display: none")
inner.add_attr("spt_state", "on")
else:
on_div.add_style("display: none")
inner.add_attr("spt_state", "off")
on_div.add( self.on_wdg )
off_div.add( self.off_wdg )
# handle an icon
icon_str = self.kwargs.get("icon")
if icon_str and isinstance(icon_str, basestring):
icon_div = DivWdg()
if icon_str.startswith("BS_"):
icon = IconWdg(name=title, icon=icon_str, size=12 )
icon_div.add_style("margin: -2px 10px 0px 10px")
icon_div.add_style("margin-left: -3px")
else:
icon = IconWdg(name=title, icon=icon_str )
icon_div.add_style("margin-left: -6px")
icon_div.add(icon)
td = table.add_cell(icon_div)
elif icon_str:
td = table.add_cell(icon_str)
icon_str.add_style("margin-left: -6px")
else:
show_border = self.kwargs.get("show_border")
if show_border in [True, 'true']:
on_div.add_border()
off_div.add_border()
on_div.add_style("width: 16")
on_div.add_style("height: 16")
on_div.add_style("overflow: hidden")
off_div.add_style("width: 16")
off_div.add_style("height: 16")
off_div.add_style("overflow: hidden")
if self.title_wdg:
td = table.add_cell(self.title_wdg)
else:
td = table.add_cell(title)
return top
示例9: ResizableTableWdg
# 需要导入模块: from pyasm.web import Table [as 别名]
# 或者: from pyasm.web.Table import add_class [as 别名]
class ResizableTableWdg(BaseRefreshWdg):
def __init__(self, **kwargs):
self.table = Table()
self.table.add_style("border-collapse: collapse")
self.table.add_style("padding: 0px")
self.table.set_attr("cellpadding", "0px")
self.table.set_attr("cellspacing", "0px")
self.is_first_row = True
self.hilight = self.table.get_color("background", -40)
super(ResizableTableWdg, self).__init__(**kwargs)
def set_style(self, name, value=None):
self.table.set_style(name, value)
def set_max_width(self):
self.table.set_max_width()
def add_class(self, name):
self.table.add_class(name)
def get_display(self):
top = self.top
self.table.add_class("spt_resizable_table_top")
self.table.add_behavior( {
'type': 'load',
'cbjs_action': self.get_onload_js()
} )
self.table.add_behavior( {
'type': 'load',
'cbjs_action': '''
var resizable_cells = bvr.src_el.getElements(".spt_resizable_cell");
for (var i = 0; i < resizable_cells.length; i++) {
var resizable_el = resizable_cells[i].getElement(".spt_resizable");
if (!resizable_el) {
continue;
}
var size = resizable_cells[i].getSize();
resizable_el.setStyle("width", size.x);
resizable_el.setAttribute("width", size.x);
}
'''
} )
top.add(self.table)
return top
def set_keep_table_size(self):
self.table.add_class("spt_resizable_keep_size")
def add_color(self, color, modifier=0):
self.table.add_color(color, modifier)
def add_border(self, modifier=0):
self.table.add_border(modifier=modifier)
def add_style(self, name, value=None):
self.table.add_style(name, value=value)
def add_row(self, resize=True):
# add resize row
if not self.is_first_row and resize == True:
tr, td = self.table.add_row_cell()
td.add_style("height: 3px")
td.add_style("min-height: 3px")
td.add_style("cursor: n-resize")
tr.add_behavior( {
'type': 'drag',
'cb_set_prefix': 'spt.resizable_table.row_drag'
} )
tr.add_behavior( {
'type': 'hover',
'hilight': self.hilight,
'cbjs_action_over': '''
var color = bvr.src_el.getStyle("background-color");
bvr.src_el.setStyle("background-color", bvr.hilight);
bvr.src_el.setAttribute("spt_last_background", color);
''',
'cbjs_action_out': '''
var color = bvr.src_el.getAttribute("spt_last_background");
bvr.src_el.setStyle("background-color", color);
'''
} )
#.........这里部分代码省略.........
示例10: get_versions_wdg
# 需要导入模块: from pyasm.web import Table [as 别名]
# 或者: from pyasm.web.Table import add_class [as 别名]
def get_versions_wdg(self):
div = DivWdg()
div.add_class("spt_imports")
title_wdg = DivWdg()
div.add(title_wdg)
title_wdg.add("Imports found:")
title_wdg.add_style("padding: 0px 0px 8px 0px")
base_dir = self.kwargs.get("base_dir")
imports_dir = "%s/imports" % base_dir
if not os.path.exists(imports_dir):
imports_dir = base_dir
basenames = os.listdir(imports_dir)
basenames.sort()
basenames.reverse()
div.add_relay_behavior( {
'type': 'mouseup',
'bvr_match_class': "spt_import_item",
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_imports");
var els = top.getElements(".spt_import_info");
for ( var i = 0; i < els.length; i++) {
spt.hide(els[i]);
}
var el = bvr.src_el.getElement(".spt_import_info");
spt.show(el);
'''
} )
# find all the zip files
count = 0
for basename in basenames:
if not basename.endswith(".txt"):
continue
if basename.find("-files-") != -1:
continue
if basename.find("-data-") != -1:
continue
version_wdg = DivWdg()
div.add(version_wdg)
version_wdg.add_style("padding: 3px 3px 3px 12px")
version_wdg.add_class("spt_import_item")
radio = RadioWdg("basename")
version_wdg.add(radio)
radio.set_option("value", basename)
if not count:
radio.set_checked()
version_wdg.add(basename)
version_wdg.add("<br/>")
# add info
path = "%s/%s" % (imports_dir, basename)
f = open(path)
data = f.read()
f.close()
data = jsonloads(data)
table = Table()
version_wdg.add(table)
table.add_class("spt_import_info")
if count:
table.add_style("display: none")
table.set_max_width()
table.add_style("margin-left: 40px")
table.add_style("margin-right: 20px")
version_wdg.add(table)
for name, value in self.data.items():
name = Common.get_display_title(name)
table.add_row()
table.add_cell(name)
table.add_cell(value)
count += 1
if count == 0:
msg_wdg = DivWdg()
div.add(msg_wdg)
#.........这里部分代码省略.........
示例11: get_display
# 需要导入模块: from pyasm.web import Table [as 别名]
# 或者: from pyasm.web.Table import add_class [as 别名]
def get_display(self):
element_data_dict = {}
config = self.get_config()
element_names = config.get_element_names()
content_wdg = DivWdg()
content_wdg.add_class("spt_simple_search_top")
onload_js = DivWdg()
content_wdg.add(onload_js)
onload_js.add_behavior( {
'type': 'load',
'cbjs_action': self.get_onload_js()
} )
if not element_names:
element_names = ['keywords']
self.set_content(content_wdg)
# this is somewhat duplicated logic from alter_search, but since this is called
# in ViewPanelWdg, it's a diff instance and needs to retrieve again
filter_data = FilterData.get()
filter_view = self.kwargs.get("filter_view")
if filter_view:
search = Search("config/widget_config")
search.add_filter("view", filter_view)
search.add_filter("category", "search_filter")
search.add_filter("search_type", self.search_type)
filter_config = search.get_sobject()
if filter_config:
filter_xml = filter_config.get_xml_value("config")
filter_value = filter_xml.get_value("config/filter/values")
if filter_value:
data_list = jsonloads(filter_value)
else:
data_list = filter_data.get_values_by_prefix(self.prefix)
for data in data_list:
handler = data.get("handler")
element_name = data.get("element_name")
if not element_name:
continue
element_data_dict[element_name] = data
elements_wdg = DivWdg()
content_wdg.add(elements_wdg)
elements_wdg.add_color("color", "color")
elements_wdg.add_style("padding-top: 10px")
elements_wdg.add_style("padding-bottom: 15px")
#elements_wdg.add_color("background", "background3", 0)
elements_wdg.add_color("background", "background", -3)
elements_wdg.add_border()
if len(element_names) == 1:
elements_wdg.add_style("border-width: 0px 0px 0px 0px" )
elements_wdg.add_style("padding-right: 50px" )
else:
elements_wdg.add_style("border-width: 0px 0px 0px 0px" )
table = Table()
table.add_color("color", "color")
elements_wdg.add(table)
table.add_class("spt_simple_search_table")
columns = self.kwargs.get("columns")
if not columns:
columns = 2
else:
columns = int(columns)
num_rows = int(len(element_names)/columns)+1
tot_rows = int(len(element_names)/columns)+1
project_code = Project.get_project_code()
# self.search_type could be the same as self.base_search_type
full_search_type = SearchType.build_search_type(self.search_type, project_code)
visible_rows = self.kwargs.get("visible_rows")
if visible_rows:
visible_rows = int(visible_rows)
num_rows = visible_rows
else:
visible_rows = 0
titles = config.get_element_titles()
#.........这里部分代码省略.........
示例12: get_display
# 需要导入模块: from pyasm.web import Table [as 别名]
# 或者: from pyasm.web.Table import add_class [as 别名]
def get_display(my):
# specially made for "load" view
if not my.view.endswith("load"):
return DivWdg()
widget = Widget()
# first use
filter_top = DivWdg(css="maq_search_bar")
filter_top.add_color("background", "background2", -15)
# so dg_table.search_cbk will obtain values from this widget
filter_top.add_class('spt_table_search')
filter_top.add_style("padding: 3px")
# this is used by get_process() in LoaderWdg
filter_top.add(HiddenWdg('prefix', 'view_action_option'))
for name, value in my.kwargs.items():
filter_top.set_attr("spt_%s" % name, value)
from tactic.ui.cgapp import SObjectLoadWdg, LoaderButtonWdg, LoaderElementWdg, IntrospectWdg
# this contains the process filter and load options
sobject_load = SObjectLoadWdg(search_type=my.search_type, load_options_class = my.load_options_class)
filter_top.add(sobject_load)
# set the process
#class foo:
# def get_value(my):
# return "texture"
#Container.put("process_filter", foo())
filter_top.add( HtmlElement.br() )
table = Table()
table.add_class('spt_action_wdg')
table.set_max_width()
td = table.add_cell()
# create the loader button
button = LoaderButtonWdg()
# -------------
# test an event mechanism
event_name = '%s|load_snapshot' % my.search_type
#event_name = 'load_snapshot'
# get triggers with this event
from pyasm.search import Search
search = Search("config/client_trigger")
search.add_filter("event", event_name)
triggers = search.get_sobjects()
if triggers:
for trigger in triggers:
#callback = trigger.get_value("custom_script_code")
callback = trigger.get_value("callback")
event_script = '''
spt.app_busy.show("Loading ...", "Loading selected [%s] in to session");
var script = spt.CustomProject.get_script_by_path("%s");
bvr['script'] = script;
spt.CustomProject.exec_custom_script(evt, bvr);
spt.app_busy.hide();
''' % (my.search_type, callback)
loader_script = '''spt.named_events.fire_event('%s', {})''' % event_name
table.add_behavior( {
'type': 'listen',
'event_name': event_name,
'cbjs_action': event_script
} )
# test a passed in script path
elif my.load_script_path:
# an event is called
event_name = 'load_snapshot'
event_script = '''var script = spt.CustomProject.get_script_by_path("%s");spt.CustomProject.exec_script(script)''' % my.load+script_path
loader_script = '''spt.named_events.fire_event('%s', {})''' % event_name
table.add_behavior( {
'type': 'listen',
'event_name': event_name,
'cbjs_action': event_script
} )
# end test
# ---------------
elif my.load_script:
#.........这里部分代码省略.........