本文整理汇总了Python中tactic.ui.container.Menu类的典型用法代码示例。如果您正苦于以下问题:Python Menu类的具体用法?Python Menu怎么用?Python Menu使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Menu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_context_menu
def get_context_menu(my):
menu = Menu(width=180)
menu.set_allow_icons(False)
menu_item = MenuItem(type='title', label='Actions')
menu.add(menu_item)
menu_item = MenuItem(type='action', label='Remove Share')
menu.add(menu_item)
menu_item.add_behavior({
'type': 'click_up',
'cbjs_action': '''
if (!confirm("Delete share?") ) {
return;
}
var activator = spt.smenu.get_activator(bvr);
var code = activator.getAttribute("spt_share_code");
var class_name = 'tactic.ui.startup.ShareItemCbk';
var kwargs = {
'action': 'delete',
'code': code
};
var server = TacticServerStub.get();
server.execute_cmd(class_name, kwargs);
var top = activator.getParent(".spt_share_top");
spt.panel.refresh(top);
'''
})
return menu
示例2: get_extra_menu
def get_extra_menu(my):
menu = Menu(width=180)
menu.set_allow_icons(False)
menu_item = MenuItem(type='title', label='Actions')
menu.add(menu_item)
menu_item = MenuItem(type='action', label='Edit Tab Config')
menu_item.add_behavior( {
'cbjs_action': '''
var activator = spt.smenu.get_activator(bvr);
spt.tab.top = activator.getParent(".spt_tab_top");
var element_name = 'edit_tab_config';
var title = 'Edit Tab Config';
var class_name = 'tactic.ui.manager.ViewManagerWdg';
var kwargs = {
search_type: 'prod/asset',
view: 'tab_config_model'
}
spt.tab.add_new(element_name, title, class_name, kwargs);
'''
} )
menu.add(menu_item)
return menu
示例3: get_test_context_menu
def get_test_context_menu(my):
menu = Menu(width=180)
menu.set_allow_icons(False)
menu_item = MenuItem(type="title", label="Actions")
menu.add(menu_item)
menu_item = MenuItem(type="action", label="Refresh")
menu.add(menu_item)
menu_item.add_behavior(
{
"type": "click_up",
"view": my.view,
"cbjs_action": """
var activator = spt.smenu.get_activator(bvr);
var top = activator.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);
""",
}
)
menu_item = MenuItem(type="action", label="Edit")
menu.add(menu_item)
menu_item.add_behavior(
{
"type": "click_up",
"view": my.view,
"cbjs_action": """
var activator = spt.smenu.get_activator(bvr);
var popup_top = activator.getParent(".spt_popup");
var top = popup_top.top;
if (top) {
top.setAttribute("spt_view", bvr.view);
spt.app_busy.show("Loading view: " + bvr.view);
spt.panel.refresh(top);
spt.app_busy.hide();
}
""",
}
)
return menu
示例4: get_test_context_menu
def get_test_context_menu(my):
menu = Menu(width=180)
menu.set_allow_icons(False)
menu_item = MenuItem(type='title', label='Actions')
menu.add(menu_item)
menu_item = MenuItem(type='action', label='Refresh')
menu.add(menu_item)
menu_item.add_behavior( {
'type': 'click_up',
'view': my.view,
'cbjs_action': '''
var activator = spt.smenu.get_activator(bvr);
var top = activator.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);
'''
} )
menu_item = MenuItem(type='action', label='Edit')
menu.add(menu_item)
menu_item.add_behavior( {
'type': 'click_up',
'view': my.view,
'cbjs_action': '''
var activator = spt.smenu.get_activator(bvr);
var popup_top = activator.getParent(".spt_popup");
var top = popup_top.top;
if (top) {
top.setAttribute("spt_view", bvr.view);
spt.app_busy.show("Loading view: " + bvr.view);
spt.panel.refresh(top);
spt.app_busy.hide();
}
'''
} )
return menu
示例5: get_node_context_menu
def get_node_context_menu(my):
menu = Menu(width=180)
menu.set_allow_icons(False)
menu.set_setup_cbfn( 'spt.dg_table.smenu_ctx.setup_cbk' )
menu_item = MenuItem(type='title', label='Actions')
menu.add(menu_item)
menu_item = MenuItem(type='action', label='Load Detail Report')
menu_item.add_behavior( {
'cbjs_action': '''
var node = spt.smenu.get_activator(bvr);
var name = node.getAttribute("spt_element_name");
var top = node.getParent(".spt_detail_top");
spt.tab.top = top.getElement(".spt_tab_top");
var search_key = top.getAttribute("spt_parent_key");
if (!search_key) {
search_key = top.getAttribute("spt_search_key");
}
var class_name = 'tactic.ui.tools.sobject_wdg.SObjectSingleProcessDetailWdg';
var kwargs = {
search_key: search_key,
process: name
}
var title = "Detail ["+name+"]";
var element_name = "detail_"+name;
spt.tab.add_new(element_name, title, class_name, kwargs);
'''
} )
menu.add(menu_item)
return menu
示例6: get_header_context_menu
def get_header_context_menu(my):
menu = Menu(width=180)
menu.set_allow_icons(False)
menu.set_setup_cbfn( 'spt.dg_table.smenu_ctx.setup_cbk' )
menu_item = MenuItem(type='title', label='Actions')
menu.add(menu_item)
menu_item = MenuItem(type='action', label='Edit Column Definition')
menu_item.add_behavior( {
'args' : {
'search_type': my.search_type,
'options': {
'class_name': 'tactic.ui.manager.ElementDefinitionWdg',
'popup_id': 'edit_column_defn_wdg',
'title': 'Edit Column Definition'
}
},
'cbjs_action': '''
spt.alert("Not yet implemented");
return
var activator = spt.smenu.get_activator(bvr);
bvr.args.element_name = activator.getProperty("spt_element_name");
bvr.args.view = activator.getAttribute('spt_view');
var popup = spt.popup.get_widget(evt,bvr);
popup.activator = activator;
'''
} )
menu.add(menu_item)
return menu
示例7: get_text_new_context_menu
def get_text_new_context_menu(self):
search_type_obj = SearchType.get(self.search_type)
title = search_type_obj.get_title()
menu = Menu(width=180)
menu.set_allow_icons(False)
menu_item = MenuItem(type='title', label='Actions')
menu.add(menu_item)
menu_item = MenuItem(type='action', label="Update line")
menu.add(menu_item)
menu_item.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
var activator = spt.smenu.get_activator(bvr);
var line_el = activator.getParent(".spt_new_line");
var prev_line_el = line_el.getPrevious(".spt_line");
prev_line_el.setStyle("border", "solid 1px red");
var content = prev_line_el.getElement(".spt_line_content");
alert(content.innerHTML);
var prev_line_el = prev_line_el.getPrevious(".spt_line");
prev_line_el.setStyle("border", "solid 1px red");
var next_line_el = line_el.getNext(".spt_line");
next_line_el.setStyle("border", "solid 1px red");
var next_line_el = next_line_el.getNext(".spt_line");
next_line_el.setStyle("border", "solid 1px red");
'''
} )
return menu
示例8: get_gear_menu
def get_gear_menu(my):
top = DivWdg()
# FIXME: the gear menu widget should be here
from tactic.ui.container import GearMenuWdg, Menu, MenuItem
menu = Menu(width=180)
menu_item = MenuItem(type="title", label="Actions")
menu.add(menu_item)
# create a new element
menu_item = MenuItem(type="action", label="New Element")
behavior = {
"options": {"is_insert": "true", "search_type": my.search_type, "view": my.view},
"cbjs_action": """
var activator = spt.smenu.get_activator(bvr);
var top = activator.getParent(".spt_view_manager_top");
var detail_panel = top.getElement(".spt_view_manager_detail");
var class_name = 'tactic.ui.manager.ElementDefinitionWdg';
var options = bvr.options
var values = {};
spt.panel.load(detail_panel, class_name, options, values, false);
""",
}
menu_item.add_behavior(behavior)
menu.add(menu_item)
menu_item = MenuItem(type="separator")
menu.add(menu_item)
# Show preview of the view
menu_item = MenuItem(type="action", label="Show Preview")
behavior = {
"search_type": my.search_type,
"view": my.view,
"cbjs_action": """
var kwargs = {
search_type: bvr.search_type,
view: bvr.view
};
var title = "Search Type: [" + bvr.search_type + "], View [" + bvr.view + "]";
spt.panel.load_popup(title, 'tactic.ui.panel.ViewPanelWdg', kwargs);
""",
}
menu_item.add_behavior(behavior)
menu.add(menu_item)
# Show preview of the view
menu_item = MenuItem(type="action", label="Show Full XML Config")
behavior = {
"search_type": my.search_type,
"view": my.view,
"cbjs_action": """
var kwargs = {
search_type: 'config/widget_config',
view: 'table',
expression: "@SOBJECT(config/widget_config['search_type','"+bvr.search_type+"']['view','"+bvr.view+"'])",
filter: [{}]
};
var title = "Widget Config - ["+bvr.search_type+"] ["+bvr.view+"]";
spt.panel.load_popup(title, 'tactic.ui.panel.ViewPanelWdg', kwargs);
""",
}
menu_item.add_behavior(behavior)
menu.add(menu_item)
menu_item = MenuItem(type="separator")
menu.add(menu_item)
# New view popup
new_view_wdg = DivWdg()
new_view_wdg.add_class("spt_new_view")
new_view_wdg.add_style("display: none")
new_view_wdg.add_style("position: absolute")
new_view_wdg.add_color("background", "background")
new_view_wdg.add_style("z-index: 100")
new_view_wdg.add_border()
new_view_wdg.set_round_corners()
new_view_wdg.set_box_shadow()
new_view_wdg.add_style("padding: 30px")
new_view_wdg.add("New View Name: ")
new_view_text = TextWdg("new_view")
new_view_text.add_class("spt_new_view_text")
new_view_wdg.add(new_view_text)
new_view_wdg.add(HtmlElement.br(2))
# new_view_button = ProdIconButtonWdg('Save New View')
new_view_button = ActionButtonWdg(title="Save", tip="Save New View")
new_view_button.add_style("float: left")
new_view_wdg.add(new_view_button)
new_view_button.add_behavior(
{
"type": "click_up",
"search_type": my.search_type,
"cbjs_action": """
var top = bvr.src_el.getParent(".spt_view_manager_top");
#.........这里部分代码省略.........
示例9: get_menu
def get_menu(my):
menu = Menu(width=180)
menu_item = MenuItem(type='title', label='Actions')
menu.add(menu_item)
menu_item = MenuItem(type='action', label='View')
menu_item.add_behavior( {
'cbjs_action': '''
var activator = spt.smenu.get_activator(bvr);
var report_top = activator.getParent(".spt_report_top");
var kwargs = report_top.kwargs;
var class_name = report_top.class_name;
var element_name = report_top.element_name;
spt.tab.set_main_body_tab();
spt.tab.add_new(element_name, element_name, class_name, kwargs);
'''
} )
menu.add(menu_item)
menu_item = MenuItem(type='action', label='Show Definition')
menu_item.add_behavior( {
'cbjs_action': '''
var activator = spt.smenu.get_activator(bvr);
var report_top = activator.getParent(".spt_report_top");
var xml = report_top.xml;
console.log(xml);
alert(xml);
'''
} )
menu.add(menu_item)
menu_item = MenuItem(type='separator')
menu.add(menu_item)
menu_item = MenuItem(type='action', label='Add to Side Bar')
menu_item.add_behavior( {
'cbjs_action': '''
var activator = spt.smenu.get_activator(bvr);
var top = activator.getParent(".spt_tab_top");
spt.tab.top = top;
var header = activator;
var title = header.getAttribute("spt_title");
var report_top = activator.getParent(".spt_report_top");
var kwargs = report_top.kwargs;
var class_name = report_top.class_name;
var element_name = report_top.element_name;
var element_name = element_name.replace(/ /g, "_");
element_name = element_name.replace(/\//g, "_");
var kwargs = {
class_name: 'LinkWdg',
display_options: kwargs,
element_attrs: {
title: title
}
}
try {
spt.app_busy.show("Adding Side Bar Link ["+element_name+"]");
var server = TacticServerStub.get();
server.start({description:"Added Side Bar Link ["+element_name+"]"});
var info = server.add_config_element("SideBarWdg", "definition", element_name, kwargs);
var info = server.add_config_element("SideBarWdg", "project_view", element_name, {});
server.finish();
spt.panel.refresh("side_bar");
spt.app_busy.hide();
}
catch(e) {
server.abort();
alert(e);
spt.app_busy.hide();
throw(e);
}
'''
} )
menu.add(menu_item)
return menu
示例10: get_menu
def get_menu(self):
menu = Menu(width=180)
menu_item = MenuItem(type='title', label='Actions')
menu.add(menu_item)
menu_item = MenuItem(type='action', label='View')
menu_item.add_behavior( {
'cbjs_action': '''
var activator = spt.smenu.get_activator(bvr);
var report_top = activator.getParent(".spt_report_top");
var kwargs = report_top.kwargs;
var class_name = report_top.class_name;
var element_name = report_top.element_name;
spt.tab.set_main_body_tab();
spt.tab.add_new(element_name, element_name, class_name, kwargs);
'''
} )
menu.add(menu_item)
menu_item = MenuItem(type='action', label='Show Definition')
menu_item.add_behavior( {
'cbjs_action': '''
var activator = spt.smenu.get_activator(bvr);
var report_top = activator.getParent(".spt_report_top");
var xml = report_top.xml;
alert(xml);
'''
} )
menu.add(menu_item)
menu_item = MenuItem(type='separator')
menu.add(menu_item)
widget_def = '''
<element name='index' palette="BLACK">
<display class='tactic.ui.panel.CustomLayoutWdg'>
<view>VIEW</view>
</display>
</element>
'''
menu_item = MenuItem(type='action', label='Set as Project Theme')
menu_item.add_behavior( {
'type': 'click_up',
'widget_def': widget_def,
'cbjs_action': '''
var activator = spt.smenu.get_activator(bvr);
var report_top = activator.getParent(".spt_report_top");
var kwargs = report_top.kwargs;
var class_name = report_top.class_name;
var element_name = report_top.element_name;
var view = report_top.view;
if (!confirm("Change theme to ["+view+"]?")) {
return;
}
var widget_def = bvr.widget_def;
widget_def = widget_def.replace(/VIEW/, view);
var data = {
url: '/index',
description: 'Index Page',
widget: widget_def
}
var server = TacticServerStub.get();
var url = server.eval("@SOBJECT(config/url['url','/index'])", {single:true});
if (url) {
server.update(url, data);
}
else {
server.insert('config/url', data);
}
'''
} )
menu.add(menu_item)
return menu
示例11: add_top_behaviors
#.........这里部分代码省略.........
var last_index;
var cur_index;
for (var i = 0; i < rows.length; i++) {
if (rows[i] == last_selected) {
last_index = i;
}
if (rows[i] == bvr.src_el) {
cur_index = i;
}
}
var start_index;
var end_index;
if (last_index < cur_index) {
start_index = last_index + 1;
end_index = cur_index ;
}
else {
start_index = cur_index;
end_index = last_index -1 ;
}
for (var i = start_index; i < end_index+1; i++) {
spt.checkin_list.select(rows[i]);
}
spt.checkin_list.last_selected = bvr.src_el;
'''
} )
# add a top menu
menu = Menu(width=180)
my.menu = menu
menu_item = MenuItem(type='title', label='Actions')
menu.add(menu_item)
#menu_item = MenuItem(type='action', label='Revert to Latest')
#menu.add(menu_item)
menu_item = MenuItem(type='action', label='Open File')
menu.add(menu_item)
menu_item.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
var applet = spt.Applet.get();
var activator = spt.smenu.get_activator(bvr);
var path = activator.getAttribute("spt_path");
applet.open_file(path);
'''
} )
menu_item = MenuItem(type='action', label='Open Containing Folder')
menu.add(menu_item)
menu_item.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
var applet = spt.Applet.get();
示例12: add_base_dir_behaviors
def add_base_dir_behaviors(my, div, base_dir):
# add tooltip
div.add_attr('title','This is the sandbox folder. Double-click to open and right-click for more options.')
# add a top menu
menu = Menu(width=180)
menu_item = MenuItem(type='title', label='Actions')
menu.add(menu_item)
menu_item = MenuItem(type='action', label='Explore sandbox folder')
menu.add(menu_item)
menu_item.add_behavior( {
'type': 'click_up',
'base_dir': base_dir,
'cbjs_action': '''
var applet = spt.Applet.get();
var activator = spt.smenu.get_activator(bvr);
var path = bvr.base_dir;
applet.open_file(path);
'''
} )
menu_item = MenuItem(type='action', label='Browse for sandbox folder')
menu.add(menu_item)
# FIXME: this code is identical to the one in checkin_wdg.py
menu_item.add_behavior( {
'type': 'click_up',
'base_dir': base_dir,
'cbjs_action': '''
var current_dir = bvr.base_dir;
var applet = spt.Applet.get();
var file_paths = applet.open_file_browser(current_dir);
// take the first one make sure it is a directory
var dir = file_paths[0];
if (!applet.is_dir(dir)) {
spt.alert("Please Select a Folder");
return;
}
dir = dir.replace(/\\\\/g, "/");
var activator = spt.smenu.get_activator(bvr);
var top = activator.getParent(".spt_checkin_top");
top.setAttribute("spt_sandbox_dir", dir);
spt.panel.refresh(top);
'''
} )
menu_item = MenuItem(type='action', label='Download from clipboard')
menu.add(menu_item)
menu_item.add_behavior( {
'type': 'click_up',
'base_dir': base_dir,
'cbjs_action': '''
var current_dir = bvr.base_dir;
var server = TacticServerStub.get();
var base = spt.Environment.get().get_server_url();
var user = spt.Environment.get().get_user();
var expr = "@SOBJECT(sthpw/clipboard['login','"+user+"'].sthpw/file)";
var items = server.eval(expr);
var applet = spt.Applet.get();
var urls = [];
for (var i = 0; i < items.length; i++) {
var url = base + "/assets/" + items[i].relative_dir + "/" + items[i].file_name;
var file_name = items[i].file_name;
applet.download_file(url, current_dir + "/" + file_name);
}
var activator = spt.smenu.get_activator(bvr);
var top = activator.getParent(".spt_checkin_top");
spt.panel.refresh(top);
'''
} )
menus_in = {
'SANDBOX_MENU_CTX': menu,
}
SmartMenu.attach_smart_context_menu( div, menus_in, False )
SmartMenu.assign_as_local_activator( div, 'SANDBOX_MENU_CTX' )
super(CheckinDirListWdg, my).add_base_dir_behaviors(div,base_dir)
示例13: get_add_menu
def get_add_menu(my):
from tactic.ui.container import Menu, MenuItem
menu = Menu(width=180)
menu.set_allow_icons(False)
# menu.set_setup_cbfn( 'spt.dg_table.smenu_ctx.setup_cbk' )
menu_item = MenuItem(type="title", label="Add Item")
menu.add(menu_item)
menu_item = MenuItem(type="action", label="Label")
menu_item.add_behavior({"element_name": "label", "cbjs_action": my.get_add_bvr_action()})
menu.add(menu_item)
menu_item = MenuItem(type="action", label="Text")
menu_item.add_behavior({"element_name": "text", "cbjs_action": my.get_add_bvr_action()})
menu.add(menu_item)
menu_item = MenuItem(type="action", label="TextArea")
menu_item.add_behavior({"element_name": "textarea", "cbjs_action": my.get_add_bvr_action()})
menu.add(menu_item)
return menu
示例14: add_top_behaviors
#.........这里部分代码省略.........
var last_index;
var cur_index;
for (var i = 0; i < rows.length; i++) {
if (rows[i] == last_selected) {
last_index = i;
}
if (rows[i] == bvr.src_el) {
cur_index = i;
}
}
var start_index;
var end_index;
if (last_index < cur_index) {
start_index = last_index + 1;
end_index = cur_index ;
}
else {
start_index = cur_index;
end_index = last_index -1 ;
}
for (var i = start_index; i < end_index+1; i++) {
spt.checkin_list.select(rows[i]);
}
spt.checkin_list.last_selected = bvr.src_el;
'''
} )
# add a top menu
menu = Menu(width=180)
self.menu = menu
menu_item = MenuItem(type='title', label='Actions')
menu.add(menu_item)
#menu_item = MenuItem(type='action', label='Revert to Latest')
#menu.add(menu_item)
menu_item = MenuItem(type='action', label='Open File')
menu.add(menu_item)
menu_item.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
var applet = spt.Applet.get();
var activator = spt.smenu.get_activator(bvr);
var path = activator.getAttribute("spt_path");
applet.open_file(path);
'''
} )
menu_item = MenuItem(type='action', label='Open Containing Folder')
menu.add(menu_item)
menu_item.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
var applet = spt.Applet.get();
示例15: get_text_context_menu
def get_text_context_menu(self):
search_type_obj = SearchType.get(self.search_type)
title = search_type_obj.get_title()
menu = Menu(width=180)
menu.set_allow_icons(False)
menu_item = MenuItem(type='title', label='Actions')
menu.add(menu_item)
label = 'Create New "%s"' % title
menu_item = MenuItem(type='action', label=label)
menu.add(menu_item)
menu_item.add_behavior( {
'type': 'click_up',
'search_type': self.search_type,
'column': self.column,
'cbjs_action': r'''
var activator = spt.smenu.get_activator(bvr);
var selection = spt.document.selected_text;
if (!selection) {
alert("Nothing selected");
return;
}
spt.app_busy.show("Adding " + bvr.search_type);
var data = {}
data[bvr.column] = selection;
var server = TacticServerStub.get();
server.insert(bvr.search_type, data);
spt.app_busy.hide();
'''
} )
label = '%s (Detail)' % label
menu_item = MenuItem(type='action', label=label)
menu.add(menu_item)
menu_item.add_behavior( {
'type': 'click_up',
'search_type': self.search_type,
'cbjs_action': r'''
var activator = spt.smenu.get_activator(bvr);
var selection = spt.document.selected_text;
if (!selection) {
alert("Nothing selected");
return;
}
var class_name = 'tactic.ui.panel.EditWdg';
var kwargs = {
search_type: bvr.search_type,
default: {
description: selection
}
}
spt.panel.load_popup("Add", class_name, kwargs);
'''
} )
menu_item = MenuItem(type='separator')
menu.add(menu_item)
menu_item = MenuItem(type='action', label='Search')
menu.add(menu_item)
menu_item.add_behavior( {
'type': 'click_up',
'search_type': self.search_type,
'cbjs_action': r'''
var activator = spt.smenu.get_activator(bvr);
var selection = spt.document.selected_text;
if (!selection) {
alert("Nothing selected");
return;
}
var top = activator.getParent(".spt_document_top");
var data_el = top.getElement(".spt_document_data");
spt.app_busy.show("Searching " + selection);
var class_name = 'tactic.ui.panel.ViewPanelWdg';
var kwargs = {
'search_type': bvr.search_type,
'keywords': selection,
'simple_search_view': 'simple_filter',
#.........这里部分代码省略.........