Icon and notifs in separate threads
This commit is contained in:
parent
f58b7681d0
commit
5e2f3a697f
|
@ -7,6 +7,7 @@ from pystray import MenuItem as item
|
|||
import pystray
|
||||
from PIL import Image
|
||||
import argparse
|
||||
import threading
|
||||
|
||||
NAME = 'Eye Strain Reminder'
|
||||
MESSAGE = 'Friendly reminder to observe the 20-20-20 rule'
|
||||
|
@ -20,14 +21,17 @@ icon = None
|
|||
mute = False
|
||||
disable_notifications = False
|
||||
invert_icons = False
|
||||
notify_thread = None
|
||||
|
||||
def init():
|
||||
print("Initializing EyeStrainReminder...")
|
||||
notify2.init(NAME)
|
||||
|
||||
def create_tray_icon():
|
||||
global icon
|
||||
image = get_image()
|
||||
icon = pystray.Icon(NAME, image, NAME, generate_menu_items())
|
||||
icon.run()
|
||||
print("Initializing EyeStrainReminder...")
|
||||
notify2.init(NAME)
|
||||
|
||||
def update_icon():
|
||||
global icon
|
||||
|
@ -100,4 +104,7 @@ def main():
|
|||
uninit()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
notify_thread = threading.Thread(target=main, name="Notify Thread")
|
||||
notify_thread.start()
|
||||
create_tray_icon()
|
||||
notify_thread.join()
|
||||
|
|
Loading…
Reference in New Issue