From 69a31e153fc182b7d93d38beb384d91cbdda2b09 Mon Sep 17 00:00:00 2001 From: bartool Date: Sat, 6 Sep 2025 17:46:17 +0200 Subject: [PATCH] first ui widget placement --- main.py | 15 +++++++++ ui/main_window.py | 55 ++++++++++++++++++++++++++++++++ ui/widgets/placeholder_widget.py | 35 ++++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 main.py create mode 100644 ui/main_window.py create mode 100644 ui/widgets/placeholder_widget.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..4771596 --- /dev/null +++ b/main.py @@ -0,0 +1,15 @@ +import sys +from PySide6.QtWidgets import QApplication + +from ui.main_window import MainWindow + + + +def main(): + app = QApplication(sys.argv) + window = MainWindow() + window.show() + sys.exit(app.exec()) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/ui/main_window.py b/ui/main_window.py new file mode 100644 index 0000000..57b9298 --- /dev/null +++ b/ui/main_window.py @@ -0,0 +1,55 @@ +import sys +from PySide6.QtWidgets import ( + QApplication, QMainWindow, QWidget, QVBoxLayout, QHBoxLayout, + QPushButton, QLabel, QSplitter, QStackedWidget, QLineEdit +) +from PySide6.QtCore import Qt, Slot +from PySide6.QtGui import QPalette, QColor + +from ui.widgets.placeholder_widget import PlaceholderWidget + +class MainWindow(QMainWindow): + def __init__(self): + super().__init__() + self.setWindowTitle("Mayo Stain Helper") + self.resize(1920, 1080) + self.setup_ui() + + def setup_ui(self): + # Central widget and main layout + central_widget = QWidget() + main_layout = QHBoxLayout(central_widget) + self.setCentralWidget(central_widget) + + self.preview_widget = QSplitter(Qt.Orientation.Vertical) + self.preview_widget.addWidget(PlaceholderWidget("Camera View", "#750466")) + self.preview_widget.addWidget(PlaceholderWidget("Image View", "#007981")) + + self.thumbnail_widget = PlaceholderWidget("Thumbnails", "#AAAAAA") + self.thumbnail_widget.setFixedWidth(200) + + # self.control_widget = PlaceholderWidget("Controls", "#CCCCCC") + self.control_widget = QWidget() + self.control_widget.setFixedWidth(300) + # self.control_widget.setContentsMargins(0, 0, 0, 0) + + main_layout.addWidget(self.preview_widget) + main_layout.addWidget(self.thumbnail_widget) + main_layout.addWidget(self.control_widget) + + control_layout = QVBoxLayout(self.control_widget) + control_layout.setContentsMargins(0, 0, 0, 0) + histogram_view = PlaceholderWidget("Histogram View", "#FF5733") + histogram_view.setFixedHeight(200) + control_layout.addWidget(histogram_view) + + control_layout.addStretch() + + + + + + + + + diff --git a/ui/widgets/placeholder_widget.py b/ui/widgets/placeholder_widget.py new file mode 100644 index 0000000..d1bc37b --- /dev/null +++ b/ui/widgets/placeholder_widget.py @@ -0,0 +1,35 @@ +from PySide6.QtWidgets import QWidget, QLabel, QVBoxLayout +from PySide6.QtGui import QPalette, QColor +from PySide6.QtCore import Qt + +class PlaceholderWidget(QWidget): + """A custom widget to display a colored background with centered text.""" + def __init__(self, text: str, color: str, parent=None): + super().__init__(parent) + self.setAutoFillBackground(True) + self.set_color(color) + + self.label = QLabel(text) + self.label.setAlignment(Qt.AlignmentFlag.AlignCenter) + + font = self.label.font() + font.setPointSize(24) + self.label.setFont(font) + self.label.setWordWrap(True) + + layout = QVBoxLayout(self) + layout.addWidget(self.label) + self.setLayout(layout) + + def set_text(self, text: str): + self.label.setText(text) + + def set_color(self, color: str): + palette = self.palette() + palette.setColor(QPalette.ColorRole.Window, QColor(color)) + self.setPalette(palette) + + def set_text_color(self, color: str): + palette = self.label.palette() + palette.setColor(QPalette.ColorRole.WindowText, QColor(color)) + self.label.setPalette(palette)