global interface_root\r
interface_root = tk.Tk()\r
interface_root.protocol("WM_DELETE_WINDOW", on_closing)\r
- interface_root.iconphoto(False, tk.PhotoImage(file="static/icons/ppt.png"))\r
+ interface_root.iconphoto(False, tk.PhotoImage(file="static\icons\ppt.png"))\r
interface_root.geometry("600x300+300+300")\r
app = Interface(interface_root)\r
interface_thread = threading.Thread(target=interface_root.mainloop())\r
refresh_status()\r
\r
\r
+def exit_action(icon):\r
+ logger.debug("User requested shutdown")\r
+ icon.visible = False\r
+ icon.stop()\r
\r
def show_icon():\r
logger.debug("Starting system tray icon")\r
- menu = (pystray.MenuItem("Status", lambda: null_action(), enabled=False),\r
+ icon = pystray.Icon("ppt-control")\r
+ icon.menu = (pystray.MenuItem("Status", lambda: null_action(), enabled=False),\r
pystray.MenuItem("Restart", lambda: start()),\r
- pystray.MenuItem("Settings", lambda: open_settings()))\r
- icon = pystray.Icon("ppt-control", Image.open(os.path.dirname(os.path.realpath(__file__)) + r'''\static\icons\ppt.ico'''), "ppt-control", menu)\r
+ pystray.MenuItem("Stop", lambda: exit_action(icon)),\r
+ pystray.MenuItem("Settings", lambda: open_settings())\r
+ )\r
+ icon.icon = Image.open(os.path.dirname(os.path.realpath(__file__)) + r'''\static\icons\ppt.ico''')\r
+ icon.title = "ppt-control"\r
icon.visible = True\r
icon.run(setup=start)\r
\r
\r
# Start systray icon and server\r
show_icon()\r
+ sys.exit(0)\r
\r
if __name__ == "__main__":\r
start_interface()\r