本文整理汇总了Python中menu.Menu.add_item方法的典型用法代码示例。如果您正苦于以下问题:Python Menu.add_item方法的具体用法?Python Menu.add_item怎么用?Python Menu.add_item使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类menu.Menu
的用法示例。
在下文中一共展示了Menu.add_item方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ready
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import add_item [as 别名]
def ready(self):
# Add two items to our main menu
Menu.add_item("main", MenuItem("Informacje o koncie",reverse("am_userInfo"),weight=10,icon="tools"))
Menu.add_item("main", MenuItem("zmień dane",reverse("am_changeUserdata"),weight=20,icon="report"))
Menu.add_item("main", MenuItem("zmień hasło",reverse("am_changeUserpassword"),weight=30,icon="report"))
Menu.add_item("main", MenuItem("twoje ankiety",reverse("am_userSurveys"),weight=40,icon="report"))
Menu.add_item("main", MenuItem("statystyki i aktywność użytkownika",reverse("am_userActivity"),weight=50,icon="report"))
示例2: parse_menu
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import add_item [as 别名]
def parse_menu(self):
if self.is_parsed:
return self.menu
#self.diner = self.diner.lower()
#self.diner = self.diner.splitlines()
self.menu = self.menu.splitlines()
parsed_menu = Menu()
for menu_item in self.menu:
menu_item = menu_item[1:-1] # remove parenthases
menu_item = menu_item.split(',')
menu_item = Food(menu_item[0], menu_item[1], menu_item[2])
parsed_menu.add_item(menu_item)
self.is_parsed = True
self.menu = parsed_menu
return self.menu
示例3: setUp
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import add_item [as 别名]
def setUp(self):
"""
Build some menus for our tests
"""
self.kids3_2_desired_title = None
def kids3_2_title(request):
"Allow the title of kids3-2 to be changed"
if self.kids3_2_desired_title is not None:
return "-".join([request.path, self.kids3_2_desired_title])
return 'kids3-2'
def kids2_2_check(request):
"Hide kids2-2 whenever the request path ends with /hidden"
if request.path.endswith('/hidden'):
return False
return True
# Ensure we can pass children as tuples (or other iterables, like generators)
# Following the implementation of sorted children there was a bug reported due to children
# being passed as a tuple, which has no .sort method
# See: https://github.com/borgstrom/django-simple-menu/issues/38
def kids2():
"Generator for kids2"
class RepeatIterator(object):
"We need this to be reusable -- http://stackoverflow.com/a/1985733"
def __iter__(self):
yield MenuItem("kids2-1", "/parent2/kids2-1", weight=999)
yield MenuItem("kids2-2", "/kids2-2", check=kids2_2_check)
return RepeatIterator()
def kids3_1(request):
"Callable for kids3-1"
return [
MenuItem("kids3-1-1", "/parent3/kids3-1/kid1", exact_url=True),
]
kids3 = (
MenuItem("kids3-1", "/parent3/kids3-1", children=kids3_1),
MenuItem(kids3_2_title, "/parent3/kids3-2")
)
Menu.items = {}
Menu.sorted = {}
Menu.loaded = False
# add our items. because we set weight to 999 for parent 1 it will become the last child
# even though it's added first
Menu.add_item("test", MenuItem("Parent 1", "/parent1", weight=999))
Menu.add_item("test", MenuItem("Parent 2", "/parent2", children=kids2()))
Menu.add_item("test", MenuItem("Parent 3", "/parent3", children=kids3))
self.factory = RequestFactory()
示例4: setUp
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import add_item [as 别名]
def setUp(self):
kids2 = [
MenuItem("kids2-1", "/parent2/kids2-1"),
MenuItem("kids2-2", "/kids2-2")
]
kids3 = [
MenuItem("kids3-1", "/parent3/kids3-1")
]
Menu.items = {}
Menu.sorted = {}
Menu.loaded = False
Menu.add_item("test", MenuItem("Parent 1", "/parent1"))
Menu.add_item("test", MenuItem("Parent 2", "/parent2", children=kids2))
Menu.add_item("test", MenuItem("Parent 3", "/parent3", children=kids3))
self.factory = RequestFactory()
示例5: MenuItem
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import add_item [as 别名]
from django.core.urlresolvers import reverse
from menu import Menu, MenuItem
# Add two items to our main menu
Menu.add_item("sidebar", MenuItem("Messenger",
reverse('portal.portlets.messenger.views.index'),
weight=4,
icon="ios-chatbubble-outline"))
示例6: MenuItem
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import add_item [as 别名]
from menu import Menu, MenuItem
from django.core.urlresolvers import reverse
Menu.add_item( "mantis_main",
MenuItem("List, Filter & Search", "",
weight = 50,
children = (
MenuItem("Info Object List (generic filter)", reverse("url.dingos.list.infoobject.generic"), weight = 40 ),
MenuItem("Info Object List (filter by ID)", reverse("url.dingos.list.infoobject.by_id"), weight = 50 ),
MenuItem("Fact Search (simple)", reverse("url.dingos.search.fact.simple"), weight = 40 ),
MenuItem("Fact Search (unique)", reverse("url.dingos.search.fact.simple.unique"), weight = 40 ),
),
)
)
Menu.add_item( "mantis_main",
MenuItem("Saved Filters/Searches", "",
weight = 50,
children = ()
)
)
def user_name(request):
if request.user.is_authenticated():
return request.user.username
else:
示例7: MenuItem
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import add_item [as 别名]
from django.core.urlresolvers import reverse
from menu import Menu, MenuItem
Menu.add_item('main', MenuItem('Organization Vehicles',
reverse('organization.organizationvehicle_list'),
weight=3,
check=lambda request: request.user.has_perm('organization.organizationvehicle_list')
))
Menu.add_item('main', MenuItem('Organization Drivers',
reverse('organization.organizationdriver_list'),
weight=4,
check=lambda request: request.user.has_perm('organization.organizationdriver_list')
))
示例8: MenuItem
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import add_item [as 别名]
from menu import Menu, MenuItem
from django.core.urlresolvers import reverse
Menu.add_item("main", MenuItem("Tools",
reverse("hl.views.add_hadoop_analy_dit"),
weight=10,
icon="tools"))
Menu.add_item("main", MenuItem("Reports",
reverse("hl.views.add_hadoop_analy_dit"),
weight=20,
icon="report"))
# Define children for the my account menu
myaccount_children = (
MenuItem("Edit Profile",
reverse("hl.views.add_hadoop_analy_dit"),
weight=10,
icon="user"),
MenuItem("Admin",
reverse("admin:index"),
weight=80,
separator=True,
check=lambda request: request.user.is_superuser),
MenuItem("Logout",
reverse("accounts.views.logout"),
weight=90,
separator=True,
icon="user"),
)
示例9: profile_title
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import add_item [as 别名]
from django.core.urlresolvers import reverse
from admin_tools.menu.models import *
from menu import Menu, MenuItem
def profile_title(request):
"""
Return a personalized title for our profile menu item
"""
# we don't need to check if the user is authenticated because our menu
# item will have a check that does that for us
name = request.user.get_full_name() or request.user
return "%s's Profile" % name
Menu.add_item("main", MenuItem("Accounts Index",
reverse("accounts.views.index")))
# this item will be shown to users who are not logged in
Menu.add_item("user", MenuItem("Login",
reverse('django.contrib.auth.views.login'),
check=lambda request: not request.user.is_authenticated()))
# this will only be shown to logged in users and also demonstrates how to use
# a callable for the title to return a customized title for each request
Menu.add_item("user", MenuItem(profile_title,
reverse('accounts.views.profile'),
check=lambda request: request.user.is_authenticated()))
Menu.add_item("user", MenuItem("Logout",
reverse('django.contrib.auth.views.logout'),
check=lambda request: request.user.is_authenticated()))
示例10: MenuItem
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import add_item [as 别名]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from menu import Menu, MenuItem
Menu.add_item("main", MenuItem(title="首页", url="/", slug="home"))
Menu.add_item("main", MenuItem(title="影视大全", url='http://movie.obtainfo.com/', slug="collect"))
Menu.add_item("main", MenuItem("每日推荐", '/categories/day/', slug="day"))
Menu.add_item("main", MenuItem("电影精选", '/categories/selection/', slug="selection"))
Menu.add_item("main", MenuItem("画质预览", '/categories/preview/', slug="preview"))
Menu.add_item("main", MenuItem("学习园地", '/categories/manual/', slug="manual"))
Menu.add_item("main", MenuItem("音乐欣赏", '/categories/music/', slug="music"))
Menu.add_item("main", MenuItem("常用软件", '/categories/soft/', slug="soft"))
Menu.add_item("main", MenuItem("技术博客", '/categories/techblog/', slug="techblog"))
Menu.add_item("main", MenuItem("关于", '/flatpages/about/', slug="about"))
Menu.add_item("main", MenuItem("联系",'/flatpages/contact/', slug="contact"))
Menu.add_item("main", MenuItem("留言 / 求片", '/flatpages/guestbook/', slug="guestbook"))
示例11: MenuItem
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import add_item [as 别名]
from menu import Menu, MenuItem
from django.core.urlresolvers import reverse
Menu.add_item( "mantis_main",
MenuItem("List & Filter", "",
weight = 50,
children = (
MenuItem("Info Object List (generic filter)", reverse("url.dingos.list.infoobject.generic"), weight = 40 ),
MenuItem("Info Object List (filter by ID)", reverse("url.dingos.list.infoobject.by_id"), weight = 50 ),
),
)
)
Menu.add_item( "mantis_main",
MenuItem("Search", "",
weight = 50,
children = (
MenuItem("Fact Search (simple)", reverse("url.dingos.search.fact.simple"), weight = 40 ),
),
)
)
示例12: MenuItem
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import add_item [as 别名]
MenuItem(
title=activity.title,
url=reverse("activity", args=[activity.id]),
weight=10,
icon="user"
),
)
lesson_items.append(
MenuItem(
title=lesson.title,
url=reverse("index"),
weight=10,
icon="user",
children=(
activities_items
)
),
)
Menu.add_item(
"unit",
MenuItem(
title=unit.title,
url=reverse("index"),
weight=10,
icon="tools",
children=(
lesson_items
)
)
)
示例13: MenuItem
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import add_item [as 别名]
from menu import Menu, MenuItem
from django.core.urlresolvers import reverse
Menu.add_item("main", MenuItem("Home",
reverse("events.home")))
示例14: profile_title
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import add_item [as 别名]
from menu import Menu, MenuItem
def profile_title(request):
"""
Return a personalized title for our profile menu item
"""
# we don't need to check if the user is authenticated because our menu
# item will have a check that does that for us
name = request.user.get_full_name() or request.user
return "%s's Profile" % name
Menu.add_item("main", MenuItem("Home", reverse("Home")))
Menu.add_item("main", MenuItem("Product", reverse("Product")))
Menu.add_item("main", MenuItem("Services", reverse("Services")))
Menu.add_item("main", MenuItem("About", reverse("About")))
Menu.add_item("main", MenuItem("Contact", reverse("Contact")))
# this item will be shown to users who are not logged in
Menu.add_item("main", MenuItem("Login", reverse("Login"), check=lambda request: not request.user.is_authenticated()))
Menu.add_item("main", MenuItem("Profile", reverse("Profile"), check=lambda request: request.user.is_authenticated()))
Menu.add_item("main", MenuItem("Logout", reverse("Logout"), check=lambda request: request.user.is_authenticated()))
示例15: MenuItem
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import add_item [as 别名]
from menu import Menu, MenuItem
from django.core.urlresolvers import reverse
project_submenu = (
MenuItem(
"List",
reverse("projects_list"),
weight=10,
icon="tools"
),
)
Menu.add_item(
"main",
MenuItem(
"Projects",
reverse("projects_list"),
weight=10,
children=project_submenu,
icon="tools"
)
)