def tray_handler(): global TRAY_HNWD hover_text = "Gesture Mouse Server" menu_options = ( # ('Say Hello', None, kill_server), # ('Switch Icon', None, kill_server), # ('A sub-menu', None, ( # ('Say Hello to Simon', None, kill_server), # ('Switch Icon', None, kill_server), # )) ) TRAY_HNWD = SysTrayIcon("icon.ico", hover_text, menu_options, on_quit=kill_server, default_menu_index=1) TRAY_HNWD.show_balloon_tip("Startup", "Gesture mouse is running.") TRAY_HNWD.start()
log.info("enable session lock") def left_ckick(): print(">> left click") print("%s" % sys_tray_app.icon) if str(sys_tray_app.icon).__contains__('unlock.ico'): log.info("unlocked -> locked") enable_lock(sys_tray_app) else: log.info("locked -> unlocked") disable_lock(sys_tray_app) print("<< left click") def bye(sysTrayIcon): log.info('Bye, then.') menu_options = ( ('enable session locking', None, enable_lock), ('disable session locking', None, disable_lock), ) sys_tray_app = SysTrayIcon(unlock_icon, hover_text, menu_options, left_click_action=left_ckick, on_quit=bye, default_menu_index=1) session_unlocking_thd = SessionUnlockingThread(sys_tray_app) session_unlocking_thd.start() sys_tray_app.start()
SPACES = True PREFIX_NUMBER = 2 # Initialize the Word Completer and Keyboard Handler. WC = WordCompleter(WC_pkl_file, PREFIX_NUMBER) KbH = KeyboardHandler(WC, GUI_Q, SPACES, DCM) # SysTrayIcon argument parameters hovertext = "Automatic Word Completion" icon = os.getcwd() + "/" + "Speech_Bubble_Icon.ico" menu_options = (('Options', icon, options), ) # Threaded class initialization SysTray = SysTrayIcon(KbH, icon, hovertext, menu_options, default_menu_index=0) WSG = WSGui(BG, GUI_CORNER_PLACEMENT, DCM, FONTSIZE, TXTCOLOR, GUI_Q, GUI_HEIGHT, GUI_WIDTH) # Start the SysTray and Word Suggester GUI Threads. SysTray.start() WSG.start() ''' Begin the message loop waiting for keyboard input. This should continue until the tray icon tells the handler to shut down. ''' KbH.begin() time.sleep(1) # Let threads clean up.