Skip to main content
Ctrl+K

Ignis

  • User guide
  • API reference
  • Developer Guide
  • Examples
  • GitHub
  • User guide
  • API reference
  • Developer Guide
  • Examples
  • GitHub

Section Navigation

  • Toplevel package
  • Application
  • WindowManager
  • Singleton
  • GObject
  • Variable
  • Client
  • Options
  • Options Manager
  • Exceptions
  • D-Bus
  • D-Bus menu
  • BaseWidget
  • BaseService
  • Connection Manager
  • Menu Model
  • Widgets
    • Arrow
    • ArrowButton
    • Box
    • Button
    • Calendar
    • CenterBox
    • CheckButton
    • DropDown
    • Entry
    • EventBox
    • FileChooserButton
    • FileDialog
    • FileFilter
    • Grid
    • HeaderBar
    • Icon
    • Label
    • ListBox
    • ListBoxRow
    • Overlay
    • Picture
    • PopoverMenu
    • RegularWindow
    • Revealer
    • RevealerWindow
    • Scale
    • Scroll
    • Separator
    • SpinButton
    • Stack
    • Switch
    • ToggleButton
    • Window
  • Services
    • Applications
    • Audio
    • Backlight
    • Bluetooth
    • Fetch
    • Hyprland
    • MPRIS (media)
    • Network
    • Niri
    • Notifications
    • Recorder
    • System Tray
    • Systemd
    • UPower
    • Wallpaper
  • Utils
    • FileMonitor
    • Poll
    • Timeout
    • Debounce
    • File
    • Icon
    • Misc
    • Monitor
    • Pixbuf
    • Sass
    • Shell Commands
    • Socket
    • String Cases
    • Thread
    • Version
  • API reference
  • Menu Model

Menu Model#

class ignis.menu_model.IgnisMenuModel(*args: IgnisMenuItem | IgnisMenuModel | IgnisMenuSeparator, label: str | None = None)#

A helper class that provides a convenient way to construct a Gio.Menu.

Parameters:
  • *args (IgnisMenuItem | IgnisMenuModel | IgnisMenuSeparator) -- Items to add.

  • label (str | None, default: None) -- The label of the submenu. Only works if this model passed as an item of the parent model. Must be provided only as a keyword argument.

from ignis.menu_model import IgnisMenuModel, IgnisMenuItem, IgnisMenuSeparator

model = IgnisMenuModel(
    IgnisMenuItem(
        label="Item 1",
        on_activate=lambda x: print("item 1 activated!"),
    ),
    IgnisMenuItem(
        label="This is disabled item",
        enabled=False,
        on_activate=lambda x: print(
            "you will not see this message in terminal hehehehehe"
        ),
    ),
    IgnisMenuModel(
        *(  # unpacking because items must be passed as *args
            IgnisMenuItem(
                label=str(i),
                on_activate=lambda x, i=i: print(f"Clicked on item {i}!"),
            )
            for i in range(10)
        ),
        label="Submenu",  # pass label as keyword argument
    ),
)

# Access built Gio.Menu
print(model.gmenu)
gproperty items: list[IgnisMenuItem | IgnisMenuModel | IgnisMenuSeparator]#
  • read-write

A list of items.

gproperty gmenu: Gio.Menu | None#
  • read-only

The Gio.Menu built from the contents of items, or None if no items are present.

gproperty label: str | None#
  • read-only

The label of the submenu. Only Works if this model passed as an item of the parent model.

clean_gmenu() → None#

Clean gmenu. This will gracefully destroy it, avoiding a memory leak.

Return type:

None

class ignis.menu_model.IgnisMenuItem(label: str, enabled: bool = True, on_activate: Callable | None = None)#

A menu item.

Parameters:
  • label (str) -- The label of item.

  • enabled (bool, default: True) -- Whether the item is enabled. If False, the item cannot be selected.

  • on_activate (Callable | None, default: None) -- The function to call when the user clicks on the item.

gproperty label: str#
  • read-only

The label of item.

gproperty uniq_name: str#
  • read-only

The unique name of the Gio.Action.

gproperty action_name: str#
  • read-only

The full action name (app.UNIQ_NAME).

gproperty enabled: bool#
  • read-only

Whether the item is enabled. If False, the item cannot be selected.

gproperty on_activate: Callable#
  • read-write

The function to call when the user clicks on the item.

class ignis.menu_model.IgnisMenuSeparator#

A simple object representing a menu separator.

previous

Connection Manager

next

Widgets

On this page
  • IgnisMenuModel
    • IgnisMenuModel.items
    • IgnisMenuModel.gmenu
    • IgnisMenuModel.label
    • IgnisMenuModel.clean_gmenu()
  • IgnisMenuItem
    • IgnisMenuItem.label
    • IgnisMenuItem.uniq_name
    • IgnisMenuItem.action_name
    • IgnisMenuItem.enabled
    • IgnisMenuItem.on_activate
  • IgnisMenuSeparator
Edit on GitHub

This Page

  • Show Source

© Copyright 2024, linkfrg.

Created using Sphinx 8.1.0.

Built with the PyData Sphinx Theme 0.16.1.