From da3630347c6f68b6ff15e579a19bbaa9a612a704 Mon Sep 17 00:00:00 2001
From: Bastian Germann <bage@debian.org>
Date: Wed, 7 Oct 2026 22:29:50 +0200
Subject: [PATCH] Port to PyQt6

---
 Makefile                 |  2 +-
 debian/control           |  6 +++---
 debian/tests/control     |  6 +++---
 debian/tests/runtests.sh |  2 +-
 debian/tests/test_gui.py |  8 ++++----
 mainWindow.py            | 10 +++++-----
 matplotlib_widget.py     | 14 +++++++-------
 point.py                 |  6 +++---
 pysatellites.py          | 12 ++++++------
 rectangle_sensible.py    |  8 ++++----
 traj_satellite.py        | 18 +++++++++---------
 video.py                 |  6 +++---
 12 files changed, 49 insertions(+), 49 deletions(-)

diff --git a/Makefile b/Makefile
index 46228d7..aaccf8a 100644
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@ clean:
 user-interface: UI_pysat.py UI_graphe.py
 
 UI_%.py: %.ui
-	pyuic5 $< -o $@
+	pyuic6 $< -o $@
 
 install: all
 	mkdir -p $(DESTDIR)/usr/bin
diff --git a/debian/control b/debian/control
index d9ae902..92f4f3b 100644
--- a/debian/control
+++ b/debian/control
@@ -5,8 +5,8 @@ Maintainer: Georges Khaznadar <georgesk@debian.org>
 Build-Depends: debhelper-compat (=13),
  python3-all,
  dh-python,
- pyqt5-dev-tools,
- qttools5-dev-tools,
+ pyqt6-dev-tools,
+ qt6-tools-dev-tools,
  imagemagick,
  stellarium-data
 Standards-Version: 4.6.2
@@ -18,7 +18,7 @@ Architecture: all
 Depends: ${misc:Depends}, ${python3:Depends},
  ffmpeg,
  iceweasel| firefox-esr|www-browser,
- python3-pyqt5,
+ python3-pyqt6,
  xplanet,
  python3-matplotlib,
  python3-tk,
diff --git a/debian/tests/control b/debian/tests/control
index b9457ff..78e1d3c 100644
--- a/debian/tests/control
+++ b/debian/tests/control
@@ -2,15 +2,15 @@ Test-Command: make; for p in $(py3versions -s); do xvfb-run sh -c "$p -m pytest
 Depends:
  python3-all,
  python3-pytest,
- python3-pyqt5,
+ python3-pyqt6,
  python3-matplotlib,
  python3-tk,
  python3-numpy,
  python3-opencv,
  python3-pil,
  python3-scipy,
- pyqt5-dev-tools,
- qttools5-dev-tools,
+ pyqt6-dev-tools,
+ qt6-tools-dev-tools,
  python3-pytestqt,
  xplanet,
  xvfb,
diff --git a/debian/tests/runtests.sh b/debian/tests/runtests.sh
index e8fb4f3..f2f1e98 100755
--- a/debian/tests/runtests.sh
+++ b/debian/tests/runtests.sh
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-xvfb-run sh -c "PYTEST_QT_API=pyqt5 pytest debian/tests"
+xvfb-run sh -c "PYTEST_QT_API=pyqt6 pytest debian/tests"
diff --git a/debian/tests/test_gui.py b/debian/tests/test_gui.py
index 9b7fa22..17a94be 100644
--- a/debian/tests/test_gui.py
+++ b/debian/tests/test_gui.py
@@ -4,8 +4,8 @@ import sys, os, time
 PACKAGE_DIR = os.path.abspath(os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))))
 sys.path.insert(0, PACKAGE_DIR)
 
-from PyQt5 import QtCore
-from mainWindow import StartQT5
+from PyQt6 import QtCore
+from mainWindow import StartQT6
 from pytestqt.qt_compat import qt_api
 import pytest
 from PIL import Image
@@ -47,11 +47,11 @@ def normalize(arr):
 @pytest.mark.skipif(platform.machine() != 'x86_64',
                     reason="architecture is not amd64")
 def test_earth(qtbot):
-    mw = StartQT5(None)
+    mw = StartQT6(None)
     mw.show()
     qtbot.addWidget(mw)
     mw.ui.vitesse_tangentielle_objet.setText("-7400")
-    qtbot.mouseClick(mw.ui.Bouton_Lancer, QtCore.Qt.LeftButton)
+    qtbot.mouseClick(mw.ui.Bouton_Lancer, QtCore.Qt.MouseButton.LeftButton)
     time.sleep(3)
     figureCanvas = mw.ui.label_vitx.children()[0]
     buffer = BytesIO()
diff --git a/mainWindow.py b/mainWindow.py
index 87f4f40..5239d15 100644
--- a/mainWindow.py
+++ b/mainWindow.py
@@ -26,9 +26,9 @@ licence="""
 """
 
 import sys, os
-from PyQt5.QtCore import *
-from PyQt5.QtGui import *
-from PyQt5.QtWidgets import *
+from PyQt6.QtCore import *
+from PyQt6.QtGui import *
+from PyQt6.QtWidgets import *
 from glob import glob
 from UI_pysat  import Ui_MainWindow
 from traj_satellite  import Trajectoire
@@ -41,7 +41,7 @@ from video import Cinema
 import flottant as flottant
 from debug import Debug
 
-class StartQT5(QMainWindow):
+class StartQT6(QMainWindow):
     def __init__(self, parent, rep=None , debugger=Debug(1), app=None):
         QMainWindow.__init__(self)
         QWidget.__init__(self, parent)
@@ -118,7 +118,7 @@ class StartQT5(QMainWindow):
         self.placeDepart()
 
     def cinema(self):
-        if self.cinemaThread!=None and self.cinemaThread.isAlive():
+        if self.cinemaThread!=None and self.cinemaThread.is_alive():
             return
         import datetime,copy
         from numpy import arange
diff --git a/matplotlib_widget.py b/matplotlib_widget.py
index e24dcdc..2ad363f 100644
--- a/matplotlib_widget.py
+++ b/matplotlib_widget.py
@@ -9,11 +9,11 @@
 
 import sys, os, random
 from numpy import arange, sin, pi
-from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
+from matplotlib.backends.backend_qtagg import FigureCanvasQTAgg as FigureCanvas
 from matplotlib.figure import Figure
-from PyQt5.QtGui import *
-from PyQt5.QtWidgets import *
-from PyQt5.QtCore import *
+from PyQt6.QtGui import *
+from PyQt6.QtWidgets import *
+from PyQt6.QtCore import *
 from UI_graphe import Ui_Graphe
 
 progname = os.path.basename(sys.argv[0])
@@ -27,7 +27,7 @@ class MyMplCanvas(FigureCanvas):
         FigureCanvas.__init__(self, self.fig)
         self.setParent(parent)
         FigureCanvas.setSizePolicy(
-            self, QSizePolicy.Expanding, QSizePolicy.Expanding)
+            self, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
         FigureCanvas.updateGeometry(self)
         self.axes = self.fig.add_subplot(111)
         a = self.axes.set_axis_off()
@@ -62,10 +62,10 @@ class MyMplCanvas(FigureCanvas):
     def sizeHint(self):
         w, h = self.get_width_height()
         #print "w, h", w, h
-        return QtCore.QSize(w, h)
+        return QSize(w, h)
 
     def minimumSizeHint(self):
-        return QtCore.QSize(10, 10)
+        return QSize(10, 10)
     
     def plot(self,donnees, traitement, dates):
         d=[]
diff --git a/point.py b/point.py
index 960155c..3e4ad19 100644
--- a/point.py
+++ b/point.py
@@ -1,8 +1,8 @@
 #-*- coding: utf-8 -*-
 
-from PyQt5.QtGui import *
-from PyQt5.QtWidgets import *
-from PyQt5.QtCore import *
+from PyQt6.QtGui import *
+from PyQt6.QtWidgets import *
+from PyQt6.QtCore import *
 
 class Point(QLabel):
     def __init__(self, parent, point, color, numero, app, pred=None,type_de_point="petit"):
diff --git a/pysatellites.py b/pysatellites.py
index 7673399..d1bce89 100644
--- a/pysatellites.py
+++ b/pysatellites.py
@@ -31,11 +31,11 @@ licence_fr="""
 """
 
 import sys
-from PyQt5.QtGui import *
-from PyQt5.QtWidgets import *
-from PyQt5.QtCore import *
+from PyQt6.QtGui import *
+from PyQt6.QtWidgets import *
+from PyQt6.QtCore import *
 from debug import Debug
-from mainWindow import StartQT5
+from mainWindow import StartQT6
 
                 
 
@@ -70,9 +70,9 @@ def run():
         if cle=="-f" or cle=="--fichier":
             print ("On ne sait pas encore quoi faire de '%s', la fonctionnalité gouvernée par '%s' reste à implémenter." %(val,cle))
 
-    windows = StartQT5(None, debugger=debugger, app=app)
+    windows = StartQT6(None, debugger=debugger, app=app)
     windows.show()
-    sys.exit(app.exec_())
+    sys.exit(app.exec())
 
 if __name__ == "__main__":
     run()
diff --git a/rectangle_sensible.py b/rectangle_sensible.py
index e91cd71..3db6069 100644
--- a/rectangle_sensible.py
+++ b/rectangle_sensible.py
@@ -1,8 +1,8 @@
 # -*- coding: utf-8 -*-
 
-from PyQt5.QtGui import *
-from PyQt5.QtWidgets import *
-from PyQt5.QtCore import *
+from PyQt6.QtGui import *
+from PyQt6.QtWidgets import *
+from PyQt6.QtCore import *
 from debug import Debug
 
 class Rs(QWidget):
@@ -47,7 +47,7 @@ class Rs(QWidget):
         if self.onMove != None:
             return self.onMove(ev)
         else:
-            self.debug(9, "event onMove still to implement ... x=%s, y=%s" %(ev.x(),ev.y()))
+            self.debug(9, "event onMove still to implement ... x=%s, y=%s" %(ev.position().x(),ev.position().y()))
     def mouseDoubleClickEvent(self,ev):
         if self.onDoubleClick != None:
             return self.onDoubleClick(ev)
diff --git a/traj_satellite.py b/traj_satellite.py
index 97c4e30..52ffb4c 100644
--- a/traj_satellite.py
+++ b/traj_satellite.py
@@ -7,9 +7,9 @@
 
 from numpy import *
 from pylab import *
-from PyQt5.QtGui import *
-from PyQt5.QtWidgets import *
-from PyQt5.QtCore import *
+from PyQt6.QtGui import *
+from PyQt6.QtWidgets import *
+from PyQt6.QtCore import *
 from point import Point
 import os, tempfile, time
 from matplotlib_widget import MyMplCanvas
@@ -244,7 +244,7 @@ class Trajectoire(Rs):
             t=self.tr("Ce n'est pas un satellite")
             q=self.tr("L'énergie mécanique initiale est positive, l'objet lancé échappera à l'attraction de l'astre. Voulez-vous tracer une partie de la trajectoire ?")
             ret=QMessageBox.question (self, t, q)
-            if ret==QMessageBox.Yes:
+            if ret==QMessageBox.StandardButton.Yes:
                 self.t=30*(self.distance_astre**3/self.masse_astre/self.G)**0.5
                 self.dt=self.t/100
             else:
@@ -274,7 +274,7 @@ class Trajectoire(Rs):
             t=self.tr("Changement d'échelle")
             q=self.tr("Un dépassement a été détecté. Voulez-vous changer d'échelle ?")
             ret=QMessageBox.question (self, t, q)
-            if ret==QMessageBox.Yes:
+            if ret==QMessageBox.StandardButton.Yes:
                 self.setEchelle(r,"max")
                 self.efface()
                 self.dessine(self.traj.pv)
@@ -359,8 +359,8 @@ class Trajectoire(Rs):
     def paintEvent(self, event):
         painter = QPainter()
         painter.begin(self)
-        painter.setBrush(Qt.CrossPattern)
-        painter.setPen(Qt.green)
+        painter.setBrush(Qt.BrushStyle.CrossPattern)
+        painter.setPen(Qt.GlobalColor.green)
 	
         rayon=int(self.mainWin.getRayonAstre()/self.echelle)
         painter.drawLine(round(self.milieuX), 0, round(self.milieuX),
@@ -413,8 +413,8 @@ class Satellite(QLabel):
         self.image = image
     def paintEvent(self, event):
         painter = QPainter()
-        painter.setBrush(Qt.CrossPattern)
-        painter.setPen(Qt.green)
+        painter.setBrush(Qt.BrushStyle.CrossPattern)
+        painter.setPen(Qt.GlobalColor.green)
         painter.begin(self)
         x, y = self.coord_sat.x(), self.coord_sat.y()
         self.debug(5,"%s,%s" %(x,y))
diff --git a/video.py b/video.py
index ba78f2d..cd8a802 100644
--- a/video.py
+++ b/video.py
@@ -7,8 +7,8 @@ tableau de positions-vitesses tel que pysatellite peut le réaliser.
 
 import math, datetime, tempfile, os.path, os
 from astres import Astre
-from PyQt5.QtGui import *
-from PyQt5.QtWidgets import *
+from PyQt6.QtGui import *
+from PyQt6.QtWidgets import *
 from threading import *
 from debug import Debug
 import flottant as flottant
@@ -62,7 +62,7 @@ class Cinema(Thread):
         for n in range(20):
             nomfichier=os.path.join(self.dir, "%04d.jpg" %(num+n))
             (w,h)=self.geometrie.split("x")
-            img=QImage(int(w), int(h), QImage.Format_RGB32)
+            img=QImage(int(w), int(h), QImage.Format.Format_RGB32)
             img.fill(QColor("red").rgb())
             img.save(nomfichier)
     
