Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow menu items to be hidden #138

Merged
merged 2 commits into from Jun 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Expand Up @@ -4,6 +4,7 @@ Changes
0.3.0.dev
---------

- Allow menu items to be hidden #138
- Fix dark mode alert style #137
- Notifications: fixes, cleanup, and tests #131
- Fix slider for some older macOS versions (10.11 and before?)
Expand Down
17 changes: 17 additions & 0 deletions rumps/rumps.py
Expand Up @@ -528,6 +528,23 @@ def state(self):
def state(self, new_state):
self._menuitem.setState_(new_state)

@property
def hidden(self):
"""Indicates whether the menu item is hidden."""
return self._menuitem.isHidden()

@hidden.setter
def hidden(self, value):
self._menuitem.setHidden_(value)

def hide(self):
"""Hide the menu item."""
self.hidden = True

def show(self):
"""Show the menu item."""
self.hidden = False

def set_callback(self, callback, key=None):
"""Set the function serving as callback for when a click event occurs on this menu item. When `callback` is
``None``, it will disable the callback function and grey out the menu item. If `key` is a string, set as the
Expand Down