-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
64 lines (47 loc) · 1.89 KB
/
main.py
File metadata and controls
64 lines (47 loc) · 1.89 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
from gui.qt.common import *
from gui.pages.blank import BLANK
from gui.pages.home import HOME
from utils.memory import mem
class WELDBOT(NStackedWidget):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.page_blank:BLANK = self.addWidget(BLANK())
self.page_home:HOME = self.addWidget(HOME())
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)
self.inactivity_timer = NTimer(900_000, self.__inactivity_call, repeat=False)
gsig.button_activity.connect(self.__reset_inactivity_timer)
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):
self.setCurrentIndex(self.currentIndex() - 1)
def __next_page(self):
self.setCurrentIndex(self.currentIndex() + 1)
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 = WELDBOT()
if os.name == 'nt':
app.resize(int(SCREEN_WIDTH), int(SCREEN_HEIGHT))
app.show()
else:
app.showFullScreen()
sys.exit(qapp.exec_())