eric6/MicroPython/MicroPythonWidget.py

changeset 8061
979562f350bf
parent 8055
52fdd41517f3
child 8067
a467ab075be0
equal deleted inserted replaced
8060:78aea20be1ec 8061:979562f350bf
21 21
22 from E5Gui.E5ZoomWidget import E5ZoomWidget 22 from E5Gui.E5ZoomWidget import E5ZoomWidget
23 from E5Gui import E5MessageBox, E5FileDialog 23 from E5Gui import E5MessageBox, E5FileDialog
24 from E5Gui.E5Application import e5App 24 from E5Gui.E5Application import e5App
25 from E5Gui.E5ProcessDialog import E5ProcessDialog 25 from E5Gui.E5ProcessDialog import E5ProcessDialog
26 from E5Gui.E5OverrideCursor import E5OverrideCursor, E5OverridenCursor
26 27
27 from .Ui_MicroPythonWidget import Ui_MicroPythonWidget 28 from .Ui_MicroPythonWidget import Ui_MicroPythonWidget
28 29
29 from . import MicroPythonDevices 30 from . import MicroPythonDevices
30 try: 31 try:
571 """ 572 """
572 Private slot to connect to the selected device or disconnect from the 573 Private slot to connect to the selected device or disconnect from the
573 currently connected device. 574 currently connected device.
574 """ 575 """
575 if self.__connected: 576 if self.__connected:
576 self.__disconnectFromDevice() 577 with E5OverrideCursor():
578 self.__disconnectFromDevice()
577 579
578 if self.replButton.isChecked(): 580 if self.replButton.isChecked():
579 self.on_replButton_clicked(False) 581 self.on_replButton_clicked(False)
580 if self.filesButton.isChecked(): 582 if self.filesButton.isChecked():
581 self.on_filesButton_clicked(False) 583 self.on_filesButton_clicked(False)
582 if self.chartButton.isChecked(): 584 if self.chartButton.isChecked():
583 self.on_chartButton_clicked(False) 585 self.on_chartButton_clicked(False)
584 else: 586 else:
585 self.__connectToDevice() 587 with E5OverrideCursor():
588 self.__connectToDevice()
586 589
587 @pyqtSlot() 590 @pyqtSlot()
588 def __clear(self): 591 def __clear(self):
589 """ 592 """
590 Private slot to clear the REPL pane. 593 Private slot to clear the REPL pane.
595 @pyqtSlot() 598 @pyqtSlot()
596 def __paste(self): 599 def __paste(self):
597 """ 600 """
598 Private slot to perform a paste operation. 601 Private slot to perform a paste operation.
599 """ 602 """
603 # add support for paste by mouse middle button
600 clipboard = QApplication.clipboard() 604 clipboard = QApplication.clipboard()
601 if clipboard: 605 if clipboard:
602 pasteText = clipboard.text() 606 pasteText = clipboard.text()
603 if pasteText: 607 if pasteText:
604 pasteText = pasteText.replace('\n\r', '\r') 608 pasteText = pasteText.replace('\n\r', '\r')
685 index = 0 689 index = 0
686 while index < len(data): 690 while index < len(data):
687 if data[index] == 8: # \b 691 if data[index] == 8: # \b
688 tc.movePosition(QTextCursor.Left) 692 tc.movePosition(QTextCursor.Left)
689 self.replEdit.setTextCursor(tc) 693 self.replEdit.setTextCursor(tc)
690 elif data[index] == 13: # \r 694 elif data[index] in (4, 13): # EOT, \r
691 pass 695 pass
692 elif (len(data) > index + 1 and 696 elif (len(data) > index + 1 and
693 data[index] == 27 and 697 data[index] == 27 and
694 data[index + 1] == 91): 698 data[index + 1] == 91):
695 # VT100 cursor command detected: <Esc>[ 699 # VT100 cursor command detected: <Esc>[
926 930
927 if (Preferences.getMicroPython("SyncTimeAfterConnect") and 931 if (Preferences.getMicroPython("SyncTimeAfterConnect") and
928 self.__device.hasTimeCommands()): 932 self.__device.hasTimeCommands()):
929 self.__synchronizeTime(quiet=True) 933 self.__synchronizeTime(quiet=True)
930 else: 934 else:
931 E5MessageBox.warning( 935 with E5OverridenCursor():
932 self, 936 E5MessageBox.warning(
933 self.tr("Serial Device Connect"), 937 self,
934 self.tr("""<p>Cannot connect to device at serial port""" 938 self.tr("Serial Device Connect"),
935 """ <b>{0}</b>.</p>""").format(port)) 939 self.tr("""<p>Cannot connect to device at serial port"""
940 """ <b>{0}</b>.</p>""").format(port))
936 941
937 def __disconnectFromDevice(self): 942 def __disconnectFromDevice(self):
938 """ 943 """
939 Private method to disconnect from the device. 944 Private method to disconnect from the device.
940 """ 945 """
1306 """ 1311 """
1307 try: 1312 try:
1308 self.__interface.syncTime() 1313 self.__interface.syncTime()
1309 1314
1310 if not quiet: 1315 if not quiet:
1311 E5MessageBox.information( 1316 with E5OverridenCursor():
1312 self, 1317 E5MessageBox.information(
1313 self.tr("Synchronize Time"), 1318 self,
1314 self.tr("<p>The time of the connected device was" 1319 self.tr("Synchronize Time"),
1315 " synchronized with the local time.</p>") + 1320 self.tr("<p>The time of the connected device was"
1316 self.__getDeviceTime() 1321 " synchronized with the local time.</p>") +
1317 ) 1322 self.__getDeviceTime()
1323 )
1318 except Exception as exc: 1324 except Exception as exc:
1319 self.__showError("syncTime()", str(exc)) 1325 self.__showError("syncTime()", str(exc))
1320 1326
1321 def __getDeviceTime(self): 1327 def __getDeviceTime(self):
1322 """ 1328 """
1350 def __showDeviceTime(self): 1356 def __showDeviceTime(self):
1351 """ 1357 """
1352 Private slot to show the date and time of the connected device. 1358 Private slot to show the date and time of the connected device.
1353 """ 1359 """
1354 msg = self.__getDeviceTime() 1360 msg = self.__getDeviceTime()
1355 E5MessageBox.information( 1361 if msg:
1356 self, 1362 E5MessageBox.information(
1357 self.tr("Device Date and Time"), 1363 self,
1358 msg) 1364 self.tr("Device Date and Time"),
1365 msg)
1359 1366
1360 @pyqtSlot() 1367 @pyqtSlot()
1361 def __showLocalTime(self): 1368 def __showLocalTime(self):
1362 """ 1369 """
1363 Private slot to show the local date and time. 1370 Private slot to show the local date and time.
1430 @param method name of the method the error occured in 1437 @param method name of the method the error occured in
1431 @type str 1438 @type str
1432 @param error error message 1439 @param error error message
1433 @type str 1440 @type str
1434 """ 1441 """
1435 E5MessageBox.warning( 1442 with E5OverridenCursor():
1436 self, 1443 E5MessageBox.warning(
1437 self.tr("Error handling device"), 1444 self,
1438 self.tr("<p>There was an error communicating with the connected" 1445 self.tr("Error handling device"),
1439 " device.</p><p>Method: {0}</p><p>Message: {1}</p>") 1446 self.tr("<p>There was an error communicating with the"
1440 .format(method, error)) 1447 " connected device.</p><p>Method: {0}</p>"
1448 "<p>Message: {1}</p>")
1449 .format(method, error))
1441 1450
1442 def __mpyCrossAvailable(self): 1451 def __mpyCrossAvailable(self):
1443 """ 1452 """
1444 Private method to check the availability of mpy-cross. 1453 Private method to check the availability of mpy-cross.
1445 1454

eric ide

mercurial