当前位置: 首页>>代码示例>>Python>>正文


Python container.MenuItem类代码示例

本文整理汇总了Python中tactic.ui.container.MenuItem的典型用法代码示例。如果您正苦于以下问题:Python MenuItem类的具体用法?Python MenuItem怎么用?Python MenuItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MenuItem类的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
开发者ID:blezek,项目名称:TACTIC,代码行数:35,代码来源:share_wdg.py

示例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
开发者ID:davidsouthpaw,项目名称:TACTIC,代码行数:28,代码来源:sobject_wdg.py

示例3: get_add_menu

    def get_add_menu(self):
        from tactic.ui.container import Menu, MenuItem
        menu = Menu(width=180)
        menu.set_allow_icons(False)
        #menu.set_setup_cbfn( 'spt.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': self.get_add_bvr_action()
        } )
        menu.add(menu_item)

        menu_item = MenuItem(type='action', label='Text')
        menu_item.add_behavior( {
            'element_name': 'text',
            'cbjs_action': self.get_add_bvr_action()
        } )
        menu.add(menu_item)


        menu_item = MenuItem(type='action', label='TextArea')
        menu_item.add_behavior( {
            'element_name': 'textarea',
            'cbjs_action': self.get_add_bvr_action()
        } )
        menu.add(menu_item)


        return menu
开发者ID:mincau,项目名称:TACTIC,代码行数:34,代码来源:freeform_layout_wdg.py

示例4: add_project_menu

        def add_project_menu(menu, project):
            project_code = project.get_code()
            menu_item = MenuItem(type='action', label=project.get_value("title"))

            web = WebContainer.get_web()
            browser = web.get_browser()

            if browser != 'Qt':

                menu_item.add_behavior( {
                'type': 'click_up',
                'project_code': project_code,
                'cbjs_action': '''
                window.open('/tactic/%s/');
                ''' % project_code
                } )

            else:
                menu_item.add_behavior( {
                'project_code': project_code,
                'cbjs_action': '''
                spt.app_busy.show("Jumping to Project ["+bvr.project_code+"]", "");
                document.location = '/tactic/%s/';
                ''' % project_code
                } )

            menu.add(menu_item)
开发者ID:hellios78,项目名称:TACTIC,代码行数:27,代码来源:page_header_wdg.py

示例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
开发者ID:davidsouthpaw,项目名称:TACTIC,代码行数:40,代码来源:sobject_wdg.py

示例6: 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
开发者ID:mincau,项目名称:TACTIC,代码行数:39,代码来源:doc_tool_wdg.py

示例7: 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
开发者ID:hellios78,项目名称:TACTIC,代码行数:23,代码来源:freeform_layout_wdg.py

示例8: 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
开发者ID:funic,项目名称:TACTIC,代码行数:36,代码来源:edit_wdg.py

示例9: 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
开发者ID:hellios78,项目名称:TACTIC,代码行数:48,代码来源:custom_layout_wdg.py

示例10: 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
开发者ID:southpawtech,项目名称:TACTIC-DEV,代码行数:45,代码来源:custom_layout_wdg.py

示例11: add_top_behaviors

    def add_top_behaviors(my, top):

        super(ScmDirListWdg, my).add_top_behaviors(top)

        changelist = WidgetSettings.get_value_by_key("current_changelist")

        menu_item = MenuItem(type='title', label="Perforce Actions")
        my.menu.add(menu_item)

        menu_item = MenuItem(type='action', label='Add To Changelist [%s]' % changelist)
        my.menu.add(menu_item)
        menu_item.add_behavior( {
            'type': 'click_up',
            'changelist': changelist,
            'cbjs_action': '''
            var activator = spt.smenu.get_activator(bvr);

            var paths = spt.checkin.get_selected_paths();
            if (paths.length == 0) {
                var path = activator.getAttribute("spt_path");
                paths = [path]
            }

            var changelist = bvr.changelist;

            // TODO: optimize this to call on once by passing in the array
            // of paths
            for (var i = 0; i < paths.length; i++) {
                var path = paths[i];
                spt.scm.run("add", [path, changelist]);
            }
            var top = activator.getParent(".spt_checkin_top");
            spt.panel.refresh(top);
            '''
        } )


        menu_item = MenuItem(type='action', label='Make Editable')
        my.menu.add(menu_item)
        menu_item.add_behavior( {
            'type': 'click_up',
            'changelist': changelist,
            'cbjs_action': '''
            var activator = spt.smenu.get_activator(bvr);

            var paths = spt.checkin.get_selected_paths();
            if (paths.length == 0) {
                var path = activator.getAttribute("spt_path");
                paths = [path]
            }

            // TODO: optimize this to call on once by passing in the array
            // of paths
            for (var i = 0; i < paths.length; i++) {
                var path = paths[i];
                spt.scm.run("edit", [path, bvr.changelist]);
            }

            var top = activator.getParent(".spt_checkin_top");
            spt.panel.refresh(top);

            '''
        } )


        menu_item = MenuItem(type='action', label='Revert File')
        my.menu.add(menu_item)
        menu_item.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var activator = spt.smenu.get_activator(bvr);
            var path = activator.getAttribute("spt_path");
            try {
                spt.scm.revert(path);
                var top = activator.getParent(".spt_checkin_top");
                spt.panel.refresh(top);
            }
            catch (e) {
                spt.scm.handle_error(e);
            }

            '''
        } )



        menu_item = MenuItem(type='action', label='File Log')
        my.menu.add(menu_item)
        menu_item.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var activator = spt.smenu.get_activator(bvr);
            var path = activator.getAttribute("spt_path");
            try {
                var file_logs = spt.scm.file_log(path);

                var class_name = 'tactic.ui.checkin.ScmCheckinHistoryWdg';
                var kwargs = {
                    'file_logs': file_logs
                }
#.........这里部分代码省略.........
开发者ID:blezek,项目名称:TACTIC,代码行数:101,代码来源:scm_dir_list_wdg.py

示例12: 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',
#.........这里部分代码省略.........
开发者ID:mincau,项目名称:TACTIC,代码行数:101,代码来源:doc_tool_wdg.py

示例13: 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");
#.........这里部分代码省略.........
开发者ID:hellios78,项目名称:TACTIC,代码行数:101,代码来源:view_manager_wdg.py

示例14: 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
开发者ID:0-T-0,项目名称:TACTIC,代码行数:89,代码来源:reports_wdg.py

示例15: 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
开发者ID:mincau,项目名称:TACTIC,代码行数:88,代码来源:themes_wdg.py


注:本文中的tactic.ui.container.MenuItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。