eric6/MicroPython/MicroPythonReplWidget.py

branch
micropython
changeset 7133
7aa4832b3730
parent 7130
6014d37d9683
--- a/eric6/MicroPython/MicroPythonReplWidget.py	Mon Aug 12 14:54:06 2019 +0200
+++ b/eric6/MicroPython/MicroPythonReplWidget.py	Mon Aug 12 14:55:08 2019 +0200
@@ -10,6 +10,7 @@
 from __future__ import unicode_literals
 
 import re
+import time
 
 from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QPoint, QEvent
 from PyQt5.QtGui import QColor, QKeySequence, QTextCursor, QBrush
@@ -136,6 +137,7 @@
 }
 
 
+# TODO: add config option to synchronize the device time upon connect
 class MicroPythonReplWidget(QWidget, Ui_MicroPythonReplWidget):
     """
     Class implementing the MicroPython REPL widget.
@@ -1042,7 +1044,7 @@
             if not self.__interface.isConnected():
                 self.__connectToDevice()
             self.__fileManagerWidget = MicroPythonFileManagerWidget(
-                self.__interface, self.__device.supportsLocalFileAccess,
+                self.__interface, self.__device.supportsLocalFileAccess(),
                 self)
             
             self.__ui.addSideWidget(self.__ui.BottomSide,
@@ -1083,6 +1085,7 @@
         else:
             hasTime = False
         
+        # TODO: add menu entry to cross-compile a .py file (using mpy-cross)
         act = self.__superMenu.addAction(
             self.tr("Show Version"), self.__showDeviceVersion)
         act.setEnabled(self.__connected)
@@ -1095,8 +1098,10 @@
                 self.tr("Synchronize Time"), self.__synchronizeTime)
             act.setEnabled(self.__connected)
             act = self.__superMenu.addAction(
-                self.tr("Show Time"), self.__showDeviceTime)
+                self.tr("Show Device Time"), self.__showDeviceTime)
             act.setEnabled(self.__connected)
+            self.__superMenu.addAction(
+                self.tr("Show Local Time"), self.__showLocalTime)
             self.__superMenu.addSeparator()
         if self.__device:
             self.__device.addDeviceMenuEntries(self.__superMenu)
@@ -1158,6 +1163,7 @@
         except Exception as exc:
             self.__showError("getImplementation()", str(exc))
     
+    # TODO: show device time after sync
     @pyqtSlot()
     def __synchronizeTime(self):
         """
@@ -1204,6 +1210,25 @@
         except Exception as exc:
             self.__showError("getTime()", str(exc))
     
+    @pyqtSlot()
+    def __showLocalTime(self):
+        """
+        Private slot to show the local date and time.
+        """
+        localdatetime = time.localtime()
+        loacldate = time.strftime('%Y-%m-%d', localdatetime)
+        localtime = time.strftime('%H:%M:%S', localdatetime)
+        E5MessageBox.information(
+            self,
+            self.tr("Local Date and Time"),
+            self.tr("<h3>Local Date and Time</h3>"
+                    "<table>"
+                    "<tr><td><b>Date</b></td><td>{0}</td></tr>"
+                    "<tr><td><b>Time</b></td><td>{1}</td></tr>"
+                    "</table>"
+                    ).format(loacldate, localtime)
+        )
+    
     def __showError(self, method, error):
         """
         Private method to show some error message.

eric ide

mercurial