Files
test-main/views/widgets/platform_button.py
Claude Project Manager 08ed938105 Initial commit
2025-07-03 21:11:05 +02:00

76 Zeilen
2.5 KiB
Python

# Path: views/widgets/platform_button.py
"""
Benutzerdefinierter Button für die Plattformauswahl.
"""
import os
from PyQt5.QtWidgets import QPushButton, QVBoxLayout, QLabel, QWidget
from PyQt5.QtCore import QSize, Qt, pyqtSignal
from PyQt5.QtGui import QIcon, QFont
class PlatformButton(QWidget):
"""Angepasster Button-Widget für Plattformauswahl mit Icon."""
# Signal wenn geklickt
clicked = pyqtSignal()
def __init__(self, platform_name, icon_path=None, enabled=True):
super().__init__()
self.platform = platform_name.lower()
self.setMinimumSize(200, 200)
self.setEnabled(enabled)
# Layout für den Container
layout = QVBoxLayout(self)
layout.setAlignment(Qt.AlignCenter)
layout.setContentsMargins(10, 10, 10, 10)
# Icon-Button
self.icon_button = QPushButton()
self.icon_button.setFlat(True)
self.icon_button.setCursor(Qt.PointingHandCursor)
# Icon setzen, falls vorhanden
if icon_path and os.path.exists(icon_path):
self.icon_button.setIcon(QIcon(icon_path))
self.icon_button.setIconSize(QSize(120, 120)) # Größeres Icon
self.icon_button.setMinimumSize(150, 150)
self.icon_button.setStyleSheet("""
QPushButton {
background-color: transparent;
border: none;
}
QPushButton:hover {
background-color: rgba(200, 200, 200, 50);
border-radius: 10px;
}
QPushButton:pressed {
background-color: rgba(150, 150, 150, 80);
}
QPushButton:disabled {
opacity: 0.5;
}
""")
# Button-Signal verbinden
self.icon_button.clicked.connect(self.clicked)
# Name-Label
self.name_label = QLabel(platform_name)
self.name_label.setAlignment(Qt.AlignCenter)
name_font = QFont()
name_font.setPointSize(12)
name_font.setBold(True)
self.name_label.setFont(name_font)
self.name_label.setStyleSheet("color: black;") # Schwarzer Text
# Widgets zum Layout hinzufügen
layout.addWidget(self.icon_button, 0, Qt.AlignCenter)
layout.addWidget(self.name_label, 0, Qt.AlignCenter)
# Styling für den deaktivierten Zustand
if not enabled:
self.setStyleSheet("opacity: 0.5;")