Init projet Photostation - borne impression photo tactile PyQt6
Structure : 4 écrans (accueil, import, éditeur, impression), navigation QStackedWidget, base éditeur QGraphicsScene. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
87
src/ui/screens/import_screen.py
Normal file
87
src/ui/screens/import_screen.py
Normal file
@@ -0,0 +1,87 @@
|
||||
"""Écran d'import — galerie de photos importées."""
|
||||
|
||||
from PyQt6.QtWidgets import (
|
||||
QWidget, QVBoxLayout, QHBoxLayout, QPushButton,
|
||||
QLabel, QScrollArea, QGridLayout
|
||||
)
|
||||
from PyQt6.QtCore import Qt
|
||||
from PyQt6.QtGui import QFont, QPixmap
|
||||
|
||||
|
||||
class ImportScreen(QWidget):
|
||||
def __init__(self, main_window):
|
||||
super().__init__()
|
||||
self.main_window = main_window
|
||||
self.photos = []
|
||||
self._setup_ui()
|
||||
|
||||
def _setup_ui(self):
|
||||
layout = QVBoxLayout(self)
|
||||
|
||||
# Header
|
||||
header = QHBoxLayout()
|
||||
back_btn = QPushButton("Retour")
|
||||
back_btn.setFont(QFont("", 14))
|
||||
back_btn.clicked.connect(self.main_window.show_home)
|
||||
header.addWidget(back_btn)
|
||||
|
||||
title = QLabel("Sélectionnez une photo")
|
||||
title.setFont(QFont("", 24, QFont.Weight.Bold))
|
||||
title.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
header.addWidget(title, 1)
|
||||
|
||||
header.addSpacing(80) # Balance le bouton retour
|
||||
layout.addLayout(header)
|
||||
|
||||
# Grille de photos (scrollable)
|
||||
scroll = QScrollArea()
|
||||
scroll.setWidgetResizable(True)
|
||||
scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
|
||||
|
||||
self.grid_widget = QWidget()
|
||||
self.grid_layout = QGridLayout(self.grid_widget)
|
||||
self.grid_layout.setSpacing(10)
|
||||
scroll.setWidget(self.grid_widget)
|
||||
|
||||
layout.addWidget(scroll)
|
||||
|
||||
def set_photos(self, photo_paths):
|
||||
"""Affiche les photos dans la grille."""
|
||||
# Clear existing
|
||||
while self.grid_layout.count():
|
||||
item = self.grid_layout.takeAt(0)
|
||||
if item.widget():
|
||||
item.widget().deleteLater()
|
||||
|
||||
self.photos = photo_paths
|
||||
cols = 4
|
||||
for i, path in enumerate(photo_paths):
|
||||
row, col = divmod(i, cols)
|
||||
thumb = self._create_thumbnail(path)
|
||||
self.grid_layout.addWidget(thumb, row, col)
|
||||
|
||||
def _create_thumbnail(self, path):
|
||||
btn = QPushButton()
|
||||
btn.setMinimumSize(180, 180)
|
||||
btn.setStyleSheet("""
|
||||
QPushButton {
|
||||
border: 3px solid transparent;
|
||||
border-radius: 10px;
|
||||
}
|
||||
QPushButton:pressed {
|
||||
border-color: #2196F3;
|
||||
}
|
||||
""")
|
||||
pixmap = QPixmap(path)
|
||||
if not pixmap.isNull():
|
||||
scaled = pixmap.scaled(
|
||||
170, 170,
|
||||
Qt.AspectRatioMode.KeepAspectRatio,
|
||||
Qt.TransformationMode.SmoothTransformation
|
||||
)
|
||||
btn.setIcon(scaled)
|
||||
from PyQt6.QtCore import QSize
|
||||
btn.setIconSize(QSize(170, 170))
|
||||
|
||||
btn.clicked.connect(lambda checked, p=path: self.main_window.show_editor(p))
|
||||
return btn
|
||||
Reference in New Issue
Block a user