本文整理汇总了Python中tactic.ui.widget.ActionButtonWdg.add_behavior方法的典型用法代码示例。如果您正苦于以下问题:Python ActionButtonWdg.add_behavior方法的具体用法?Python ActionButtonWdg.add_behavior怎么用?Python ActionButtonWdg.add_behavior使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tactic.ui.widget.ActionButtonWdg
的用法示例。
在下文中一共展示了ActionButtonWdg.add_behavior方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_save_button
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_behavior [as 别名]
def get_save_button(my,checkin_keys):
save_button = ActionButtonWdg(title="Save >>", tip="Save configuration and start using TACTIC")
save_button.add_style("float: right")
save_button.add_behavior( {
'type': 'click_up',
'os' : os.name,
'checkin_options':checkin_keys,
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_db_config_top");
var failed_els = top.getElements('.spt_input_validation_failed')
if (failed_els.length > 0){
spt.alert('One of the fields fail validation. Please correct it before saving')
return;
}
spt.app_busy.show("Saving configuration. Please wait...")
var values = spt.api.Utility.get_input_values(top, null, false);
var class_name = 'tactic.ui.startup.DbConfigSaveCbk';
var server = TacticServerStub.get();
var kwargs = {checkin_options:bvr.checkin_options};
try {
var ret_val = server.execute_cmd(class_name, kwargs, values);
var info = ret_val.info;
}
catch(e) {
log.critical(spt.exception.handler(e));
//FIXME: recognize it's a 502 which is normal and pass , otherwise throw the error
//spt.error(spt.exception.handler(e));
//spt.app_busy.hide();
//return;
}
// This means TACTIC was restarted
if (typeof(info) == 'undefined' || bvr.os == 'nt' ) {
spt.app_busy.show("Restarting TACTIC ...");
var id = setInterval( function() {
var ping_rtn = server.ping();
if (ping_rtn) {
window.location = '/tactic';
clearInterval(id);
}
}, 5000 );
}
else if (info.error) {
spt.alert(info.error);
spt.app_busy.hide();
}
else {
window.location = '/tactic';
}
'''
} )
return save_button
示例2: get_tools_wdg
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_behavior [as 别名]
def get_tools_wdg(my):
div = DivWdg()
div.set_name("Tools")
div.add_style("padding: 10px")
div.add("This tool will export out a version of the project")
button = ActionButtonWdg(title="Export")
div.add(button)
button.add_behavior( {
'type': 'click_up',
'server': my.server_code,
'cbjs_action': '''
var class_name = 'tactic.ui.sync.SyncCreateTemplateCmd';
var kwargs = {
server: bvr.server
}
spt.app_busy.show("Exporting project ...");
var server = TacticServerStub.get();
server.execute_cmd(class_name, kwargs);
spt.app_busy.hide();
spt.panel.refresh(bvr.src_el);
'''
} )
return div
示例3: handle_python_script_test
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_behavior [as 别名]
def handle_python_script_test(self, top):
top.add(DivWdg('Python Script Test', css='spt_info_title'))
table = Table(css='script')
table.add_color("color", "color")
table.add_style("margin: 10px")
table.add_style("width: 100%")
top.add(table)
table.add_row()
td = table.add_cell("Script Path: ")
td.add_style("width: 150px")
text = TextWdg('script_path')
td = table.add_cell(text)
button = ActionButtonWdg(title='Run')
table.add_cell(button)
button.add_style("float: right")
button.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
var s = TacticServerStub.get();
try {
var path = bvr.src_el.getParent('.script').getElement('.spt_input').value;
if (! path)
throw('Please enter a valid script path');
s.execute_cmd('tactic.command.PythonCmd', {script_path: path});
} catch(e) {
spt.alert(spt.exception.handler(e));
}
'''
})
示例4: get_search_wdg
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_behavior [as 别名]
def get_search_wdg(self):
search_div = DivWdg()
if self.kwargs.get('run_search_bvr'):
run_search_bvr = self.kwargs.get('run_search_bvr')
else:
run_search_bvr = {
'type': 'click_up',
'cbjs_action': '''
spt.simple_search.hide();
spt.dg_table.search_cbk(evt, bvr);
''',
'new_search': True,
'panel_id': self.prefix
}
title = "Apply"
button = ActionButtonWdg(title=title, tip='Run search with this criteria' )
search_div.add(button)
#button.add_style("margin-top: -7px")
button.add_behavior( run_search_bvr )
return search_div
示例5: handle_load_balancing
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_behavior [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
'''
} )
示例6: get_display
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_behavior [as 别名]
def get_display(my):
top = DivWdg()
top.add_style("width: 100%")
top.add_color("background", "background", -10)
top.add_style("padding-top: 30px")
top.add_style("padding-bottom: 50px")
top.add_class("twog_wizard_top")
inner = DivWdg()
top.add(inner)
# set the width and height here
inner.add_style("width: 800px")
inner.add_style("min-height: 600px")
inner.add_style("float: center")
inner.add_border()
inner.center()
inner.add_style("padding: 20px")
inner.add_color("background", "background")
from tactic.ui.container import WizardWdg
title = DivWdg()
title.add("Step 1")
wizard = WizardWdg(title=title)
my.wizard = wizard
inner.add(wizard)
help_button = ActionButtonWdg(title="?", tip="Step 1 Help", size='s')
title.add(help_button)
help_button.add_style("float: right")
help_button.add_style("margin-top: -20px")
help_button.add_style("margin-right: -10px")
help_button.add_behavior({
'type': 'click_up',
'cbjs_action': '''
spt.help.set_top();
spt.help.load_alias("order_wdg");
'''
})
page_one = my.get_page_one()
wizard.add(page_one, 'Step 1')
page_two = my.get_page_two()
wizard.add(page_two, 'Step 2')
page_three = my.get_page_three()
wizard.add(page_three, 'Step 3')
page_four = my.get_page_four()
wizard.add(page_four, 'Step 4')
return top
示例7: get_display
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_behavior [as 别名]
def get_display(self):
top = self.top
upload = Html5UploadWdg(name="formxyz")
top.add(upload)
upload_id = upload.get_upload_id()
color = self.kwargs.get("color")
width = self.kwargs.get("width")
from tactic.ui.widget import ActionButtonWdg
button = ActionButtonWdg(title="Upload", color=color, width=width)
top.add(button)
button.add_behavior( {
'type': 'click_up',
'upload_id': upload_id,
'cbjs_action': '''
// set the form
spt.html5upload.form = $(bvr.upload_id);
// set an action for completion
var upload_complete = function(evt) {
var search_key = "sthpw/login?code=admin";
var server = TacticServerStub.get();
var file = spt.html5upload.get_file();
if (file) {
file_name = file.name;
server.simple_checkin(search_key, "icon", file_name, {mode:'uploaded'});
}
else
alert('Error: file object cannot be found.')
}
var upload_progress = function(evt) {
var percent = Math.round(evt.loaded * 100 / evt.total);
}
var onchange = function () {
spt.html5upload.upload_file( {
upload_complete: upload_complete,
upload_progress: upload_progress
} );
}
spt.html5upload.select_file( onchange);
'''
} )
return top
示例8: get_error_wdg
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_behavior [as 别名]
def get_error_wdg(my):
div = DivWdg()
error_div = DivWdg()
error_div.add("Error %s" % my.status)
div.add(error_div)
error_div.add_style("font-size: 18px")
error_div.add_style("font-weight: bold")
error_div.add_style("padding: 10px")
error_div.add_style("width: auto")
error_div.add_gradient("background", "background")
error_div.add_border()
error_div.add_style("margin-left: 5px")
error_div.add_style("margin-right: 5px")
error_div.add_style("margin-top: -10px")
div.add("<br/>")
span = DivWdg()
#span.add_color("color", "color")
span.add_style("color", "#FFF")
if my.status == 404:
span.add(HtmlElement.b("You have tried to access a url that is not recognized."))
else:
span.add(HtmlElement.b(my.message))
span.add(HtmlElement.br(2))
web = WebContainer.get_web()
root = web.get_site_root()
if my.message.startswith('No project ['):
label = 'You may need to correct the default_project setting in the TACTIC config.'
else:
label = "Go to the Main page for a list of valid projects"
span.add(label)
div.add(span)
div.add(HtmlElement.br())
from tactic.ui.widget import ActionButtonWdg
button_div = DivWdg()
button_div.add_style("width: 90px")
button_div.add_style("margin: 0px auto")
div.add(button_div)
button = ActionButtonWdg(title="Go to Main", tip='Click to go to main page')
button_div.add(button)
button.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
document.location = '/';
'''
} )
button.add_event("onmouseup", "document.location='/'")
return div
示例9: get_page_four
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_behavior [as 别名]
def get_page_four(my):
last_page = DivWdg()
last_page.add_style("padding-top: 80px")
last_page.add_style("padding-left: 30px")
cb = CheckboxWdg('jump_to_tab', label='Jump to Tab')
cb.set_checked()
last_page.add(cb)
last_page.add(HtmlElement.br(5))
button_div = DivWdg()
create_button = ActionButtonWdg(title="Create >>", tip="Create new project")
my.wizard.add_submit_button(create_button)
create_button.add_style("float: right")
create_button.add_behavior({
'type': "click_up",
'cbjs_action': '''
spt.alert('perform action here');
'''
})
# you can even pass in a custom cacel_script like
# spt.info("You have cancelled")
cancel_script = my.kwargs.get("cancel_script")
if cancel_script:
cancel_button = ActionButtonWdg(title="Cancel")
cancel_button.add_style("float: left")
cancel_button.add_behavior({
'type': "click_up",
'cbjs_action': cancel_script
})
button_div.add(cancel_button)
create_button.add_style("margin-right: 15px")
create_button.add_style("margin-left: 75px")
button_div.add("<br clear='all'/>")
last_page.add(button_div)
return last_page
示例10: get_display
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_behavior [as 别名]
def get_display(my):
search_key = ''
sobj = my.get_current_sobject()
top = DivWdg()
top.add_style("padding-top: 5px")
span = ActionButtonWdg(title="Email Test")
#span = ProdIconButtonWdg('Email Test')
top.add(span)
span.add_behavior(my.get_behavior(sobj))
return top
示例11: get_add_chat_wdg
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_behavior [as 别名]
def get_add_chat_wdg(my):
div = DivWdg()
div.add_border()
div.add_style("padding: 20px")
div.add_class("spt_add_chat_top")
table = Table()
table.add_style("width: auto")
div.add(table)
table.add_row()
text = TextInputWdg(title="user", icon="USER_ADD")
table.add_cell(text)
text.add_class("spt_add_chat_user")
add_button = ActionButtonWdg(title="Start Chat")
table.add_cell(add_button)
add_button.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_add_chat_top");
var el = top.getElement(".spt_add_chat_user");
var user = el.value;
if (!user) {
alert("Specify a valid user to chat with");
return;
}
// new chat
var server = TacticServerStub.get();
var category = "chat";
var class_name = 'tactic.ui.app.ChatCmd';
var kwargs = {
users: [user]
}
server.execute_cmd(class_name, kwargs);
spt.panel.refresh(bvr.src_el);
'''
} )
return div
示例12: get_display
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_behavior [as 别名]
def get_display(my):
alias = my.kwargs.get("alias")
div = DivWdg()
div.add_style("padding: 15px")
div.add_style("margin: 10px")
div.add_border()
div.add_color("background", "background", -5)
div.add_style("text-align: center")
div.add_style("font-weight: bold")
icon = IconWdg("WARNING", IconWdg.HELP_MISSING)
div.add(icon)
div.add("Add custom documentation page by clicking the Create button")
from tactic.ui.widget import ActionButtonWdg
button = ActionButtonWdg(title="Create", tip="Create docs for this view")
div.add(button)
button.add_style("margin-right: auto")
button.add_style("margin-left: auto")
button.add_style("margin-top: 15px")
button.add_style("margin-bottom: 15px")
# FIXME: copied code from above
button.add_behavior(
{
"type": "click_up",
"cbjs_action": """
spt.tab.set_main_body_tab();
var class_name = 'tactic.ui.app.HelpEditWdg';
var element_name = spt.help.get_view();
if (!element_name) {
element_name = "default";
}
var kwargs = {
view: element_name
}
spt.tab.add_new("help_edit", "Help Edit", class_name, kwargs);
""",
}
)
return div
示例13: get_search_wdg
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_behavior [as 别名]
def get_search_wdg(my):
search_div = DivWdg()
if my.kwargs.get('run_search_bvr'):
run_search_bvr = my.kwargs.get('run_search_bvr')
else:
run_search_bvr = {
'type': 'click_up',
'cbjs_action': 'spt.dg_table.search_cbk(evt, bvr)',
'new_search': True,
'panel_id': my.prefix
}
button = ActionButtonWdg(title='Search', tip='Run search with this criteria' )
search_div.add(button)
#button.add_style("margin-top: -7px")
button.add_behavior( run_search_bvr )
return search_div
示例14: get_save_button
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_behavior [as 别名]
def get_save_button(my,checkin_keys):
save_button = ActionButtonWdg(title="Save >>", tip="Save configuration and start using TACTIC")
save_button.add_style("float: right")
save_button.add_behavior( {
'type': 'click_up',
'os' : os.name,
'checkin_options':checkin_keys,
'cbjs_action': '''
spt.app_busy.show("Saving configuration. Please wait...")
var top = bvr.src_el.getParent(".spt_db_config_top");
var values = spt.api.Utility.get_input_values(top, null, false);
var class_name = 'tactic.ui.startup.DbConfigSaveCbk';
var server = TacticServerStub.get();
var kwargs = {checkin_options:bvr.checkin_options};
var ret_val = server.execute_cmd(class_name, kwargs, values);
var info = ret_val.info;
// This means TACTIC was restarted
if (typeof(info) == 'undefined' || bvr.os == 'nt' ) {
spt.app_busy.show("Restarting TACTIC ...");
var id = setInterval( function() {
var ping_rtn = server.ping();
if (ping_rtn) {
window.location = '/tactic';
clearInterval(id);
}
}, 5000 );
}
else if (info.error) {
spt.alert(info.error);
}
else {
window.location = '/tactic';
}
'''
} )
return save_button
示例15: handle_sidebar_clear
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_behavior [as 别名]
def handle_sidebar_clear(self, top):
top.add(DivWdg('Clear Side Bar Cache ', css='spt_info_title'))
table = Table()
table.add_color("color", "color")
table.add_style("margin: 10px")
top.add(table)
table.add_row()
td = table.add_cell("Clear the Side Bar Cache for all users")
td.add_style("width: 250px")
button = ActionButtonWdg(title='Run')
table.add_cell(button)
button.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
try {
var s = TacticServerStub.get();
s.execute_cmd('tactic.ui.app.ClearSideBarCache');
} catch(e) {
spt.alert(spt.exception.handler(e));
}
spt.info('Side Bar cache cleared.')
'''
})