src/eric7/MicroPython/Devices/TeensyDevices.py

branch
mpy_network
changeset 9820
67597e003373
parent 9765
6378da868bb0
child 9927
fa258d559f01
--- a/src/eric7/MicroPython/Devices/TeensyDevices.py	Mon Feb 27 16:55:09 2023 +0100
+++ b/src/eric7/MicroPython/Devices/TeensyDevices.py	Mon Feb 27 17:43:11 2023 +0100
@@ -7,8 +7,8 @@
 Module implementing the device interface class for Teensy boards with MicroPython.
 """
 
-from PyQt6.QtCore import QProcess, QUrl, pyqtSlot
-from PyQt6.QtNetwork import QNetworkRequest
+from PyQt6.QtCore import QCoreApplication, QProcess, QUrl, pyqtSlot
+from PyQt6.QtNetwork import QNetworkReply, QNetworkRequest
 from PyQt6.QtWidgets import QMenu
 
 from eric7 import Globals, Preferences
@@ -148,10 +148,10 @@
         )
         self.__teensyMenu.addSeparator()
         self.__teensyMenu.addAction(
-            self.tr("MicroPython Flash Instructions"), self.__showFlashInstructions
+            self.tr("MicroPython Flash Instructions"), showTeensyFlashInstructions
         )
         self.__flashMpyAct = self.__teensyMenu.addAction(
-            self.tr("Flash MicroPython Firmware"), self.__startTeensyLoader
+            self.tr("Flash MicroPython Firmware"), startTeensyLoader
         )
         self.__flashMpyAct.setToolTip(
             self.tr("Start the 'Teensy Loader' application to flash the Teensy device.")
@@ -195,9 +195,10 @@
                 reply = ui.networkAccessManager().head(request)
                 reply.finished.connect(lambda: self.__firmwareVersionResponse(reply))
 
+    @pyqtSlot(QNetworkReply)
     def __firmwareVersionResponse(self, reply):
         """
-        Private method handling the response of the latest version request.
+        Private slot handling the response of the latest version request.
 
         @param reply reference to the reply object
         @type QNetworkReply
@@ -232,40 +233,6 @@
             msg,
         )
 
-    def __showFlashInstructions(self):
-        """
-        Private method to show a message box with instruction to flash the Teensy.
-        """
-        EricMessageBox.information(
-            self.microPython,
-            self.tr("Flash MicroPython Firmware"),
-            self.tr(
-                """<p>Teensy 4.0 and Teensy 4.1 are flashed using the 'Teensy Loader'"""
-                """ application. Make sure you downloaded the MicroPython or"""
-                """ CircuitPython .hex file.</p>"""
-                """<p>See <a href="{0}">the PJRC Teensy web site</a>"""
-                """ for details.</p>"""
-            ).format("https://www.pjrc.com/teensy/loader.html"),
-        )
-
-    def __startTeensyLoader(self):
-        """
-        Private method to start the 'Teensy Loader' application.
-
-        Note: The application must be accessible via the application search path.
-        """
-        ok, _ = QProcess.startDetached("teensy")
-        if not ok:
-            EricMessageBox.warning(
-                self.microPython,
-                self.tr("Start 'Teensy Loader'"),
-                self.tr(
-                    """<p>The 'Teensy Loader' application <b>teensy</b> could not"""
-                    """ be started. Ensure it is in the application search path or"""
-                    """ start it manually.</p>"""
-                ),
-            )
-
     ##################################################################
     ## time related methods below
     ##################################################################
@@ -322,3 +289,43 @@
     @rtype PyBoardDevice
     """
     return TeensyDevice(microPythonWidget, deviceType)
+
+
+@pyqtSlot()
+def showTeensyFlashInstructions():
+    """
+    Slot to show a message box with instruction to flash the Teensy.
+    """
+    EricMessageBox.information(
+        None,
+        QCoreApplication.translate("TeensyDevice", "Flash MicroPython Firmware"),
+        QCoreApplication.translate(
+            "TeensyDevice",
+            """<p>Teensy 4.0 and Teensy 4.1 are flashed using the 'Teensy Loader'"""
+            """ application. Make sure you downloaded the MicroPython or"""
+            """ CircuitPython .hex file.</p>"""
+            """<p>See <a href="{0}">the PJRC Teensy web site</a>"""
+            """ for details.</p>""",
+        ).format("https://www.pjrc.com/teensy/loader.html"),
+    )
+
+
+@pyqtSlot()
+def startTeensyLoader():
+    """
+    Slot to start the 'Teensy Loader' application.
+
+    Note: The application must be accessible via the application search path.
+    """
+    ok, _ = QProcess.startDetached("teensy")
+    if not ok:
+        EricMessageBox.warning(
+            None,
+            QCoreApplication.translate("TeensyDevice", "Start 'Teensy Loader'"),
+            QCoreApplication.translate(
+                "TeensyDevice",
+                """<p>The 'Teensy Loader' application <b>teensy</b> could not"""
+                """ be started. Ensure it is in the application search path or"""
+                """ start it manually.</p>""",
+            ),
+        )

eric ide

mercurial