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
|
import pystray
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
import argparse
|
import argparse
|
||||||
|
import threading
|
||||||
|
|
||||||
NAME = 'Eye Strain Reminder'
|
NAME = 'Eye Strain Reminder'
|
||||||
MESSAGE = 'Friendly reminder to observe the 20-20-20 rule'
|
MESSAGE = 'Friendly reminder to observe the 20-20-20 rule'
|
||||||
|
@ -20,14 +21,17 @@ icon = None
|
||||||
mute = False
|
mute = False
|
||||||
disable_notifications = False
|
disable_notifications = False
|
||||||
invert_icons = False
|
invert_icons = False
|
||||||
|
notify_thread = None
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
|
print("Initializing EyeStrainReminder...")
|
||||||
|
notify2.init(NAME)
|
||||||
|
|
||||||
|
def create_tray_icon():
|
||||||
global icon
|
global icon
|
||||||
image = get_image()
|
image = get_image()
|
||||||
icon = pystray.Icon(NAME, image, NAME, generate_menu_items())
|
icon = pystray.Icon(NAME, image, NAME, generate_menu_items())
|
||||||
icon.run()
|
icon.run()
|
||||||
print("Initializing EyeStrainReminder...")
|
|
||||||
notify2.init(NAME)
|
|
||||||
|
|
||||||
def update_icon():
|
def update_icon():
|
||||||
global icon
|
global icon
|
||||||
|
@ -100,4 +104,7 @@ def main():
|
||||||
uninit()
|
uninit()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
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