Skip to content

Commit 742b24f

Browse files
authored
Merge pull request #21 from AINexumLab/20-implement-new-background-gui
Implement New Background Color
2 parents d72c997 + 509ffa9 commit 742b24f

3 files changed

Lines changed: 42 additions & 60 deletions

File tree

app/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
def main():
88
app = QApplication(sys.argv)
99
window = TrainerWidget()
10+
window.setWindowOpacity(.80)
1011
window.show()
1112
sys.exit(app.exec())
1213

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
from PyQt6.QtWidgets import QWidget, QVBoxLayout, QLabel, QSlider
1+
from PyQt6.QtWidgets import QWidget, QVBoxLayout, QLabel, QSlider, QApplication, QGraphicsDropShadowEffect, QFrame
22
from PyQt6.QtCore import Qt, QSettings
3-
from PyQt6.QtGui import QFont
4-
from PyQt6.QtWidgets import QApplication
3+
from PyQt6.QtGui import QPainter, QColor, QFont
54

65
class SettingsWindow(QWidget):
76
def __init__(self):
@@ -12,12 +11,26 @@ def __init__(self):
1211
label = QLabel("Font Size")
1312
layout.addWidget(label)
1413

14+
# Create the slider
1515
self.font_slider = QSlider(Qt.Orientation.Horizontal)
1616
self.font_slider.setRange(8, 13)
1717
current_size = QApplication.instance().font().pointSize()
1818
self.font_slider.setValue(current_size)
1919
self.font_slider.valueChanged.connect(self.change_font_size)
20-
layout.addWidget(self.font_slider)
20+
21+
slider_frame = QFrame()
22+
slider_layout = QVBoxLayout(slider_frame)
23+
slider_layout.setContentsMargins(0, 0, 0, 0)
24+
slider_layout.addWidget(self.font_slider)
25+
26+
shadow = QGraphicsDropShadowEffect()
27+
shadow.setBlurRadius(20)
28+
shadow.setColor(QColor(0, 0, 0, 160))
29+
shadow.setOffset(0, 0)
30+
31+
slider_frame.setGraphicsEffect(shadow)
32+
33+
layout.addWidget(slider_frame)
2134

2235
self.setLayout(layout)
2336

@@ -27,4 +40,11 @@ def change_font_size(self, size: int):
2740
QApplication.instance().setFont(font)
2841

2942
settings = QSettings("YourCompany", "YourApp")
30-
settings.setValue("fontSize", size)
43+
settings.setValue("fontSize", size)
44+
45+
def paintEvent(self, event):
46+
painter = QPainter(self)
47+
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
48+
painter.fillRect(self.rect(), QColor(0, 0, 0, 0))
49+
color = QColor(40, 40, 80, int(0.6 * 255))
50+
painter.fillRect(self.rect(), color)

presentation/widgets/trainer_widget.py

Lines changed: 16 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from PyQt6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QComboBox, QLabel, QFileDialog, QMessageBox
22
from PyQt6.QtCore import QSize, Qt
3+
from PyQt6.QtGui import QPainter, QColor
34
from presentation.widgets.setting_window import SettingsWindow
45
from infrastructure.data.dataset_loader import DatasetLoader
56
from core.model_trainer import ModelTrainer
@@ -8,54 +9,6 @@
89
from torchvision import transforms
910

1011
class TrainerWidget(QWidget):
11-
"""
12-
A QWidget-derived graphical interface facilitating the end-to-end workflow
13-
for training machine learning models. This widget integrates model selection,
14-
algorithm choice, dataset loading, model training, and model saving functionalities,
15-
tailored primarily for image and voice classification/segmentation tasks.
16-
17-
Attributes
18-
----------
19-
dataset : Any
20-
Holds the loaded dataset after user selection, to be consumed during training.
21-
model : Any
22-
Reference to the trained model instance after the training phase completes.
23-
model_label : QLabel
24-
Label prompting the user to choose the task type (e.g., classification, segmentation).
25-
model_combobox : QComboBox
26-
Dropdown menu populated with task types/models available for training.
27-
algorithm_label : QLabel
28-
Label prompting the user to select a specific algorithm based on the chosen task.
29-
algorithm_combobox : QComboBox
30-
Dropdown menu dynamically populated with algorithms compatible with the selected task.
31-
load_button : QPushButton
32-
Button to trigger the dataset loading dialog and process the chosen dataset.
33-
train_button : QPushButton
34-
Button to commence model training on the loaded dataset.
35-
save_button : QPushButton
36-
Button to save the trained model to disk.
37-
restart_label : QLabel
38-
Informative label guiding the user to restart the application post model saving.
39-
40-
Methods
41-
-------
42-
init_ui()
43-
Initializes and configures all UI components and their layout within the widget.
44-
update_model_section(index: int)
45-
Dynamically updates the algorithm selection UI elements based on the selected task type.
46-
style_combobox_on_selection(index: int)
47-
Placeholder method for styling combobox elements upon user interaction (currently no-op).
48-
algorithm_selected(index: int)
49-
Enables dataset loading when a valid algorithm is selected.
50-
load_dataset()
51-
Launches a dialog to select dataset folders, loads datasets with task-specific
52-
preprocessing, and prepares the system for training.
53-
train_model()
54-
Triggers the training process for the selected model and algorithm on the loaded dataset.
55-
save_model()
56-
Opens a file dialog to save the trained model to disk and updates the UI accordingly.
57-
"""
58-
5912
def __init__(self):
6013
"""
6114
Initializes the TrainerWidget instance, sets up attributes, and invokes UI setup.
@@ -141,8 +94,20 @@ def init_ui(self):
14194

14295
layout.addStretch()
14396
self.setLayout(layout)
144-
self.setWindowTitle("ML Model Trainer")
145-
97+
self.setWindowTitle("NexumAI")
98+
99+
def paintEvent(self, event):
100+
painter = QPainter(self)
101+
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
102+
painter.fillRect(self.rect(), QColor(0, 0, 0, 0))
103+
color = QColor(40, 40, 80, int(0.6 * 255))
104+
painter.fillRect(self.rect(), color)
105+
106+
def open_settings(self):
107+
self.settings_window = SettingsWindow()
108+
self.settings_window.setWindowOpacity(.80)
109+
self.settings_window.show()
110+
146111
def update_model_section(self, index):
147112
"""
148113
Adjusts the visibility and content of the algorithm selection UI elements
@@ -297,8 +262,4 @@ def save_model(self):
297262
self.save_button.setText("Saved Successfully")
298263
self.save_button.setEnabled(False)
299264
print("Model saved successfully.")
300-
self.restart_label.setVisible(True)
301-
302-
def open_settings(self):
303-
self.settings_window = SettingsWindow()
304-
self.settings_window.show()
265+
self.restart_label.setVisible(True)

0 commit comments

Comments
 (0)