From 69480338e8060a8b78fe6f019872af7f52e1401e Mon Sep 17 00:00:00 2001 From: mhz1g21 <mhz1g21@soton.ac.uk> Date: Tue, 26 Nov 2024 15:07:43 +0000 Subject: [PATCH] small ui improvements: added colour to buttons --- scripts/simple_tab.py | 96 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 90 insertions(+), 6 deletions(-) diff --git a/scripts/simple_tab.py b/scripts/simple_tab.py index a80dae8..8602d6b 100644 --- a/scripts/simple_tab.py +++ b/scripts/simple_tab.py @@ -1,7 +1,7 @@ from PyQt6.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout, QGroupBox, QCheckBox, QMessageBox, QPushButton, QProgressBar) -from PyQt6.QtCore import Qt, QThread, pyqtSignal +from PyQt6.QtCore import Qt, QThread, pyqtSignal, QTimer import os import sys @@ -149,7 +149,10 @@ class SimpleTab(QWidget): self.depth.hide() self.material.hide() self.edge_net.hide() - + + self.file_selected = False + self.flash_timer = QTimer(self) + self.flash_timer.timeout.connect(self.toggle_flash) self.setup_ui() def setup_ui(self): @@ -165,15 +168,18 @@ class SimpleTab(QWidget): ("Status:", "Ready") ] self.info_group, self.info_labels = create_info_group("Information", info_rows) + self.info_group.setStyleSheet("QGroupBox { font-weight: bold; }") controls_layout.addWidget(self.info_group) # Options options_layout = QHBoxLayout() self.include_top_check = QCheckBox("Include Top in Mesh") + self.include_top_check.setStyleSheet("QCheckBox { margin: 5px; }") options_layout.addWidget(self.include_top_check) self.shift_image_check = QCheckBox("Shift Input Image") + self.shift_image_check.setStyleSheet("QCheckBox { margin: 5px; }") options_layout.addWidget(self.shift_image_check) controls_layout.addLayout(options_layout) @@ -183,18 +189,44 @@ class SimpleTab(QWidget): self.progress_bar.setMinimum(0) self.progress_bar.setMaximum(0) # Makes it an indefinite progress bar self.progress_bar.hide() # Hidden by default + self.progress_bar.setStyleSheet(""" + QProgressBar { + border: 2px solid grey; + border-radius: 5px; + text-align: center; + } + QProgressBar::chunk { + background-color: #05B8CC; + width: 20px; + } + """) controls_layout.addWidget(self.progress_bar) # Buttons self.run_pipeline_btn = QPushButton("Run Pipeline") self.run_pipeline_btn.clicked.connect(self.run_full_pipeline) self.run_pipeline_btn.setEnabled(False) # Disabled by default + self.run_pipeline_btn.setStyleSheet(""" + QPushButton { + margin: 5px; + padding: 5px; + } + QPushButton:enabled { + background-color: green; + color: white; + } + QPushButton:disabled { + background-color: red; + color: white; + } + """) buttons_layout = QHBoxLayout() - select_btn = QPushButton("Select Input Image") - select_btn.clicked.connect(self.handle_file_select) + self.select_btn = QPushButton("Select Input Image") + self.select_btn.clicked.connect(self.handle_file_select) + self.select_btn.setStyleSheet("QPushButton { margin: 5px; padding: 5px; }") - buttons_layout.addWidget(select_btn) + buttons_layout.addWidget(self.select_btn) buttons_layout.addWidget(self.run_pipeline_btn) controls_layout.addLayout(buttons_layout) @@ -202,19 +234,56 @@ class SimpleTab(QWidget): # Status section status_group, self.status_text = create_group_with_text("Pipeline Status", 150) + status_group.setStyleSheet(""" + QGroupBox { + font-weight: bold; + border: 2px solid grey; + border-radius: 5px; + margin-top: 10px; + } + QLabel { + margin: 5px; + } + """) layout.addWidget(status_group) # Preview section preview_group = QGroupBox("Preview") + preview_group.setStyleSheet(""" + QGroupBox { + font-weight: bold; + border: 2px solid grey; + border-radius: 5px; + margin-top: 10px; + } + """) preview_layout = QHBoxLayout(preview_group) input_group, self.input_preview = create_preview_group("Input Image") output_group, self.output_preview = create_preview_group("Current Output") - + input_group.setStyleSheet(""" + QGroupBox { + font-weight: bold; + border: 1px solid grey; + border-radius: 5px; + margin: 5px; + } + """) + output_group.setStyleSheet(""" + QGroupBox { + font-weight: bold; + border: 1px solid grey; + border-radius: 5px; + margin: 5px; + } + """) preview_layout.addWidget(input_group) preview_layout.addWidget(output_group) layout.addWidget(preview_group) + # Start flashing if no file is selected + self.start_flashing() + def handle_file_select(self): file_path = select_file( @@ -239,6 +308,21 @@ class SimpleTab(QWidget): self.depth.depth_input_path = file_path self.material.input_file_path = file_path # self.edge_net.input_path = file_path # edgenet have default input path + + self.file_selected = True + self.flash_timer.stop() + self.select_btn.setStyleSheet("QPushButton { margin: 5px; padding: 5px; }") + + def start_flashing(self): + if not self.file_selected: + self.flash_timer.start(1000) # Flash every 1000 milliseconds + + def toggle_flash(self): + current_style = self.select_btn.styleSheet() + if "background-color: DarkOrange;" in current_style: + self.select_btn.setStyleSheet("QPushButton { margin: 5px; padding: 5px; }") + else: + self.select_btn.setStyleSheet("QPushButton { margin: 5px; padding: 5px; background-color: DarkOrange; }") def run_full_pipeline(self): if not self.input_path: -- GitLab