neon_label.py
1 ''' 2 SuperFormat is a program that converts files into various formats 3 Copyright (C) 2025 daroi 4 5 This program is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <https://www.gnu.org/licenses/>. 17 ''' 18 19 from PyQt6.QtWidgets import QLabel, QGraphicsDropShadowEffect 20 from PyQt6.QtGui import QColor, QFont 21 from PyQt6.QtCore import Qt 22 23 # Personalized label 24 class NeonLabel(QLabel): 25 # Builder 26 def __init__(self, text: str, font_size: int = 20, bold: bool = True, color: str = "#c77dff"): 27 super().__init__(text) 28 29 # this center the text 30 self.setAlignment(Qt.AlignmentFlag.AlignCenter) 31 32 # Identifier in the qss 33 self.setObjectName("NeonLabel") 34 35 # Personalized font 36 font = QFont() 37 font.setPointSize(font_size) 38 font.setBold(bold) 39 self.setFont(font) 40 41 # Neon shadow 42 shadow = QGraphicsDropShadowEffect() 43 shadow.setColor(QColor(color)) 44 shadow.setBlurRadius(20) 45 shadow.setOffset(0, 0) 46 self.setGraphicsEffect(shadow) 47