-
Notifications
You must be signed in to change notification settings - Fork 0
/
70-lcd-clock.py
43 lines (33 loc) · 856 Bytes
/
70-lcd-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
# ========== digital clock ===============
# using pyglet:
# https://pyglet.readthedocs.io/en/latest/
# install:
# pip install pyglet --user
# more examples:
# https://github.com/pyglet/pyglet/tree/master/examples
import pyglet
from pyglet import clock
from datetime import datetime
window = pyglet.window.Window()
pyglet.font.add_file('library/DS-DIGIT.TTF')
ds_digital = pyglet.font.load('DS-Digital')
label = pyglet.text.Label(
text='DIGITAL CLOCK',
font_name = 'DS-Digital',
font_size = 48,
color = (0, 255, 0, 255),
x = window.width // 2,
y = window.height // 2,
anchor_x = 'center',
anchor_y = 'center'
)
def callback(delta):
now = datetime.now()
current = now.strftime("%H:%M:%S")
label.text = current
@window.event
def on_draw():
window.clear()
label.draw()
clock.schedule_interval(callback, 1)
pyglet.app.run()