-
Notifications
You must be signed in to change notification settings - Fork 6
/
InstrumentPanel.py
39 lines (31 loc) · 1.02 KB
/
InstrumentPanel.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
import time
class InstrumentPanel:
listeners = {}
tm = None
menu_opened = False
def __init__(self, tm):
self.tm = tm
def on_menu(self, message, show_arrows):
if message is None:
self.tm.clear_instpanel()
self.menu_opened = False
else:
self.tm.send_instpanel(message, show_arrows)
self.menu_opened = True
self.fire_event('menu_opened', self.menu_opened)
def fire_event(self, event, *args):
if event not in self.listeners:
return
for listener in self.listeners[event]:
listener(*args)
def on_event(self, event, callback):
if event not in self.listeners:
self.listeners[event] = []
self.listeners[event].append(callback)
def on_phone(self, number):
if number is None:
self.tm.send_instpanel(" Metto giu!")
time.sleep(1)
self.tm.clear_instpanel()
else:
self.tm.send_instpanel("Pronto?Pronto!")