Skip to content

Commit

Permalink
app setup
Browse files Browse the repository at this point in the history
  • Loading branch information
SkaisteMotiejunaite committed Nov 5, 2024
1 parent cf0d367 commit ac95654
Show file tree
Hide file tree
Showing 10 changed files with 465 additions and 0 deletions.
9 changes: 9 additions & 0 deletions App/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import sys
from PyQt5.QtWidgets import QApplication
from pages.home_page import HomePage

if __name__ == "__main__":
app = QApplication(sys.argv)
home_page = HomePage()
home_page.show()
sys.exit(app.exec_())
Binary file not shown.
Binary file added App/pages/__pycache__/home_page.cpython-311.pyc
Binary file not shown.
Empty file.
35 changes: 35 additions & 0 deletions App/pages/hand_gesture_page.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel, QHBoxLayout, QFrame
from PyQt5.QtGui import QPixmap

class HandGestureRecognitionPage(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("Hand Gesture Recognition")
self.setGeometry(100, 100, 800, 600)

main_layout = QHBoxLayout()
left_layout = QVBoxLayout()
self.left_hand_label = QLabel("Left Hand Gesture:")
self.left_hand_emoji = QLabel()
left_layout.addWidget(self.left_hand_label)
left_layout.addWidget(self.left_hand_emoji)

self.stream_frame = QFrame()
self.stream_frame.setStyleSheet("background-color: black;")
self.stream_frame.setFixedSize(400, 600)

right_layout = QVBoxLayout()
self.right_hand_label = QLabel("Right Hand Gesture:")
self.right_hand_emoji = QLabel()
right_layout.addWidget(self.right_hand_label)
right_layout.addWidget(self.right_hand_emoji)

main_layout.addLayout(left_layout)
main_layout.addWidget(self.stream_frame)
main_layout.addLayout(right_layout)

self.setLayout(main_layout)

def update_emojis(self, left_emoji_path, right_emoji_path):
self.left_hand_emoji.setPixmap(QPixmap(left_emoji_path))
self.right_hand_emoji.setPixmap(QPixmap(right_emoji_path))
71 changes: 71 additions & 0 deletions App/pages/home_page.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
from PyQt5.QtWidgets import QLabel, QVBoxLayout, QPushButton, QWidget, QHBoxLayout
from PyQt5.QtGui import QPixmap, QPainter
from PyQt5.QtSvg import QSvgRenderer
from PyQt5.QtCore import Qt
from .hand_gesture_page import HandGestureRecognitionPage

class HomePage(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("SensorFusion: Home")
self.setGeometry(100, 100, 800, 600)

# Main layout
main_layout = QHBoxLayout()

# Left layout for logo and introduction
left_layout = QVBoxLayout()

# Logo using QSvgRenderer
self.logo_label = QLabel(self)
self.svg_renderer = QSvgRenderer("../Datasets/UGLogo.svg") # Use SVG file path

# Create a QPixmap from the SVG renderer
desired_width = 150
desired_height = int(desired_width / (self.svg_renderer.defaultSize().width() / self.svg_renderer.defaultSize().height()))

# Set the logo pixmap by rendering the SVG
pixmap = QPixmap(int((self.svg_renderer.defaultSize().width())/10) , int((self.svg_renderer.defaultSize().height())/10))
pixmap.fill(Qt.transparent) # Fill with transparent background

# Create a painter to render the SVG onto the pixmap
painter = QPainter(pixmap)
self.svg_renderer.render(painter)
painter.end()

self.logo_label.setPixmap(pixmap)
self.logo_label.setScaledContents(True) # Allow scaling
left_layout.addWidget(self.logo_label)

# Introduction label
welcome_label = QLabel("Welcome to SensorFusion", self)
welcome_label.setStyleSheet("font-size: 20px; font-weight: bold;")
left_layout.addWidget(welcome_label)

# Add left layout to the main layout
main_layout.addLayout(left_layout)

# Layout for demo buttons
button_layout = QVBoxLayout()
demo_buttons = [
("Hand Gesture Recognition", self.open_hand_gesture_page),
("Facial Expression Recognition", self.open_facial_expression_page)
]

for text, handler in demo_buttons:
button = QPushButton(text, self)
button.clicked.connect(handler)
button_layout.addWidget(button)

# Add the button layout to the main layout
main_layout.addLayout(button_layout)

# Set the main layout
self.setLayout(main_layout)

def open_hand_gesture_page(self):
self.hand_gesture_page = HandGestureRecognitionPage()
self.hand_gesture_page.show()

def open_facial_expression_page(self):
print("Facial Expression Recognition demo selected") # Placeholder for future implementation
12 changes: 12 additions & 0 deletions App/styles/base.qss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
QLabel {
font-size: 24px;
font-weight: bold;
}
QPushButton {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
font-size: 16px;
}
Empty file.
Empty file added App/styles/hand_gesture.qss
Empty file.
Loading

0 comments on commit ac95654

Please sign in to comment.