-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHotkeyLayers.py
More file actions
44 lines (37 loc) · 1 KB
/
HotkeyLayers.py
File metadata and controls
44 lines (37 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from threading import Thread
import os
from PIL import Image
from Layers.InitConfig import updateConfig
import common
from GUI.createGUI import makeWidget
from GUI.guiVisibility import showGUI, hideGUI
import pystray
def quit():
common.kill = True
showGUI()
icon.stop()
def refreshConfigs():
global t
updateConfig()
common.kill = True
if t:
showGUI()
t.join(timeout=.5)
hideGUI()
common.kill = False
if common.drawGUI:
t = Thread(target=makeWidget,
args=[common.layout])
t.start()
# In order for the icon to be displayed, you must provide an icon
menu = pystray.Menu(pystray.MenuItem("Quit", quit),
pystray.MenuItem("Refresh configs", refreshConfigs),
)
icon = pystray.Icon(
'ToggleScript',
icon=Image.open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "toggleScript.ico")),
menu=menu)
t : Thread = None
refreshConfigs()
# To finally show you icon, call run
icon.run()