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


Python Menu.get_list方法代码示例

本文整理汇总了Python中menu.Menu.get_list方法的典型用法代码示例。如果您正苦于以下问题:Python Menu.get_list方法的具体用法?Python Menu.get_list怎么用?Python Menu.get_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在menu.Menu的用法示例。


在下文中一共展示了Menu.get_list方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: BaseApp

# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import get_list [as 别名]

#.........这里部分代码省略.........
            self.languages = self.app.config['LANGUAGES']
        else:
            self.languages = {
                'en': {'flag':'gb', 'name':'English'},
                }
    
    def _add_global_filters(self):
        self.template_filters = TemplateFilters(self.app, self.sm)

    def _add_global_static(self):
        bp = Blueprint('baseapp', __name__, url_prefix='/static',
                template_folder='templates', static_folder = self.static_folder, static_url_path = self.static_url_path)
        self.app.register_blueprint(bp)

    def _add_admin_views(self):
        self.indexview = self.indexview()
        self.add_view_no_menu(self.indexview)
        self.add_view_no_menu(LocaleView())
        self.sm.register_views(self)

    def _init_view_session(self, baseview_class):
        if baseview_class.datamodel.session == None:
            baseview_class.datamodel.session = self.db.session
        return baseview_class()
    
    def _add_permissions_menu(self, name):
        try:
            self.sm.add_permissions_menu(name)
        except:
            print "Add Permission on Menu Error: DB not created"
    
    
    def _add_menu_permissions(self):
        for category in self.menu.get_list():
            self._add_permissions_menu(category.name)
            for item in category.childs:
                self._add_permissions_menu(item.name)
    
    def add_view(self, baseview, name, href = "", icon = "", category = ""):
        """
            Add your views associated with menus using this method.
            
            :param baseview:
                A BaseView type class instantiated.
            :param name:
                The string name that will be displayed on the menu.
            :param href:
                Override the generated href for the menu.
            :param icon:
                Bootstrap included icon name
            :param category:
                The menu category where the menu will be included        
        """
        print "Registering:", category,".", name
        if baseview not in self.lst_baseview:
            baseview.baseapp = self
            self.lst_baseview.append(baseview)
            self.register_blueprint(baseview)
            self._add_permission(baseview)
        self.add_link(name = name, href = href, icon = icon, category = category, baseview = baseview)
        
    def add_link(self, name, href, icon = "", category = "", baseview = None):
        """
            Add your own links to menu using this method
            
            :param name:
开发者ID:Dorianux,项目名称:Flask-AppBuilder,代码行数:70,代码来源:baseapp.py

示例2: BaseApp

# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import get_list [as 别名]

#.........这里部分代码省略.........
        else:
            self.languages = {
                'en': {'flag': 'gb', 'name': 'English'},
            }

    def _add_global_filters(self):
        self.template_filters = TemplateFilters(self.app, self.sm)

    def _add_global_static(self):
        bp = Blueprint('baseapp', __name__, url_prefix='/static',
                       template_folder='templates', static_folder=self.static_folder,
                       static_url_path=self.static_url_path)
        self.app.register_blueprint(bp)

    def _add_admin_views(self):
        self.indexview = self.indexview()
        self.add_view_no_menu(self.indexview)
        self.bm.register_views(self)
        self.sm.register_views(self)

    def _init_view_session(self, baseview_class):
        if baseview_class.datamodel.session == None:
            baseview_class.datamodel.session = self.db.session
        return baseview_class()

    def _add_permissions_menu(self, name):
        try:
            self.sm.add_permissions_menu(name)
        except Exception as e:
            log.error("Add Permission on Menu Error: {0}".format(str(e)))


    def _add_menu_permissions(self):
        for category in self.menu.get_list():
            self._add_permissions_menu(category.name)
            for item in category.childs:
                self._add_permissions_menu(item.name)

    def add_view(self, baseview, name, href="", icon="", category=""):
        """
            Add your views associated with menus using this method.
            
            :param baseview:
                A BaseView type class instantiated.
            :param name:
                The string name that will be displayed on the menu.
            :param href:
                Override the generated href for the menu. if non provided default_view from view will be set as href.
            :param icon:
                Font-Awesome icon name, optional.
            :param category:
                The menu category where the menu will be included, if non provided the view will be acessible as a top menu.
                
            Examples::
            
                baseapp = BaseApp(app, db)
                # Register a view, rendering a top menu without icon
                baseapp.add_view(MyGeneralView, "My View")
                # Register a view, a submenu "Other View" from "Other" with a phone icon
                baseapp.add_view(MyOtherGeneralView, "Other View", icon='fa-phone', category="Others")
                # Add a link
                baseapp.add_link("google", href="www.google.com", icon = "fa-google-plus")
        """
        log.info("Registering class %s on menu %s.%s" % (baseview.__class__.__name__, category, name))
        if baseview not in self.baseviews:
            baseview.baseapp = self
开发者ID:iapilgrim,项目名称:Flask-AppBuilder,代码行数:70,代码来源:baseapp.py


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