jaredks / rumps

Ridiculously Uncomplicated macOS Python Statusbar apps
BSD 3-Clause "New" or "Revised" License
3.06k stars 177 forks source link

Basic test app rumps.clicked not working #186

Closed NikiLentz closed 1 year ago

NikiLentz commented 2 years ago

Hi, I am using python 3.9.12 and am on the newest Monterey Update on M1Pro.

I have created a very basic example app


import rumps
class TestApp(object):
    def __init__(self):
        self.app = rumps.App("Test", title="🤨")
        self.menu = [rumps.MenuItem('Test123')]
    @rumps.clicked("Test123")
    def test_23(self, _):
        print("TEST")
    def run(self):
        self.app.run()
if __name__ == '__main__':
    TestApp().run()

I can't get anything to show up in the terminal after clicking Test123, I also tried notifications and opening a window and basically nothing seems to be called in the test_23 method when clicking.

NikiLentz commented 2 years ago

Ok, i just realised that it works when setting the callback explicitly in the self.menu constructor, is that how it's supposed to work?

jaredks commented 1 year ago

Yes because you are creating a MenuItem implicitly with the clicked call so by also creating it in __init__, they collided.