-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
58 lines (48 loc) · 1.68 KB
/
main.py
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import sys
import time
import tkinter
from explorerbox import sandbox as sb
from explorerbox import config as cfg
from explorerbox import renderer as rd
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
config = cfg.Config()
config.loadFromFile()
class ConfigChangeHandler(FileSystemEventHandler):
def on_modified(self, event):
if event.src_path == 'config/config.json':
print('detected change in configfile', flush=True)
config.loadFromFile()
def main():
fake_mode = False
calibrate_beamer_mode = False
calibrate_kinect_mode = False
if len(sys.argv) == 2 and sys.argv[1] == 'fakenect':
fake_mode = True
if len(sys.argv) == 2 and sys.argv[1] == 'beamer_calibrate':
calibrate_beamer_mode = True
fake_mode = True
if len(sys.argv) == 2 and sys.argv[1] == 'kinect_calibrate':
calibrate_kinect_mode = True
if fake_mode == True:
from kinect import fakenect as fa
nect = fa.Fakenect()
else:
from kinect import kinect as ki
nect = ki.Kinect()
window = tkinter.Tk()
window.attributes('-fullscreen', True)
window.bind('<Escape>',lambda e: window.destroy())
sandbox = sb.Sandbox(config, nect, rd.Renderer(config))
if calibrate_beamer_mode == True:
sandbox.calibrate_beamer(window)
elif calibrate_kinect_mode == True:
sandbox.calibrate_kinect(window)
else:
sandbox.execute(window)
if __name__ == '__main__':
event_handler = ConfigChangeHandler()
observer=Observer()
observer.schedule(event_handler,path='config/',recursive=False)
observer.start()
main()