Closed AmberSahdev closed 1 year ago
There are a few ways to do this. I think this is cleanest:
import rumps
app = rumps.App('test')
@rumps.clicked('Action')
def on_action_click(menuitem):
menuitem.state = not menuitem.state
@rumps.events.before_start.register
def before_start():
app.menu['Action'].state = 1
app.run()
But you can also create the MenuItem
manually like so:
import rumps
app = rumps.App('test')
action = rumps.MenuItem('Action')
action.state = 1
@action.set_callback
def on_action_click(menuitem):
menuitem.state = not menuitem.state
app.menu.add(action)
app.run()
Thanks
Hi First off, thanks for creating this ridiculously uncomplicated library.
I wanted to ask if there's a way to have onoff buttons clicked by default upon application launch.
I'd have to set the sender.state to True but I dont see a way to access the sender object outside the function that enters upon clicking the button.
Thanks