diff --git a/DisplayWindow.py b/DisplayWindow.py index 61a8f63ac5ff415bd07858947e541a95b14481b0..0bb95e8b33a5f04f2653f6d2d42a0af9fa93f064 100644 --- a/DisplayWindow.py +++ b/DisplayWindow.py @@ -1,11 +1,14 @@ import sys + +from PyQt6.QtCore import Qt + import RegressionModel from pyqtgraph import PlotWidget, plot import pyqtgraph as pg from PyQt6.QtWidgets import (QApplication, QMainWindow, QWidget, QVBoxLayout, QHBoxLayout, QGridLayout, QLabel, QPushButton, QSlider, QDateTimeEdit, - QLineEdit, QComboBox, QDateEdit, QTabWidget) + QLineEdit, QComboBox, QDateEdit, QTabWidget, QCheckBox) from PyQt6.QtGui import QPalette, QColor, QIcon @@ -76,7 +79,7 @@ class MainWindow(QMainWindow): def update_values(self): menu_items = {0: 'cut', 1: 'color', 2: 'clarity', 3: 'carat', 4: 'depth', 5: 'table', 6: 'x', 7: 'y', 8: 'z'} - for key,value in menu_items.items(): + for key, value in menu_items.items(): print(key) if key < 3: RegressionModel.GUI_selections[value] = self.input_fields[key].currentText() @@ -91,55 +94,26 @@ class Advanced(QMainWindow): super().__init__() self.setWindowIcon(QIcon("icon.ico")) self.setMinimumSize(720, 640) - # - # # Create a central widget - # central_widget = QWidget(self) - # self.setCentralWidget(central_widget) - # - # # Create a grid layout and set it to the central widget - # grid_layout = QGridLayout(central_widget) - # - # # Create labels and input fields - # self.labels_text = ['Date', 'Airline', 'Destination', 'Model Start Year'] - # self.input_fields = [QDateEdit(self), QComboBox(self), QComboBox(self), QComboBox(self)] - # self.input_fields[1].addItems(RegressionModel.airlines) - # self.input_fields[2].addItems(RegressionModel.destinations) - # self.input_fields[3].addItems(list(map(str, RegressionModel.model_years))) - # - # # Add labels and input fields to the grid layout - # for i in range(4): - # label = QLabel(self.labels_text[i], self) - # grid_layout.addWidget(label, 0, i) - # grid_layout.addWidget(self.input_fields[i], 1, i) - # - # # Connect signals - # for i in range(len(self.input_fields)): - # if i == 0: - # self.input_fields[i].dateChanged.connect(self.update_values) - # else: - # self.input_fields[i].currentTextChanged.connect(self.update_values) - # - # # Create a plot widget - # graphWidget = pg.PlotWidget(self) - # graphWidget.setBackground('w') - # graphWidget.plot(RegressionModel.selected_day, RegressionModel.delay) - # - # # Add the plot widget to the grid layout - # grid_layout.addWidget(graphWidget, 2, 0, 1, 4) - # grid_layout.addWidget(QLabel("EXPECTED DELAY: ", self), 3, 0, 1, 1) - # # Remember to add the delay value here - # - # self.setWindowTitle('Assistance Systems') - # self.show() - # - # def update_values(self): - # menu_items = {0: "date", 1: "airline", 2: "destination", 3: "years to model"} - # sender = self.sender() - # for i in range(4): - # if sender == self.input_fields[i]: - # RegressionModel.GUI_selections[menu_items[i]] = sender.currentText() if i != 0 \ - # else sender.dateTime() - # print(RegressionModel.GUI_selections[menu_items[i]]) + + central_widget = QWidget(self) + self.setCentralWidget(central_widget) + # Create a grid layout and set it to the central widget + grid_layout = QGridLayout(central_widget) + + self.check_labels = ['Cut', 'Colour', 'Clarity', 'Carat', 'Depth', 'Table', 'X', 'Y', 'Z'] + self.checkboxes = [] + grid_layout.addWidget(QLabel("select features to include in Modelling"), 0, 0) + for i, label in enumerate(self.check_labels): + checkbox = QCheckBox(label, self) + checkbox.setChecked(True) + checkbox.stateChanged.connect(self.handle_checkbox_state) # Connect signal + grid_layout.addWidget(checkbox, i, 1) + self.checkboxes.append(checkbox) # Store checkboxes in the list + + def handle_checkbox_state(self): + for i, checkbox in enumerate(self.checkboxes): + state = checkbox.checkState() + RegressionModel.Advanced_selections[checkbox.text()] = (state == Qt.CheckState.Checked) app = QApplication(sys.argv) diff --git a/RegressionModel.py b/RegressionModel.py index d683c35dc714897c82218dc4a82884ef1d080a60..e202785179202b913ddce2da958bb33c4c512fca 100644 --- a/RegressionModel.py +++ b/RegressionModel.py @@ -9,7 +9,10 @@ diamonds = pd.read_csv('diamonds.csv') cut = list(diamonds["cut"].unique()) colors = list(diamonds["color"].unique()) clarity = list(diamonds["clarity"].unique()) -GUI_selections = {} +GUI_selections = {} # user inputs +Advanced_selections = {} price_caret = [] -price = 0 +price = 98 + +