-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmainwindow.py
61 lines (47 loc) · 1.89 KB
/
mainwindow.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget #, QPushButton, QAction, QMessageBox
from PyQt5.QtWidgets import QGridLayout #, QLabel, QVBoxLayout, QGroupBox
# from PyQt5.QtCore import QThread
from gloves_icon import GlovesIcon
from mode_controller import ModeController
import os
import sys
class window(QMainWindow):
def __init__(self):
super(window, self).__init__()
self.setGeometry(50, 50, 720, 720)
self.setWindowTitle('Gesture Recognition')
self.mode_controller = None
self.central_widget = QWidget()
self.grid_layout = QGridLayout()
self.add_gloves_icons()
self.central_widget.setLayout(self.grid_layout)
self.setCentralWidget(self.central_widget)
self.show()
def add_gloves_icons(self):
images_path = os.path.join(os.getcwd(), 'Gloves')
paths = os.listdir(images_path)
#saved gloves
indx = 0
for image in paths:
if image[-4:] != '.jpg' and image[-4:] != '.png': #consider jpg images only
continue
glove_name = image[:-4]
#print(glove_name)
gloves_icon = GlovesIcon(glove_name)
gloves_icon.clicked.connect(self.gestureSelected)
i = indx / 3
j = indx % 3
self.grid_layout.addWidget(gloves_icon, i, j)
indx += 1
def gestureSelected(self, gloves_name):
configuration_file_path = os.path.join(os.getcwd(), "config_file.json")
if gloves_name == "new_gloves_icon":
#print('Add a new glove')
self.mode_controller = ModeController(configuration_file_path, None)
else:
#print('Load a saved glove')
self.mode_controller = ModeController(configuration_file_path, gloves_name)
if __name__ == "__main__":
app = QApplication(sys.argv)
Gui = window()
sys.exit(app.exec_())