first ui widget placement
This commit is contained in:
15
main.py
Normal file
15
main.py
Normal file
@@ -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()
|
||||
55
ui/main_window.py
Normal file
55
ui/main_window.py
Normal file
@@ -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()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
35
ui/widgets/placeholder_widget.py
Normal file
35
ui/widgets/placeholder_widget.py
Normal file
@@ -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)
|
||||
Reference in New Issue
Block a user