-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathclock.py
More file actions
46 lines (36 loc) · 1.16 KB
/
clock.py
File metadata and controls
46 lines (36 loc) · 1.16 KB
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
#!/usr/bin/python3
#-----------------------------------------------------------------------------
# project: tkinterlite
# authors: 1966bc
# mailto: [[email protected]]
# modify: hiems MMXXI
#------------------------------------------------------------------------------
""" This is the clock module of Tkinterlite."""
import threading
import queue
import datetime
import time
class Clock(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.queue = queue.Queue()
self.check = True
def stop(self):
self.check = False
def run(self):
"""Feeds the tail."""
while self.check:
s = "Astral date: "
t = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
msg = "{0} {1}".format(s, t)
time.sleep(1)
self.queue.put(msg)
def check_queue(self, obj):
"""Returns a formatted string representing time."""
while self.queue.qsize():
try:
x = self.queue.get(0)
msg = "{0}".format(x)
obj.set(msg)
except queue.Empty:
pass