-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathguitest.py
75 lines (47 loc) · 2.45 KB
/
guitest.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
69
70
import tkinter as Tk
import calculatesleep
import broscience
import calculateIfBedNow
bedtime = ""
happening = ""
results = []
def findTimeBeforeMidnightElseFindTimeToday():
return time
def findHappening():
global happening
#happening kan være "" tom streng
happening = calculatesleep.returnHappening()
happening = happening.replace("SUMMARY:", "")
def soveLengeEllerLeggeseg():
global bedtime
if time == 0:
bedtime = "Du kan sove lenge."
else:
res1, res2, res3, res4 = calculatesleep.calculateBedTime(time[0], time[1], prepareminutes=60)
bedtime = "Du må legge deg: " + res4[0] + "." + res4[1] + ", " + res3[0] + "." + res3[1] + ", " + res2[0] + "." + res2[1] + " eller " + res1[0] + "." + res1[1] + " - " + time[2].replace("SUMMARY:", "") + " klokken " + str(time[0]) + ":" + str(time[1]) + "."
def createGui():
#bytte fra labels til text widgets
root = Tk.Tk()
root.configure(background="black")
sleep = Tk.Label(root, bg="#EC663C",font="Arial 25 bold", fg="white", height="5", text=bedtime, width="100")
sleep.grid(row=0, sticky="W")
temperature = Tk.Label(root, bg="#EC663C",font="Arial 25 bold", fg="white", height="5", width="100", text="21 grader")
temperature.grid(row=1, sticky="W")
bedNow = Tk.Text(root, bg="#9C425D",font="Arial 25 bold", fg="white", height="5", width="100")
bedNow.insert(Tk.INSERT, results)
bedNow.tag_configure(results, justify="center")
bedNow.grid(row=2, sticky="W")
quoteText = Tk.Label(root, bg="#47bbb3",font="Arial 25 bold", fg="white", height="5",text=quote, width="100")
quoteText.grid(row=3, sticky="W")
root.mainloop()
#Trenger bare å gjøres 1 gang om dagen, før klokken 12
time = calculatesleep.getWakeuptimeFromGoogleCalendar()
findHappening()
soveLengeEllerLeggeseg()
#get random quote
broscience.importQuoteList()
quote = broscience.getRandomQuote()
#time if bed now(list with 1 to 7 cycles), update every minute,
results = calculateIfBedNow.calculateTime()
results = "Anbefalte stå-opp-tider om du legger deg nå - " + str(results[0][0]) + "." + str(results[0][1]) + ", " + str(results[1][0]) + "." + str(results[1][1]) + ", " + str(results[2][0]) + "." + str(results[2][1]) + ", " + str(results[3][0]) + "." + str(results[3][1]) + ", " + str(results[4][0]) + "." + str(results[4][1]) + ", "+ str(results[5][0]) + "." + str(results[5][1]) + ", "+ str(results[6][0]) + "." + str(results[6][1]) + "."
createGui()