-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathla.py
134 lines (99 loc) · 3.07 KB
/
la.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
132
133
134
import time, os
from tkinter import *
# Comment
def getTime():
timer = time.ctime()
time1 = timer.split(" ")[3]
return time1.split(":")
def convert(a):
if a.isdigit():
b = int(a)
return b
else:
return 0
def algo(a, w):
b = [
[32, 16, 8, 4, 2, 1],
[32, 16, 8, 4, 2, 1],
[16, 8, 4, 2, 1]
]
c = []
d = ""
a1 = "[1]"
b1 = "[0]"
for e in b[0]:
c.append(a // e)
a %= e
for e in range(len(c)):
# d += f"[{e}]"
if c[e] == 1:
w[e].config(bg="#aaaaaa", fg="#131320")
else:
w[e].config(bg="#131320", fg="#aaaaaa")
def run():
global hs, ms, ss
timer = getTime()
hr = convert(timer[0])
min = convert(timer[1])
sec = convert(timer[2])
algo(hr, hs)
algo(min, ms)
algo(sec, ss)
base.after(1, run)
def start():
global hs
global ms
global ss
global base
base = Tk()
base.geometry("200x100")
base.title("Binary Clock")
ft = Frame(base)
h = Label(ft, text="32", bg="red")
h.pack(padx=1, pady=1, side='left', fill='both', expand=True)
h3 = Label(ft, text="04", bg="red")
h3.pack(padx=1, pady=1, side='left', fill='both', expand=True)
m = Label(ft, text="32", bg="red")
m.pack(padx=1, pady=1, side='left', fill='both', expand=True)
m3 = Label(ft, text="04", bg="red")
m3.pack(padx=1, pady=1, side='left', fill='both', expand=True)
s = Label(ft, text="32", bg="red")
s.pack(padx=1, pady=1, side='left', fill='both', expand=True)
s3 = Label(ft, text="04", bg="red")
s3.pack(padx=1, pady=1, side='left', fill='both', expand=True)
ft.pack(padx=1, pady=1, fill="both", expand=True)
fm = Frame(base)
h1 = Label(fm, text="16", bg="blue")
h1.pack(padx=1, side='left', fill='both', expand=True)
h4 = Label(fm, text="02", bg="red")
h4.pack(padx=1, side='left', fill='both', expand=True)
m1 = Label(fm, text="16", bg="blue")
m1.pack(padx=1, side='left', fill='both', expand=True)
m4 = Label(fm, text="02", bg="red")
m4.pack(padx=1, side='left', fill='both', expand=True)
s1 = Label(fm, text="16", bg="blue")
s1.pack(padx=1, side='left', fill='both', expand=True)
s4 = Label(fm, text="02", bg="red")
s4.pack(padx=1, side='left', fill='both', expand=True)
fm.pack(padx=1, fill="both", expand=True)
fb = Frame(base)
h2 = Label(fb, text="08", bg="red")
h2.pack(padx=1, pady=1, side='left', fill='both', expand=True)
h5 = Label(fb, text="01", bg="red")
h5.pack(padx=1, pady=1, side='left', fill='both', expand=True)
m2 = Label(fb, text="08", bg="red")
m2.pack(padx=1, pady=1, side='left', fill='both', expand=True)
m5 = Label(fb, text="01", bg="red")
m5.pack(padx=1, pady=1, side='left', fill='both', expand=True)
s2 = Label(fb, text="08", bg="red")
s2.pack(padx=1, pady=1, side='left', fill='both', expand=True)
s5 = Label(fb, text="01", bg="red")
s5.pack(padx=1, pady=1, side='left', fill='both', expand=True)
fb.pack(padx=1, pady=1, fill="both", expand=True)
hs = [h, h1, h2, h3, h4, h5]
ms = [m, m1, m2, m3, m4, m5]
ss = [s, s1, s2, s3, s4, s5]
run()
base.mainloop()
if __name__ == "__main__":
start()