Skip to content
Snippets Groups Projects
Commit c1ed5628 authored by Michael Mutote's avatar Michael Mutote
Browse files

22202956 GUI 90% on FIrst Commit

parents
No related branches found
No related tags found
No related merge requests found
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="N806" />
<option value="N802" />
<option value="N803" />
<option value="N814" />
</list>
</option>
</inspection_tool>
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredIdentifiers">
<list>
<option value="list.pop" />
</list>
</option>
</inspection_tool>
</profile>
</component>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.11 (pythonProject1)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (pythonProject1)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/pythonProject1.iml" filepath="$PROJECT_DIR$/.idea/pythonProject1.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
import sys
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)
from PyQt6.QtGui import QPalette, QColor
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
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 and Time', 'Airline', 'Destination', 'Model Start Year']
self.input_fields = [QDateTimeEdit(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].dateTimeChanged.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]])
app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec()
# Shared data to GUI
import random
destinations = ["Tunis", "Paris", "Moscow"]
airlines = ["Air Tunisia", "Air France", "Lufthansa", "Air Zimbabwe"]
model_years = list(i for i in range(2015, 2023))
selected_day = list(range(366))
delay = list(random.random() for _ in range(366))
# Shared Data from GUI
GUI_selections = {"date": "", "airline": "", "destination": "", "years to model": ""}
File added
icon.ico 0 → 100644
icon.ico

198 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment