本文整理汇总了Python中pyasm.web.DivWdg.add_event方法的典型用法代码示例。如果您正苦于以下问题:Python DivWdg.add_event方法的具体用法?Python DivWdg.add_event怎么用?Python DivWdg.add_event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.web.DivWdg
的用法示例。
在下文中一共展示了DivWdg.add_event方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_drop_wdg
# 需要导入模块: from pyasm.web import DivWdg [as 别名]
# 或者: from pyasm.web.DivWdg import add_event [as 别名]
def get_drop_wdg(my):
if my.mode == 'view':
return SpanWdg()
hr = DivWdg()
hr.set_attr("SPT_ACCEPT_DROP", "manageSideBar")
hr.add_style("height: 5px")
hr.add_style("width: 150px")
#hr.add_style("border: solid 1px black")
hr.add_style("position: absolute")
hr.add_event("onmouseover", "this.getChildren()[0].style.display=''")
hr.add_event("onmouseout", "this.getChildren()[0].style.display='none'")
hr.add("<hr style='margin-top: 2px; size: 1px; color: #222; display: none'/>")
return hr
示例2: get_day_wdg
# 需要导入模块: from pyasm.web import DivWdg [as 别名]
# 或者: from pyasm.web.DivWdg import add_event [as 别名]
#.........这里部分代码省略.........
div.add_color("color", "color")
div.add_style("vertical-align: top")
st_title = SearchType.get(my.search_type).get_value('title')
if sobjects:
#ids = "".join( [ "['id','%s']" % x.get_id() for x in sobjects ])
ids = [ str(x.get_id()) for x in sobjects ]
ids_filter = "['id' ,'in', '%s']" %'|'.join(ids)
expression = "@SOBJECT(%s%s)" % (my.search_type, ids_filter)
div.add_behavior( {
'type': "click_up",
'cbjs_action': '''
var class_name = 'tactic.ui.panel.TableLayoutWdg';
var title = '%s: %s';
var kwargs = {
'search_type': '%s',
'view': 'table',
'show_insert': 'false',
'expression': "%s"
};
spt.app_busy.show("Loading...")
setTimeout(function() {
//spt.panel.load_popup( title, class_name, kwargs );
spt.tab.set_main_body_tab();
spt.tab.add_new(title, title, class_name, kwargs);
spt.app_busy.hide();
}, 200)
''' % (st_title, str(day),my.search_type, expression ),
} )
content = DivWdg()
content.add_style("vertical-align: top")
content.add_class("spt_calendar_day_content")
content.add_style("height: 100%")
#content.add_style("width: 400px")
content.add_style("min-height: %s" % my.height);
my.handler.set_sobjects(sobjects)
else:
content = DivWdg()
content.add_style("vertical-align: top")
content.add_style("height: 100%")
#content.add_style("width: 400px")
content.add_style("min-height: %s" % my.height);
my.handler.set_sobjects([])
# force it to be 120px for now
if my.width:
content.add_style("width: %spx" % my.width)
my.handler.set_date(day)
content.add( my.handler.get_buffer_display() )
div.add(content)
today = datetime.today()
# store date like the database does YYYY-MM-DD
date_str = "%04d-%02d-%02d" % (day.year, day.month, day.day)
div.add_attr('spt_date', date_str)
div.add_class('spt_date_day')
color1 = div.get_color("background")
color2 = div.get_color("background", -10)
# put a different color for days that are not in the current month
if day.month != month:
div.add_style("color: #c22")
div.add_style("opacity: 0.7")
#div.add_style("background-image", "linear-gradient(135deg, #ccc 0%, #ccc 25%, #bbb 25%, #bbb 50%, #ccc 50%, #ccc 75%, #bbb 75%);");
div.add_style("background-size", "15px 15px")
div.add_style("background-color", "")
div.add_style("background-image", "linear-gradient(135deg, rgba(0, 0, 0, 0.06) 25%, rgba(0, 0, 0, 0) 25%, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0.06) 50%, rgba(0, 0, 0, 0.06) 75%, rgba(0, 0, 0, 0) 75%, rgba(0, 0, 0, 0));")
elif day.year == today.year and day.month == today.month and day.day == today.day:
div.add_color("background", "background", [-10, -10, 20])
color1 = div.get_color("background", [-10, -10, 20])
div.add_event("onmouseover", "$(this).setStyle('background-color','%s')" % color2)
div.add_event("onmouseout", "$(this).setStyle('background-color','%s')" % color1)
return div
示例3: get_script_wdg
# 需要导入模块: from pyasm.web import DivWdg [as 别名]
# 或者: from pyasm.web.DivWdg import add_event [as 别名]
def get_script_wdg(my):
search = Search("config/custom_script")
#search.add_user_filter()
search.add_order_by("folder")
search.add_order_by("title")
scripts = search.get_sobjects()
widget = DivWdg()
widget.add_style("width: 100%")
from pyasm.web.palette import Palette
palette = Palette.get()
bg_color = palette.color("background3")
hover_color = palette.color("background3", 20)
widget.add_color("background", bg_color)
'''
# Try the table layout widget
from tactic.ui.panel import TableLayoutWdg
table = TableLayoutWdg(id='js_edit_list',search_type="config/custom_script", view='simple')
table.set_sobjects(scripts)
widget.add(table)
'''
title = DivWdg()
title.add("Saved Scripts")
title.add_style("font-size: 14px")
title.add_color("color", "color")
title.add_style("padding: 8px 3px")
title.add_style("margin: 0 0 0 -1")
title.add_color("background", "background", -5)
title.add_border()
widget.add(title)
script_div = DivWdg()
script_div.add_border()
script_div.add_color("background", "background3")
script_div.add_color("color", "color3")
script_div.add_style("padding: 8px")
script_div.add_style("overflow-x: hidden")
script_div.add_style("overflow-y: auto")
script_div.add_style("height: 100%")
script_div.add_style("min-width: 100px")
script_div.add_style("width: 220px")
script_div.add_style("margin: -1px 0px 0px -1px")
script_div.add_class("spt_resizable")
inner = DivWdg()
script_div.add(inner)
inner.add_style("height: 100%")
inner.add_style("width: 800px")
last_folder = ''
for script in scripts:
title = script.get_value("title")
folder = script.get_value("folder")
language = script.get_value("language", no_exception=True)
if not language:
language = 'javascript'
if folder != last_folder:
div = DivWdg()
icon = IconWdg("Script", IconWdg.FOLDER)
div.add(icon)
div.add(" %s" % folder)
inner.add(div)
last_folder = folder
div = DivWdg()
inner.add(div)
div.add_class('hand')
icon = IconWdg("Script", IconWdg.TOGGLE_ON)
icon.add_style("margin-left: 10px")
div.add(icon)
div.add("%s" %title)
span = SpanWdg()
span.add_style("font-size: 9px")
span.add_style("opacity: 0.2")
span.add(" <i>(%s)</i>" % language)
div.add(span)
div.add_event("onmou8eover", "this.style.background='%s'" % hover_color)
div.add_event("onmouseout", "this.style.background='%s'" % bg_color)
behavior = {
'type': 'click_up',
'editor_id': my.editor_id,
'cbjs_action': 'spt.script_editor.display_script_cbk(evt, bvr)',
'code': script.get_code()
}
div.add_behavior(behavior)
#.........这里部分代码省略.........
示例4: get_display
# 需要导入模块: from pyasm.web import DivWdg [as 别名]
# 或者: from pyasm.web.DivWdg import add_event [as 别名]
def get_display(self):
web = WebContainer.get_web()
key = web.get_form_value('name')
top = DivWdg()
top.add_class('ad_search_wdg_top')
self.set_as_panel(top)
text = TextWdg("name")
text.set_value(key)
close_wdg = SpanWdg()
close_wdg.add( IconWdg("Close", IconWdg.POPUP_WIN_CLOSE) )
close_wdg.add_style("float: right")
close_wdg.add_class("hand")
# NOTE: the div we are looking for to hide on 'close' is outside of the this widget and
# is part of the parent widget
close_wdg.add_behavior({
'type': 'click_up',
'cbjs_action': '''
var ad_input_content = bvr.src_el.getParent(".ad_input_content");
spt.toggle_show_hide(ad_input_content);
'''
})
top.add( close_wdg )
top.add("Active Directory Search:<br clear='all'/> ")
table = Table()
table.add_row()
table.add_cell(text)
td = table.add_cell(self.get_search_wdg())
td.add_style("display", "")
top.add(table)
results_div = DivWdg()
top.add(results_div)
results_div.add_style("border: solid 1px #444")
results_div.add_style("margin: 10px")
results_div.add_style("padding: 5px")
#results_div.add_style("max-height: 400px")
results_div.add_style("overflow: auto")
if not key:
results_div.add("Please enter search criteria")
return top
results_div.add("Results Found ...")
users = self.find_users(key)
max_num_users = 20
if len(users) > max_num_users:
display_users = users[:max_num_users]
else:
display_users = users
for user in display_users:
user_div = DivWdg()
user_div.add_style("margin: 5px")
user_div.add_class("hand")
user_div.add_event("onmouseover", "$(this).setStyle('background','#444')")
user_div.add_event("onmouseout", "$(this).setStyle('background','#222')")
checkbox = CheckboxWdg()
user_div.add(checkbox)
display_name = user.get('display_name')
if not display_name:
display_name = "%s %s" % (user.get('first_name'), user.get('last_name'))
email = user.get('email')
login = user.get('login')
phone_number = user.get('phone_number')
user_div.add(display_name)
if email:
user_div.add(" (%s) " % email)
self.cbjs_action = self.kwargs.get('cbjs_action')
if self.cbjs_action:
user_behavior = {
'type': 'click_up',
'cbjs_action': self.cbjs_action
}
user_div.add_behavior( user_behavior )
else:
user_behavior = {
'type': 'click_up',
'cbjs_action': 'alert("Not implemented")'
}
user_div.add_behavior( user_behavior )
user_div.add_attr("spt_input_value", login)
user_div.add_attr("spt_display_value", display_name)
user_div.add_attr("spt_phone_number", phone_number)
user_div.add_attr("spt_email", email)
#.........这里部分代码省略.........
示例5: get_display
# 需要导入模块: from pyasm.web import DivWdg [as 别名]
# 或者: from pyasm.web.DivWdg import add_event [as 别名]
#.........这里部分代码省略.........
element.setStyle("background", "%s")
element.setStyle("padding", "1px")
}
}
''' %(light_bg_color, bg_color)
} )
match_div.add(select)
match_div.add_color("color", "color2")
match_div.add(" on the following")
hint = HintWdg( "An 'AND' operation is always applied to each category below. " \
"This controls only the filters within each category." )
match_div.add(hint)
match_div.add('<br/>')
match_div.add_style("padding-top: 5px")
filter_div.add( search_wdg)
search_wdg.add_style("float: left")
filter_div.add( match_div)
filter_div.add(HtmlElement.br())
filters_div = DivWdg()
filters_div.add_style("margin: 0 -6 0 -6")
security = Environment.get_security()
# add all the filters
for filter in my.filters:
element_name = filter.get_name()
if not security.check_access("search", element_name, "view"):
continue
# no need to create it again
#filter = my.config.get_display_widget(element_name)
div = DivWdg()
filters_div.add(div)
div.add_class("hand")
class_suffix = element_name.replace(' ', '_')
cbjs_action = 'var el=spt.get_cousin(bvr.src_el,".spt_search",".spt_filter_%s");spt.simple_display_toggle(el);' % class_suffix
div.add_behavior( {
'type': 'click_up',
'cbjs_action': cbjs_action
} )
div.add_color("color", "color", +5)
div.add_gradient("background", "background", -5, -5)
div.add_style("margin-top: -1px")
div.add_border()
div.add_style("padding: 3px")
div.add_style("whitespace: nowrap")
if element_name in ["Parent", 'Children']:
swap = SwapDisplayWdg.get_triangle_wdg()
else:
swap = SwapDisplayWdg.get_triangle_wdg()
swap.set_off()
swap.add_action_script(cbjs_action)
div.add_event("onclick", swap.get_swap_script() )
div.add(swap)
div.add_class("SPT_DTS")
div.add(element_name)
div = DivWdg()
div.add_class("spt_filter_%s" % class_suffix)
if element_name in ["Parent", 'Children']:
div.add_style("display: none")
else:
div.add_style("display: block")
#div.add_style("background-color: #333")
div.add_color("background", "background")
div.add_border()
div.add_style("padding: 5px 3px 5px 3px")
div.add_style("margin-top: -1px")
#div.add_style("margin-left: 20px")
#div.add_style("width: 660")
div.add(filter)
filters_div.add(div)
filter_div.add(filters_div)
buttons_div = DivWdg()
buttons_div.add_style("margin-top: 7px")
buttons_div.add_style("margin-bottom: 7px")
buttons_div.add(my.get_search_wdg() )
filter_div.add(buttons_div)
filter_top.add(filter_div)
return filter_top
示例6: _get_bar
# 需要导入模块: from pyasm.web import DivWdg [as 别名]
# 或者: from pyasm.web.DivWdg import add_event [as 别名]
def _get_bar(my, percent, proc_count, task):
'''get a vertical bar indicating the progress of a task '''
sobject = my.get_current_sobject()
bar = DivWdg()
if my.desc_checkbox_value == "on":
bar.add_style('margin-right: 20px')
else:
bar.add_style('width: 10px')
bar.add_style('float: left')
cur_percent = 100.0
increment = 100.0 / proc_count
# get some task info
assigned = 'unassigned'
process = task.get_value('process')
if task.get_value('assigned').strip():
assigned = task.get_value('assigned')
task_desc = task.get_value('description')
if not task_desc:
task_desc = 'n/a'
start_date = task.get_value("bid_start_date")
end_date = task.get_value("bid_end_date")
if start_date:
start_date = Date(db_date=start_date, show_warning=False).get_display_date()
else:
start_date = "?"
if end_date:
end_date = Date(db_date=end_date, show_warning=False).get_display_date()
else:
end_date = "?"
# remove some spacing characters
task_desc = re.sub('(\n|\r|\t)', ' ', task_desc)
task_desc = re.sub('"', "'", task_desc)
task_status = task.get_value('status')
display_percent = percent
if percent < 0:
task_status = "%s <font color=red>(obsolete)</font>" % task_status
display_percent = 0
msg = '<b>%s</b><br/><hr>%s<br/><span style=padding-left:1em>desc: %s</span><br/>' \
'<span style=padding-left:1em>status:%s (%s%%)</span><br/>'\
'<span style=padding-left:1em>%s - %s</span>'\
% (process, assigned, task_desc, task_status, display_percent, start_date, end_date)
if WebContainer.get_web().get_browser() == "IE":
bar.add_event('onmouseover', "hint_bubble.show(event, '%s')" %msg)
else:
bar.add_tip(msg)
from pyasm.widget import IconWdg
end_date = task.get_value("bid_end_date")
end_date = Date(db_date=end_date, show_warning=False)
now_date = Date(show_warning=False)
if now_date.get_utc() > end_date.get_utc() and percent != 100:
alert_color = "#f00"
else:
alert_color = None
for x in xrange(proc_count):
cur_percent -= increment
div = DivWdg()
content = ' '
# unidentified status probably
if percent < 0:
content = '—'
div.add_style('text-decoration: blink')
div.add(content)
div.add_style('width: 10px')
if cur_percent < percent or cur_percent == 0:
if alert_color:
div.add_style("background-color: %s" % alert_color)
else:
div.add_style("background-color: %s" % my._get_color_code(percent))
bar_height = my.get_option("bar_height")
if not bar_height:
bar_height = my.bar_select_value
if not bar_height:
bar_height = '3'
div.add_style("height: %spx" % bar_height)
# IE needs to set the font size to reduce the overall size
div.add_style("font-size: %spx" % bar_height )
if sobject.is_retired():
div.add_class('task_status_bar_retired')
else:
if my.label_select_value == "abbr":
div.add_style("margin: -1px")
#div.add_class("task_status_bar")
#div.add_style("margin-top: 2px")
div.add_border()
#.........这里部分代码省略.........
示例7: get_content_wdg
# 需要导入模块: from pyasm.web import DivWdg [as 别名]
# 或者: from pyasm.web.DivWdg import add_event [as 别名]
def get_content_wdg(my):
div = DivWdg()
div.add_class("spt_tile_layout_top")
if my.top_styles:
div.add_styles(my.top_styles)
inner = DivWdg()
div.add(inner)
menus_in = {}
# set up the context menus
if my.show_context_menu == True:
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() ]
elif my.show_context_menu == 'none':
div.add_event('oncontextmenu', 'return false;')
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", "spt.thumb.background_enter(event, this) ")
inner.add_attr("ondragleave", "spt.thumb.background_leave(event, this) ")
inner.add_attr("ondragover", "return false")
inner.add_attr("ondrop", "spt.thumb.background_drop(event, this)")
inner.add("<br clear='all'/>")
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++) {
#.........这里部分代码省略.........
示例8: get_display
# 需要导入模块: from pyasm.web import DivWdg [as 别名]
# 或者: from pyasm.web.DivWdg import add_event [as 别名]
def get_display(my):
top = DivWdg()
top.add_class("spt_sample_chart_top")
table = Table()
table.add_row()
left = table.add_cell()
# add the chart
chart_div = DivWdg()
chart_div.add_class("spt_sample_chart")
left.add(chart_div)
chart_div.add_style("width: 600")
chart_div.add_style("height: 400")
chart_div.add_style("padding: 10px")
data_file = 'bar-2.txt'
chart = ChartWdg(data_file=data_file)
chart_div.add(chart)
# add navigator
right = table.add_cell()
right.add_style("text-align: top")
top.add(table)
base_dir = "%s/src" % Environment.get_install_dir()
rel_dir = 'context/spt_js/ofc/data-files'
files_div = DivWdg()
files_div.add_style("height: 400")
files_div.add_style("overflow: auto")
files_div.add_style("padding: 3px")
right.add(files_div)
files = os.listdir("%s/%s" % (base_dir, rel_dir))
for file in files:
if not file.endswith(".txt"):
continue
explore_div = DivWdg()
link = "/%s/%s" % (rel_dir, file)
explore_div.add("<a target='_blank' href='%s'>(+)</a> " % link)
explore_div.add_style("float: left")
files_div.add(explore_div)
file_div = DivWdg()
file_div.add_style("padding: 2px")
file_div.add_class("hand")
file_div.add_event("onmouseover", "this.style.background='#696969'")
file_div.add_event("onmouseout", "this.style.background='#444'")
file_div.add(file)
files_div.add(file_div)
file_div.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
var value = bvr.src_el.innerHTML;
var top = bvr.src_el.getParent(".spt_sample_chart_top");
var chart = top.getElement(".spt_sample_chart");
spt.panel.load(chart, 'tactic.ui.chart.ChartWdg', {data_file:value});
'''
} )
return top
示例9: get_link_wdg
# 需要导入模块: from pyasm.web import DivWdg [as 别名]
# 或者: from pyasm.web.DivWdg import add_event [as 别名]
def get_link_wdg(my, element_name, config, options):
attributes = config.get_element_attributes(element_name)
title = my._get_title(config, element_name)
default_access = "view"
path = options.get('path')
security = Environment.get_security()
if not security.check_access("side_bar", element_name, "view", default=default_access):
return
# backwards compatibility??
#if not security.check_access("url", path, "view"):
# return
link_wdg = DivWdg(css="hand")
link_wdg.add_style( "padding-top: 4px" )
link_wdg.add_attr("spt_title", title)
link_wdg.add_attr("spt_icon", attributes.get("icon"))
link_wdg.add_class("spt_side_bar_link")
link_wdg.add_attr("spt_view", config.get_view() )
link_wdg.add_attr("spt_element_name", element_name)
link_wdg.add_attr("spt_path", options['path'])
# add the mouseover color change
link_wdg.add_style("color: #292929")
link_wdg.add_class("SPT_DTS")
hover = link_wdg.get_color("background3", -10)
link_wdg.add_event("onmouseover", "this.style.background='%s'" % hover)
link_wdg.add_event("onmouseout", "this.style.background=''")
link_wdg.add_class("spt_side_bar_element")
link_wdg.add_looks("fnt_text")
link_wdg.add_attr("spt_view", config.get_view() )
# add an invisible drop widget
drop_wdg = my.get_drop_wdg()
drop_wdg.add_style("margin-top: -3px")
link_wdg.add(drop_wdg)
span = SpanWdg()
span.add_class("spt_side_bar_title")
# add an icon
icon = attributes.get("icon")
if icon:
icon = icon.upper()
from pyasm.widget import IconWdg
try:
span.add( IconWdg(title, eval("IconWdg.%s" % icon) ) )
except:
pass
span.add(title)
link_wdg.add(span)
return link_wdg