本文整理汇总了Python中pyasm.widget.HiddenWdg.add_behavior方法的典型用法代码示例。如果您正苦于以下问题:Python HiddenWdg.add_behavior方法的具体用法?Python HiddenWdg.add_behavior怎么用?Python HiddenWdg.add_behavior使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.widget.HiddenWdg
的用法示例。
在下文中一共展示了HiddenWdg.add_behavior方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_display
# 需要导入模块: from pyasm.widget import HiddenWdg [as 别名]
# 或者: from pyasm.widget.HiddenWdg import add_behavior [as 别名]
#.........这里部分代码省略.........
bvr.src_el.value = 0;
}
else {
return;
}
}
else if (bvr.src_el.value == orig_value) {
return;
}
bvr.prefix_list.splice( bvr.prefix_list.indexOf(bvr.time_prefix),1)
var other_time_prefix = bvr.prefix_list[0];
spt.work_hour.update_total(bvr, '.spt_day' + bvr.time_prefix);
// register this as changed item
var all_top_el = bvr.src_el.getParent(".spt_work_hours_top");
var values1 = spt.api.Utility.get_input_values(all_top_el, '.spt_day'+ bvr.time_prefix, false);
var values2 = spt.api.Utility.get_input_values(all_top_el, '.spt_day'+ other_time_prefix, false);
// Merge values from straight time and overtime fields in values variable.
for (var attr in values2) {
values1[attr] = values2[attr];
}
for (val in values1) {
if (values1[val] && isNaN(values1[val])) {
spt.error('You have non-numeric values in your work hours. Please correct it: ' + values[val]);
return;
}
}
delete values1.data;
var value_wdg = all_top_el.getElement(".spt_data");
var value = JSON.stringify(values1);
value_wdg.value = value;
var layout = bvr.src_el.getParent(".spt_layout");
var version = layout.getAttribute("spt_version");
if (version == "2") {
spt.table.set_layout(layout);
spt.table.accept_edit(all_top_el, value, false);
}
else {
var cached_data = {};
spt.dg_table.edit.widget = all_top_el;
spt.dg_table.inline_edit_cell_cbk( value_wdg, cached_data );
}
'''
# accept on pressing Enter
behavior = {
'type': 'keydown',
'time_prefix': time_prefix,
'prefix_list': prefix_list,
'cbjs_action': '''
if (evt.key=='enter') {
%s
}
'''%script}
text.add_behavior(behavior)
behavior = {
'type': 'blur',
'time_prefix': time_prefix,
'prefix_list': prefix_list,
'cbjs_action': '''
%s
'''%script}
text.add_behavior(behavior)
text = TextWdg("total")
td = table.add_cell(text)
td.add_style("width: 35px")
text.add_border()
text.add_attr('spt_total', '.spt_total%s' % (time_prefix))
text.add_class('spt_total%s' % (time_prefix))
text.add_styles("width: %spx; text-align: right; padding-right: 3px"%my.day_width)
text.set_attr("readonly", "readonly")
# MAIN: Overtime, total.
if row_to_draw == my.OT_ROW:
text.add_color("background", "background2", modifier=[5,-15,0])
if total_hours_ot:
text.set_value("%0.1f" % total_hours_ot)
my.summary_ot[7].update({search_key: total_hours_ot})
else:
text.add_color("background", "background2", modifier=[20,0,15])
if total_hours_st:
text.set_value("%0.1f" % total_hours_st)
my.summary_st[7].update({search_key: total_hours_st})
td = table.add_blank_cell()
td.add_style('width: 100%')
return top
示例2: get_display
# 需要导入模块: from pyasm.widget import HiddenWdg [as 别名]
# 或者: from pyasm.widget.HiddenWdg import add_behavior [as 别名]
def get_display(self):
current = self.get_current_sobject()
if current.is_insert():
widget = Widget()
parent_key = self.get_option('parent_key')
if parent_key:
parent = SearchKey.get_by_search_key(parent_key)
if parent:
widget.add(SpanWdg(parent.get_code()))
else:
# use the project as the parent
parent = Project.get()
widget.add(SpanWdg("Project: %s" % parent.get_code()))
#raise TacticException('Task creation aborted since parent is undetermined. Please check the configuration that generates this table.')
text = HiddenWdg(self.get_input_name())
text.set_option('size','40')
text.set_value(parent_key)
widget.add(text)
return widget
else:
search_type = current.get_value('search_type')
if not search_type:
return "No parent type"
widget = Widget()
parent = current.get_parent()
if parent:
widget.add(parent.get_code())
return widget
# What is this look up code for?
text = TextWdg(self.get_input_name())
behavior = {
'type': 'keyboard',
'kbd_handler_name': 'DgTableMultiLineTextEdit'
}
text.add_behavior(behavior)
widget.add(text)
icon = IconButtonWdg("Look up", IconWdg.ZOOM)
icon.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
var options = {
title: '%s',
class_name: 'tactic.ui.panel.ViewPanelWdg'
};
var args = {
search_type: '%s',
view: 'list'
};
spt.popup.get_widget( {}, {options: options, args: args} );
''' % (search_type, search_type)
} )
widget.add(icon)
return widget
示例3: get_display
# 需要导入模块: from pyasm.widget import HiddenWdg [as 别名]
# 或者: from pyasm.widget.HiddenWdg import add_behavior [as 别名]
def get_display(my):
top = my.top
top.add_class("spt_input_top")
top.add_style("position: relative")
top.add_style("width: 150px")
top.add_style("margin-top: -1px")
top.add_style("margin-left: -1px")
top.add_color("background", "background", -20)
top.add_border()
title = "Big"
div = DivWdg()
top.add(div)
icon_div = DivWdg()
div.add(icon_div)
icon_div.add_style("width: 20px")
icon_div.add_style("height: 21px")
icon_div.add_style("padding-left: 3px")
icon_div.add_style("margin: -3 6 0 -3")
icon_div.add_color("background", "background", [+15, 0, 0])
icon_div.add_style("float: left")
icon_div.add_style("opacity: 0.5")
icon = IconWdg("Select", IconWdg.FILM)
icon_div.add(icon)
div.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_input_top");
var content = spt.get_element( top, ".spt_input_content");
spt.toggle_show_hide(content);
spt.body.add_focus_element(content);
content.position(top);
'''
} )
div.add(title)
div.add_class("hand")
div.add_style("padding: 3px")
#top.add( TextWdg("hello") )
select_div = DivWdg()
top.add(select_div)
select_div.add_style("position: absolute")
select_div.add_class("spt_input_content")
select_div.add_color("background", "background")
select_div.add_style("top: 0px")
select_div.add_style("left: 0px")
select_div.add_style("display: none")
select_div.add_style("z-index: 1000")
select_div.set_box_shadow()
select_div.add_border()
select_div.add_class("SPT_PUW")
for title in ("Big", "Fat", "Cow", "Horse", "Donkeys"):
div = DivWdg()
select_div.add(div)
icon_div = DivWdg()
div.add(icon_div)
icon_div.add_style("width: 20px")
icon_div.add_style("height: 21px")
icon_div.add_style("margin: -3 6 0 -3")
icon_div.add_color("background", "background", [+15, 0, 0])
icon_div.add_style("float: left")
icon_div.add_style("opacity: 0.5")
icon_div.add(" ")
div.add(title)
div.add_class("hand")
div.add_style("padding: 3px")
div.add_style("width: 100px")
hover = div.get_color("background", [-30, -30, 20])
div.add_behavior( {
'type': 'hover',
'hover': hover,
'cbjs_action_over': '''
bvr.src_el.setStyle("background", bvr.hover);
''',
'cbjs_action_out': '''
bvr.src_el.setStyle("background", "");
'''
} )
div.add_behavior( {
'type': 'click_up',
#.........这里部分代码省略.........
示例4: SearchLimitWdg
# 需要导入模块: from pyasm.widget import HiddenWdg [as 别名]
# 或者: from pyasm.widget.HiddenWdg import add_behavior [as 别名]
class SearchLimitWdg(Widget):
DETAIL = "detail_style"
LESS_DETAIL = "less_detail_style"
SIMPLE = "simple_style"
def __init__(self, name='search_limit', label="Showing", limit=None, refresh=True):
self.search_limit_name = name
self.label = label
if limit:
self.search_limit = int(limit)
else:
self.search_limit = None
self.fixed_offset = False
self.style = self.DETAIL
self.prefix = "search_limit"
self.refresh = refresh
self.refresh_script = 'spt.dg_table.search_cbk(evt, bvr)'
if self.refresh:
self.prev_hidden_name = 'Prev'
self.next_hidden_name = 'Next'
else:
self.prev_hidden_name = '%s_Prev' %self.label
self.next_hidden_name = '%s_Next' %self.label
self.chunk_size = 0
self.chunk_num = 0
super(SearchLimitWdg, self).__init__()
def init(self):
self.current_offset = 0
self.count = None
#self.text = TextWdg(self.search_limit_name)
self.text = HiddenWdg(self.search_limit_name)
self.text.add_style("width: 23px")
self.text.add_style("margin-bottom: -1px")
self.text.add_class("spt_search_limit_text")
self.text.set_persist_on_submit(prefix=self.prefix)
behavior = {
'type': 'keydown',
'cbjs_action': '''
if (evt.key=='enter') {
// register this as changed item
var value = bvr.src_el.value;
if (isNaN(value) || value.test(/[\.-]/)) {
spt.error('You have to use an integer.');
}
}
'''}
self.text.add_behavior(behavior)
# get the search limit that is passed in
filter_data = FilterData.get()
values = filter_data.get_values_by_prefix(self.prefix)
if not values:
# check web for embedded table
web = WebContainer.get_web()
values = {}
limit_value = web.get_form_value("search_limit")
label_value = web.get_form_value(self.label)
if limit_value:
values['search_limit'] = limit_value
if label_value:
values[self.label] = label_value
else:
values = values[0]
self.values2 = filter_data.get_values_by_prefix("search_limit_simple")
if not len(self.values2):
self.values2 = {}
elif len(self.values2) == 2:
if self.values2[0]['page']:
self.values2 = self.values2[0]
else:
self.values2 = self.values2[1]
else:
self.values2 = self.values2[0]
self.stated_search_limit = values.get("search_limit")
"""
if not self.stated_search_limit:
self.stated_search_limit = values.get("limit_select")
if not self.stated_search_limit:
self.stated_search_limit = values.get("custom_limit")
"""
if self.stated_search_limit:
self.stated_search_limit = int(self.stated_search_limit)
else:
self.stated_search_limit = 0
# reused for alter_search() later
self.values = values
#.........这里部分代码省略.........