-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathClock.py
131 lines (109 loc) · 5.19 KB
/
Clock.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# Import Module
import math # Required For Coordinates Calculation
import time # Required For Time Handling
from datetime import datetime
#import pytz
import random
#
class main():
def __init__(self):
pass
minute_string = str(' ')
hour_string = str(' ')
# 0 heisst strichrechnung
# 1 heisst punktrechnung
# 2 heisst kombination
calc_mode = 1
# Creating Trigger For Other Functions
def creating_all_function_trigger(self):
return
# Creating Background
def creating_background_(self):
return
# creating Canvas
def create_canvas_for_shapes(self):
return
# Creating Moving Sticks
def creating_sticks(self):
return
def set_calc_mode(self, new_calc_mode):
if new_calc_mode > -1 and new_calc_mode < 3:
self.calc_mode = new_calc_mode
def set_minute_string(self, which_minute):
# strichrechnung
if self.calc_mode == 0:
self.minute_string = self.line_calculation(which_minute)
# punktrechnung
elif self.calc_mode == 1:
self.minute_string = self.point_calculation(which_minute)
elif self.calc_mode == 2:
rng_calc_mode = random.randrange(0, 2)
if rng_calc_mode == 1:
self.minute_string = self.line_calculation(which_minute)
else:
self.minute_string = self.point_calculation(which_minute)
return
def set_hour_string(self, which_hour):
# strichrechnung
if self.calc_mode == 0:
self.hour_string = self.line_calculation(which_hour + 1)
# punktrechnung
elif self.calc_mode == 1:
self.hour_string = self.point_calculation(which_hour + 1)
elif self.calc_mode == 2:
rng_calc_mode = random.randrange(0, 2)
if rng_calc_mode == 1:
self.hour_string = self.line_calculation(which_hour + 1)
else:
self.hour_string = self.point_calculation(which_hour + 1) #+1 weil wir zu doof waren, die zeitzone zu implementieren
return
def point_calculation(self, which_minute_or_hour):
if which_minute_or_hour != 0:
# 0 heisst mal
# 1 heisst geteilt
which_point_calc_mode = random.randrange(0, 2)
if which_point_calc_mode == 0:
rng_number = random.randrange(0, which_minute_or_hour)
#print(which_minute_or_hour)
if rng_number != 0:
while which_minute_or_hour % rng_number != 0:
rng_number = random.randrange(1, which_minute_or_hour)
if rng_number != 0:
return str(rng_number) + ' * ' + str(which_minute_or_hour / rng_number)
elif which_point_calc_mode == 1:
rng_number = random.randrange(1, 11)
return str(which_minute_or_hour * rng_number) + ' : ' + str(rng_number)
elif which_minute_or_hour == 0:
return str('0 * 0')
def line_calculation(self, which_minute_or_hour):
rng_number = random.randrange(1, 99)
while rng_number == which_minute_or_hour:
rng_number = random.randrange(1, 99)
if rng_number > which_minute_or_hour:
return str(rng_number) + ' - ' + str(rng_number - which_minute_or_hour)
else:
return str(rng_number) + ' + ' + str(which_minute_or_hour - rng_number)
# Function Need Regular Update
def update_class(self, calc_mode):
now = time.localtime()
t = time.strptime(str(now.tm_hour), "%H")
hour = int(time.strftime("%I", t)) * 5
now = (hour, now.tm_min, now.tm_sec)
# strichrechnug - siehe oben bei der defintion der variable
self.set_calc_mode(calc_mode)
now2 = datetime.now()
print("%s/%s/%s %s:%s:%s" % (now2.month, now2.day, now2.year, now2.hour, now2.minute, now2.second))
print("%s --- %s" % (now2.hour, now2.minute))
self.set_hour_string(now2.hour)
self.set_minute_string(now2.minute)
#print(self.hour_string + ' h')
#print(self.minute_string + 'min ')
#time.sleep(30)
# Changing Stick Coordinates
return
# Main Function Trigger
if __name__ == '__main__':
root = main()
# Creating Main Loop
while True:
root.update_class()