-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotice.py
More file actions
28 lines (22 loc) · 743 Bytes
/
Copy pathnotice.py
File metadata and controls
28 lines (22 loc) · 743 Bytes
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
from threading import Timer
from pygmi import Button, events, client
class Notice(object):
def __init__(self, name='!notice', colors=None, timeout=5):
self.timeout = timeout
self.timer = None
self.button = Button('right', name, colors)
events.bind({'Notice': lambda args: self.show(args)})
self.tick()
def tick(self):
self.button.label = ' '
def show(self, notice):
if self.timer:
self.timer.cancel()
self.button.label = notice
try:
self.timer = Timer(self.timeout, self.tick)
self.timer.start()
except:
pass
def write(notice):
client.awrite('/event', 'Notice %s' % notice.replace('\n', ' '))