src/eric7/MicroPython/WifiDialogs/WifiController.py

branch
eric7
changeset 9875
b4512fbcf567
parent 9872
6b8aa1c50c6d
child 9878
a82014a9e57b
--- a/src/eric7/MicroPython/WifiDialogs/WifiController.py	Sat Mar 11 11:53:44 2023 +0100
+++ b/src/eric7/MicroPython/WifiDialogs/WifiController.py	Sat Mar 11 11:57:49 2023 +0100
@@ -71,10 +71,8 @@
             self.tr("Deactivate Access Point Interface"),
             lambda: self.__deactivateInterface("AP"),
         )
-
-        if self.__mpy.getDevice().hasNetworkTime():
-            wifiMenu.addSeparator()
-            wifiMenu.addAction(self.tr("Set Network Time"), self.__setNetworkTime)
+        wifiMenu.addSeparator()
+        wifiMenu.addAction(self.tr("Set Network Time"), self.__setNetworkTime)
 
         # add device specific entries (if there are any)
         self.__mpy.getDevice().addDeviceWifiEntries(wifiMenu)
@@ -376,6 +374,28 @@
         """
         from ..NtpParametersDialog import NtpParametersDialog
 
+        device = self.__mpy.getDevice()
+        if not device.getDeviceData("ntp"):
+            if device.hasCircuitPython():
+                EricMessageBox.warning(
+                    None,
+                    self.tr("Set Network Time"),
+                    self.tr(
+                        "<p>The device does not support network time synchronization."
+                        " The module <b>adafruit_ntp</b> is not installed.</p>"
+                    ),
+                )
+            else:
+                EricMessageBox.critical(
+                    None,
+                    self.tr("Set Network Time"),
+                    self.tr(
+                        "<p>The device does not support network time synchronization."
+                        " The module <b>ntptime</b> is not available.</p>"
+                    ),
+                )
+            return
+
         dlg = NtpParametersDialog(self.__mpy)
         if dlg.exec() == QDialog.DialogCode.Accepted:
             server, tzOffset, isDst, timeout = dlg.getParameters()

eric ide

mercurial