Commit b27c8826 by Laura Rodríguez

5jun

parent ff29977d
...@@ -13,7 +13,12 @@ import constants # Debe contener: DISPSIZE = (1920, 1080) ...@@ -13,7 +13,12 @@ import constants # Debe contener: DISPSIZE = (1920, 1080)
import pandas as pd # Importamos pandas para guardar los resultados en un archivo Excel import pandas as pd # Importamos pandas para guardar los resultados en un archivo Excel
import subprocess # Para abrir el archivo con el programa predeterminado import subprocess # Para abrir el archivo con el programa predeterminado
import os # Para comprobar la existencia del archivo import os # Para comprobar la existencia del archivo
from PyQt6.QtWidgets import (
QApplication, QWidget, QVBoxLayout, QPushButton,
QLabel, QMessageBox
)
from PyQt6.QtGui import QFont
from PyQt6.QtCore import Qt
# ============ FUNCIÓN DE CALIBRACIÓN ============ # ============ FUNCIÓN DE CALIBRACIÓN ============
def calibrate_tobii(self): def calibrate_tobii(self):
...@@ -231,6 +236,7 @@ def run_gonogo_test(self): ...@@ -231,6 +236,7 @@ def run_gonogo_test(self):
# ============ INTERFAZ PYQT =================== # ============ INTERFAZ PYQT ===================
class EyeTrackingApp(QWidget): class EyeTrackingApp(QWidget):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
...@@ -243,6 +249,27 @@ class EyeTrackingApp(QWidget): ...@@ -243,6 +249,27 @@ class EyeTrackingApp(QWidget):
def setup_ui(self): def setup_ui(self):
self.setStyleSheet("background-color: #e6f0ff;") self.setStyleSheet("background-color: #e6f0ff;")
button_style = """
QPushButton {
background-color: #3399ff;
color: white;
padding: 10px;
border-radius: 5px;
font-weight: bold;
}
QPushButton:hover {
background-color: #1a8cff;
color: #e6f7ff;
}
QPushButton:pressed {
background-color: #006bb3;
color: #ccf2ff;
padding-top: 11px;
padding-bottom: 9px;
}
"""
layout = QVBoxLayout() layout = QVBoxLayout()
title = QLabel("Test Go/NoGo con Tobii") title = QLabel("Test Go/NoGo con Tobii")
...@@ -252,19 +279,19 @@ class EyeTrackingApp(QWidget): ...@@ -252,19 +279,19 @@ class EyeTrackingApp(QWidget):
self.btn_calibrate = QPushButton("Calibrar") self.btn_calibrate = QPushButton("Calibrar")
self.btn_calibrate.setFont(QFont("Arial", 14)) self.btn_calibrate.setFont(QFont("Arial", 14))
self.btn_calibrate.setStyleSheet("background-color: #3399ff; color: white; padding: 10px; border-radius: 5px;") self.btn_calibrate.setStyleSheet(button_style)
self.btn_calibrate.clicked.connect(self.calibrate) self.btn_calibrate.clicked.connect(self.calibrate)
layout.addWidget(self.btn_calibrate) layout.addWidget(self.btn_calibrate)
self.btn_test = QPushButton("Iniciar test Go/NoGo") self.btn_test = QPushButton("Iniciar test Go/NoGo")
self.btn_test.setFont(QFont("Arial", 14)) self.btn_test.setFont(QFont("Arial", 14))
self.btn_test.setStyleSheet("background-color: #3399ff; color: white; padding: 10px; border-radius: 5px;") self.btn_test.setStyleSheet(button_style)
self.btn_test.clicked.connect(self.start_test) self.btn_test.clicked.connect(self.start_test)
layout.addWidget(self.btn_test) layout.addWidget(self.btn_test)
self.btn_results = QPushButton("Consultar resultados") self.btn_results = QPushButton("Consultar resultados")
self.btn_results.setFont(QFont("Arial", 14)) self.btn_results.setFont(QFont("Arial", 14))
self.btn_results.setStyleSheet("background-color: #3399ff; color: white; padding: 10px; border-radius: 5px;") self.btn_results.setStyleSheet(button_style)
self.btn_results.clicked.connect(self.view_results) self.btn_results.clicked.connect(self.view_results)
layout.addWidget(self.btn_results) layout.addWidget(self.btn_results)
...@@ -276,7 +303,7 @@ class EyeTrackingApp(QWidget): ...@@ -276,7 +303,7 @@ class EyeTrackingApp(QWidget):
self.calibrated = True self.calibrated = True
QMessageBox.information(self, "Calibración", "Calibración completada con éxito.") QMessageBox.information(self, "Calibración", "Calibración completada con éxito.")
else: else:
QMessageBox.critical(self, "Error", "La calibraciión ha fallado.") QMessageBox.critical(self, "Error", "La calibración ha fallado.")
def start_test(self): def start_test(self):
# if not self.calibrated: # if not self.calibrated:
...@@ -286,11 +313,8 @@ class EyeTrackingApp(QWidget): ...@@ -286,11 +313,8 @@ class EyeTrackingApp(QWidget):
def view_results(self): def view_results(self):
file_path = "gonogo_results.xlsx" file_path = "gonogo_results.xlsx"
# Verificamos si el archivo existe antes de intentar abrirlo
if os.path.exists(file_path): if os.path.exists(file_path):
try: try:
# Abrimos el archivo con el programa predeterminado (Windows)
subprocess.Popen([file_path], shell=True) subprocess.Popen([file_path], shell=True)
except Exception as e: except Exception as e:
QMessageBox.critical(self, "Error", f"No se pudo abrir el archivo Excel. {e}") QMessageBox.critical(self, "Error", f"No se pudo abrir el archivo Excel. {e}")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment