This commit is contained in:
2026-03-02 23:05:11 +01:00
parent 0ce305d76c
commit 0922014ae8
10 changed files with 18051 additions and 33 deletions

View File

@@ -1,27 +1,54 @@
import sys
import os
from PyQt6 import QtCore, QtGui, QtWidgets
from PyQt6 import QtGui, QtWidgets
from PyQt6 import uic
from PyQt6.QtCore import Qt
from PyQt6.QtGui import QFontDatabase, QFont
from PyQt6.QtWidgets import QApplication, QMainWindow
# Compile resources.qrc into resources_rc.py
# rcc -g python resources.qrc -o resources_rc.py
import resources # This is generated from the .qrc file
# À placer tout en haut, avant les imports PyQt6 si possible
os.environ["QT_QPA_PLATFORM"] = "xcb"
if sys.platform.startswith('linux'):
os.environ["QT_QPA_PLATFORM"] = "xcb"
class MainWindow(QtWidgets.QMainWindow):
def load_custom_font():
# Load font from Qt resource
font_id = QFontDatabase.addApplicationFont(":/assets/Avocado-Cake-Demo.otf")
if font_id == -1:
raise RuntimeError("Failed to load font from resources.")
# Get the family name of the loaded font
font_families = QFontDatabase.applicationFontFamilies(font_id)
if not font_families:
raise RuntimeError("No font families found in the loaded font.")
return font_families[0]
class MainWindow(QMainWindow):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Remove the title bar and window frame
self.setWindowFlags(Qt.WindowType.FramelessWindowHint)
self.setWindowFlags(Qt.WindowType.FramelessWindowHint |Qt.WindowType.Window)
# Optional: Make background transparent (if you want rounded corners, etc.)
# self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
# Track mouse position for dragging
self._drag_pos = None
# Load font family from resource
font_family = load_custom_font()
uic.loadUi("mainwindow.ui", self)
# Adjust UI
self.maintitle_label.setFont(QFont(font_family, 38))
self.subtitle_label.setStyleSheet("color: rgb(163, 177, 198)")
# Find the button by its objectName in Qt Designer
# Example: objectName = "close_btn"
self.close_btn.clicked.connect(self.close_link)
@@ -53,8 +80,14 @@ class MainWindow(QtWidgets.QMainWindow):
event.accept()
app = QtWidgets.QApplication(sys.argv)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec()
# Load and set the global font
custom_font = QFont(load_custom_font(), 16)
if custom_font:
app.setFont(custom_font)
window = MainWindow()
window.show()
sys.exit(app.exec())