global ws_label\r
global reset_ppt_button\r
global http_server\r
+global icon\r
scheduler = None\r
current_slideshow = None\r
interface_root = None\r
ws_daemon = None\r
http_server = None\r
reset_ppt_button = None\r
+icon = None\r
\r
\r
class Handler(server.SimpleHTTPRequestHandler):\r
global refresh_daemon\r
if STATE["connected"] == 1:\r
logger.info("Disconnected from PowerPoint instance")\r
+ icon.notify("Disconnected from PowerPoint instance")\r
refresh_daemon.do_run = False\r
STATE = copy(STATE_DEFAULT)\r
+ if icon is not None:\r
+ refresh_menu()\r
refresh_status()\r
logger.debug("State is now " + str(STATE))\r
while True:\r
STATE["connected"] = 1\r
STATE["current"] = current_slideshow.current_slide()\r
STATE["total"] = current_slideshow.total_slides()\r
+ icon.notify("Connected to PowerPoint instance")\r
+ if icon is not None:\r
+ refresh_menu()\r
refresh_status()\r
logger.info("Connected to PowerPoint instance")\r
refresh_daemon = threading.Thread(name="refresh_daemon", target=refresh_interval)\r
icon.visible = False\r
icon.stop()\r
\r
-def show_icon():\r
- logger.debug("Starting system tray icon")\r
- icon = pystray.Icon("ppt-control")\r
- icon.menu = (pystray.MenuItem("Status", lambda: null_action(), enabled=False),\r
- pystray.MenuItem("Restart", lambda: start()),\r
+def refresh_menu():\r
+ icon.menu = (pystray.MenuItem("Status: " + "dis"*(not STATE["connected"]) + "connected", lambda: null_action(), enabled=False),\r
pystray.MenuItem("Stop", lambda: exit_action(icon)),\r
pystray.MenuItem("Settings", lambda: open_settings())\r
)\r
+\r
+def show_icon():\r
+ global icon\r
+ logger.debug("Starting system tray icon")\r
+ icon = pystray.Icon("ppt-control")\r
icon.icon = Image.open(os.path.dirname(os.path.realpath(__file__)) + r'''\static\icons\ppt.ico''')\r
icon.title = "ppt-control"\r
+ refresh_menu()\r
icon.visible = True\r
icon.run(setup=start)\r
\r