first commit

This commit is contained in:
2026-03-02 17:39:26 +01:00
commit 0ce305d76c
5 changed files with 441 additions and 0 deletions

60
mainwindow.py Normal file
View File

@@ -0,0 +1,60 @@
import sys
import os
from PyQt6 import QtCore, QtGui, QtWidgets
from PyQt6 import uic
from PyQt6.QtCore import Qt
# À placer tout en haut, avant les imports PyQt6 si possible
os.environ["QT_QPA_PLATFORM"] = "xcb"
class MainWindow(QtWidgets.QMainWindow):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Remove the title bar and window frame
self.setWindowFlags(Qt.WindowType.FramelessWindowHint)
# Optional: Make background transparent (if you want rounded corners, etc.)
# self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
# Track mouse position for dragging
self._drag_pos = None
uic.loadUi("mainwindow.ui", self)
# Find the button by its objectName in Qt Designer
# Example: objectName = "close_btn"
self.close_btn.clicked.connect(self.close_link)
self.minimize_btn.clicked.connect(self.minimize_link)
def close_link(self):
sys.exit(app.exec())
def minimize_link(self):
# Minimize the application
self.setWindowState(Qt.WindowState.WindowMinimized)
# Mouse press event to start dragging
def mousePressEvent(self, event):
if event.button() == Qt.MouseButton.LeftButton:
self._drag_pos = event.globalPosition().toPoint() - self.frameGeometry().topLeft()
event.accept()
# Mouse move event to drag window
def mouseMoveEvent(self, event):
if event.buttons() == Qt.MouseButton.LeftButton and self._drag_pos is not None:
self.move(event.globalPosition().toPoint() - self._drag_pos)
event.accept()
# Mouse release event to stop dragging
def mouseReleaseEvent(self, event):
self._drag_pos = None
event.accept()
app = QtWidgets.QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec()