-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
78 lines (59 loc) · 2.37 KB
/
main.py
File metadata and controls
78 lines (59 loc) · 2.37 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
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
from gui.qt.common import *
from gui.pages.blank import BLANK
from gui.pages.home import HOME
from gui.pages.admin import ADMIN
from utils.memory import mem
from gui.workers.tpost import post_req_async
class DEBURRBOT(NStackedWidget):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.page_blank:BLANK = self.addWidget(BLANK())
self.page_home:HOME = self.addWidget(HOME())
self.page_admin:ADMIN = self.addWidget(ADMIN())
gsig.previous_page.connect(self.__previous_page)
gsig.next_page.connect(self.__next_page)
mem.page_count = self.count()
mem.page = 1
self.setCurrentIndex(mem.page)
mem.new_status.connect(self.__on_new_status)
self.inactivity_timer = NTimer(900_000, self.__inactivity_call, repeat=False)
gsig.button_activity.connect(self.__reset_inactivity_timer)
def __on_new_status(self):
status = mem.status
if status == 'startup': # send program number to robot on its startup
post_req_async(path='mem', data={'name': 'program', 'value': str(mem.program)})
def __reset_inactivity_timer(self):
self.inactivity_timer.kill()
self.inactivity_timer.start()
def __inactivity_call(self):
self.setCurrentWidget(self.page_blank)
def __previous_page(self):
i = self.currentIndex() - 1
mem.page = i
self.setCurrentIndex(i)
def __next_page(self):
i = self.currentIndex() + 1
mem.page = i
self.setCurrentIndex(i)
def setCurrentIndex(self, index: int) -> None:
return super().setCurrentIndex(index)
def setCurrentWidget(self, w: QWidget) -> None:
return super().setCurrentWidget(w)
def hideEvent(self, a0: QHideEvent) -> None:
if self.inactivity_timer.isRunning():
self.inactivity_timer.kill()
return super().hideEvent(a0)
def showEvent(self, a0: QShowEvent) -> None:
if not self.inactivity_timer.isRunning():
self.inactivity_timer.start()
return super().showEvent(a0)
if __name__ == "__main__":
with open('assets/style.css', 'r') as f:
qapp.setStyleSheet(f.read())
app = DEBURRBOT()
if os.name == 'nt':
app.resize(int(SCREEN_WIDTH), int(SCREEN_HEIGHT))
app.show()
else:
app.showFullScreen()
sys.exit(qapp.exec_())