Skip to main content
Ctrl+K
FreedomBox  documentation - Home
  • Developer Documentation
  • Tutorial: Writing Apps for FreedomBox
    • Part 1: Beginning
    • Part 2: Skeleton
    • Part 3: View
    • Part 4: Components
    • Part 5: Customizing
    • Part 6: Setup
    • Part 7: Other Changes
    • Part 8: Finishing
    • Full Code
  • Reference
    • App
    • Components
      • Info
      • EnableState
      • Menu
      • Packages
      • Configuration
      • Daemon
      • Firewall
      • Webserver
      • Frontpage
      • Domain Name
      • Let’s Encrypt
      • Users
      • StaticFiles
      • Backups
      • Coturn
      • Container
    • Actions
    • Action Utils
    • Views
    • Forms
    • Notification
  • Editing the Developer Documentation
  • Repository
  • Show source
  • Suggest edit
  • Open issue
  • .rst

Menu

Contents

  • Menu
    • Menu.__init__()
    • Menu.active_item()
    • Menu.get_with_url_name()
    • Menu.items
    • Menu.sorted_items()

Menu#

class plinth.menu.Menu(component_id: str, name: str | None = None, icon: str | None = None, tags: list[str] | None = None, url_name: str | None = None, url_args: list | None = None, url_kwargs: dict | None = None, parent_url_name: str | None = None, order: int = 50, advanced: bool = False)[source]#

Component to manage a single menu item.

__init__(component_id: str, name: str | None = None, icon: str | None = None, tags: list[str] | None = None, url_name: str | None = None, url_args: list | None = None, url_kwargs: dict | None = None, parent_url_name: str | None = None, order: int = 50, advanced: bool = False)[source]#

Initialize a new menu item with basic properties.

name is the label of the menu item.

icon is the icon to be displayed for the menu item. Icon can be the name of a glyphicon from the Fork Awesome font’s icon set: https://forkawesome.github.io/Fork-Awesome/icons/. In this case, the icon name starts with the string ‘fa-’. Alternatively, the icon can also be a file under the directory plinth/modules/<app>/static/icons/, provided without an extension. SVG icons are preferred. Currently, both PNG and SVG icons with the same name are used. For example, if the value of icon is ‘myicon’ and app_id in App class is ‘myapp’, then two icons files plinth/modules/myapp/static/icons/myicon.svg and plinth/modules/myapp/static/icons/myicon.png are used in the interface.

tags is a list of tags that describe the app. Tags help users to find similar apps or alternatives and discover use cases.

url_name is the name of url location that will be activated when the menu item is selected. This is not optional. url_args and url_kwargs are sent to reverse() when resolving url from url_name.

parent_url_name optionally specifies the menu item under which this menu item should become a child.

order is the numerical rank of this item within the menu. Lower order items appear closest to the top/left of the menu. By convention, we use the spectrum between 0 and 100 to rank orders, but feel free to disregard that. If you need more granularity, don’t bother renumbering things. Feel free to use fractional orders.

advanced decides whether to show the menu item only in advanced mode.

active_item(request)[source]#

Return the first active item (e.g. submenu) that is found.

static get_with_url_name(url_name: str) → Menu[source]#

Return a menu item with given URL name.

Raise LookupError of the request item is not found.

property items#

Return the list of children for this menu item.

sorted_items()[source]#

Return menu items in sorted order according to current locale.

previous

EnableState

next

Packages

Contents
  • Menu
    • Menu.__init__()
    • Menu.active_item()
    • Menu.get_with_url_name()
    • Menu.items
    • Menu.sorted_items()

By FreedomBox Authors

© Copyright 2021-2026.

Licensed under the CC BY-SA 4.0 license.