diff --git a/statapp/main_window.py b/statapp/main_window.py index f24ecbc..9acd5ae 100644 --- a/statapp/main_window.py +++ b/statapp/main_window.py @@ -1,7 +1,7 @@ import numpy as np from PySide2.QtCore import Slot, QSize from PySide2.QtGui import QIcon -from PySide2.QtWidgets import QMainWindow, QMessageBox +from PySide2.QtWidgets import QMainWindow, QMessageBox, QAction from statapp.calculations import generate_x_values from statapp.generate_factor_window import GenerateFactorWindow @@ -24,7 +24,10 @@ class MainWindow(QMainWindow): icon = QIcon() icon.addFile(resource_path("ui/images/logo.ico"), QSize(), QIcon.Normal, QIcon.Off) - self.setWindowIcon(icon) + + self.ui.generateXaction.setEnabled(False) + self.ui.varianceAnalysisAction.setEnabled(False) + self.ui.correlationAnalisisAction.setEnabled(False) self.isDataChanged = False self.model = InputValuesModel() @@ -34,6 +37,7 @@ class MainWindow(QMainWindow): @Slot() def on_openfileaction_triggered(self): current_data = self.model.getData() + data = np.array([]) if current_data.size > 1: file = '' if self.fileModel.file_name: @@ -53,15 +57,28 @@ class MainWindow(QMainWindow): return else: data = self.fileModel.loadFile() - if data is not None: + if data is not None and data.shape[0] > 0: self.model.updateAllData(data) self.isDataChanged = False else: data = self.fileModel.loadFile() - if data is not None: + if data is not None and data.shape[0] > 0: self.model.updateAllData(data) self.isDataChanged = False + if data.shape[1] == 1: + self.ui.generateXaction.setEnabled(True) + self.ui.varianceAnalysisAction.setEnabled(False) + self.ui.correlationAnalisisAction.setEnabled(False) + elif data.shape[1] > 1: + self.ui.generateXaction.setEnabled(True) + self.ui.varianceAnalysisAction.setEnabled(True) + self.ui.correlationAnalisisAction.setEnabled(True) + else: + self.ui.generateXaction.setEnabled(False) + self.ui.varianceAnalysisAction.setEnabled(False) + self.ui.correlationAnalisisAction.setEnabled(False) + @Slot() def on_savefileaction_triggered(self): self.isDataChanged = not self.fileModel.saveFile(self.model.getData()) @@ -78,6 +95,7 @@ class MainWindow(QMainWindow): y = np.random.normal(gw.mat, gw.deviation, size=(gw.count, 1)) self.model.updateAllData(y.round(2)) self.isDataChanged = True + self.generateXaction_action.setEnabled(True) @Slot() def on_generateXaction_triggered(self): @@ -91,6 +109,8 @@ class MainWindow(QMainWindow): # dd = dd.reshape(len(dd), 1) data = np.concatenate((data, x_arr), axis=1) self.model.updateAllData(data) + self.varianceAnalysisAction_action.setEnabled(True) + self.correlationAnalisisAction_action.setEnabled(True) self.isDataChanged = True @Slot()