import sys from PyQt6.QtWidgets import QApplication, QLabel, QVBoxLayout, QHBoxLayout, QPushButton, QWidget, QFileDialog, QSlider, QLineEdit from PyQt6.QtGui import QPixmap, QImage, QColor, QPainter, QPen from PyQt6.QtCore import Qt, QPoint, QThread import cv2 import numpy as np from ImageCanvas import ImageCanvas from ImageProcessingWorker import ImageProcessingWorker from ImageManager import ImageManager from ImageManagePanel import ImageManagePanel from DialogsPanel import DialogsPanel class ImageEditor(QWidget): def __init__(self): super().__init__() self.setWindowTitle("Image Editor") self.setGeometry(100, 100, 800, 600) self.canvas = ImageCanvas() self.img_manager = ImageManagePanel() self.img_manager.on_update.connect(self.display_image) self.img_manager.on_close.connect(lambda : self.canvas.clear()) self.dialogs_panel = DialogsPanel(self.img_manager.mgr) self.dialogs_panel.result_ready.connect(self.display_image) main_layout = QHBoxLayout() side_panel = QVBoxLayout() side_panel.addWidget(self.img_manager, 1) side_panel.addWidget(self.dialogs_panel, 9) preview_panel = QVBoxLayout() preview_panel.addWidget(self.canvas) main_layout.addLayout(side_panel,2) main_layout.addLayout(preview_panel, 3) self.setLayout(main_layout) def display_image(self, image, first_load = False): height, width, channel = image.shape bytes_per_line = 3 * width self.canvas.updatePixmap(QImage(image.data, width, height, bytes_per_line, QImage.Format.Format_RGB888)) if first_load: self.canvas.reset() if __name__ == "__main__": app = QApplication(sys.argv) editor = ImageEditor() editor.show() sys.exit(app.exec())