Problem: Very new to programming, but I am trying to build off a simple rumps example and thought I could just call a function from another file inside of a decorator that associates the function with the "Run Program" menu item but it seems like there are compatability issues with rumps/pystray and gui or something along those lines.
Goal: The idea is that I have a GUI that is just the user interface for a program that runs in the background, but when the GUI window is closed the program will keep running in the background. I need an icon to click in the menu bar to open the gui back up to be able to stop the program from running in the background or change any settings I have in the gui. Like I mentioned before, rumps and gui don't seem to work well together. I have tried using pystray in a similar manner, but got a similar error. If you have any other ways to go about this, I would appreciate the help! I would also like to try and keep it mac and windows compatible if possible (I understand rumps is for mac only)
import rumps
class SimpleApp(rumps.App):
def __init__(self):
super(SimpleApp, self).__init__("Glasses", icon="glassesIcon2.png")
self.menu = ["Run Program", "Exit"]
@rumps.clicked("Run Program")
def on_say_hello(self, sender):
from main import run_gui_function
run_gui_function() #this is the function to be run
print("test")
@rumps.clicked("Exit")
def on_exit(self, sender):
rumps.quit_application()
if __name__ == "__main__":
app = SimpleApp()
app.run()
Error: The code runs, the icon is shown in the menu bar, but when I click "Run Program", I get an error but the icon remains in the menu bar.
The error that I get when I try to run the program is: unrecognized selector sent to instance 0x14b6babd0