-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
70 lines (49 loc) · 1.66 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
59
60
61
62
63
64
65
66
67
68
import tkinter
import time
import os
import random
from eyes import *
from thoughts import *
if os.environ.get('DISPLAY','') == '':
print('no display found. Using :0.0')
os.environ.__setitem__('DISPLAY', ':0.0')
def enterFullScreen(event=None):
window.attributes("-fullscreen", True)
return "break"
def endFullScreen(event=None):
window.attributes("-fullscreen", False)
return "break"
window = tkinter.Tk()
window.title('animation test')
window.config(cursor="none")
window.bind("<F11>", enterFullScreen)
window.bind("<Escape>", endFullScreen)
window.attributes("-fullscreen", True)
canvas = tkinter.Canvas(window, width=window.winfo_screenwidth(), height=window.winfo_screenheight(), bg="black", highlightthickness=0)
canvas.pack()
myeyes = Eyes(canvas, window)
lastEyeAtime = time.time()
blinkInterval:float = 0
myThoughts = ThoughtBox(canvas)
updateThoughtPossibility = 25.0
cycleInterval:float = 7
lastUpdateThoughtTime = time.time()
while 1:
window.update()
# blink eyes
if time.time() > lastEyeAtime+blinkInterval:
if myeyes.blink():
lastEyeAtime = time.time()
blinkInterval:float = ((3000+random.randint(-3000, 3000))/1000)
# blink cursor
myThoughts.blink()
# update text
if time.time() > lastUpdateThoughtTime+cycleInterval:
randomNum = float(random.randint(0, 10000)/100)
if randomNum < updateThoughtPossibility:
myThoughts.getNewThought("/home/pi/Desktop/OwO/thoughts.txt")
else:
# hide thoughts if expired
myThoughts.hideThoughtBox()
lastUpdateThoughtTime = time.time()
window.mainloop()