60 |
60 |
61 class MicroPythonWidget(QWidget, Ui_MicroPythonWidget): |
61 class MicroPythonWidget(QWidget, Ui_MicroPythonWidget): |
62 """ |
62 """ |
63 Class implementing the MicroPython REPL widget. |
63 Class implementing the MicroPython REPL widget. |
64 |
64 |
|
65 @signal aboutToDisconnect() emitted to indicate the imminent disconnect from the |
|
66 currently device |
|
67 @signal disconnected() emitted after the device was disconnected |
65 @signal dataReceived(data) emitted to send data received via the serial |
68 @signal dataReceived(data) emitted to send data received via the serial |
66 connection for further processing |
69 connection for further processing |
67 """ |
70 """ |
68 |
71 |
69 DeviceTypeRole = Qt.ItemDataRole.UserRole |
72 DeviceTypeRole = Qt.ItemDataRole.UserRole |
74 DeviceSerNoRole = Qt.ItemDataRole.UserRole + 5 |
77 DeviceSerNoRole = Qt.ItemDataRole.UserRole + 5 |
75 DeviceInterfaceTypeRole = Qt.ItemDataRole.UserRole + 6 |
78 DeviceInterfaceTypeRole = Qt.ItemDataRole.UserRole + 6 |
76 DeviceWebreplUrlRole = Qt.ItemDataRole.UserRole + 7 |
79 DeviceWebreplUrlRole = Qt.ItemDataRole.UserRole + 7 |
77 |
80 |
78 dataReceived = pyqtSignal(bytes) |
81 dataReceived = pyqtSignal(bytes) |
|
82 aboutToDisconnect = pyqtSignal() |
|
83 disconnected = pyqtSignal() |
79 |
84 |
80 ManualMarker = "<manual>" |
85 ManualMarker = "<manual>" |
81 |
86 |
82 def __init__(self, parent=None): |
87 def __init__(self, parent=None, forMPyWindow=False): |
83 """ |
88 """ |
84 Constructor |
89 Constructor |
85 |
90 |
86 @param parent reference to the parent widget |
91 @param parent reference to the parent widget (defaults to None) |
87 @type QWidget |
92 @type QWidget (optional) |
|
93 @param forMPyWindow flag indicating the MicroPythonWindow variant |
|
94 (defaults to False) |
|
95 @type bool (optional) |
88 """ |
96 """ |
89 super().__init__(parent) |
97 super().__init__(parent) |
90 self.setupUi(self) |
98 self.setupUi(self) |
91 |
99 |
92 self.layout().setContentsMargins(0, 3, 0, 0) |
100 self.layout().setContentsMargins(0, 3, 0, 0) |
93 |
101 |
94 self.__ui = parent |
102 self.__ui = parent |
|
103 self.__forMPyWindow = forMPyWindow |
95 |
104 |
96 self.__wifiController = WifiController(self, self) |
105 self.__wifiController = WifiController(self, self) |
97 self.__wifiMenu = None |
106 self.__wifiMenu = None |
98 |
107 |
99 self.__bluetoothController = BluetoothController(self, self) |
108 self.__bluetoothController = BluetoothController(self, self) |
556 Private slot to connect to the selected device or disconnect from the |
565 Private slot to connect to the selected device or disconnect from the |
557 currently connected device. |
566 currently connected device. |
558 """ |
567 """ |
559 self.replWidget.clearOSD() |
568 self.replWidget.clearOSD() |
560 if self.__linkConnected: |
569 if self.__linkConnected: |
|
570 self.aboutToDisconnect.emit() |
561 with EricOverrideCursor(): |
571 with EricOverrideCursor(): |
562 self.__disconnectFromDevice() |
572 self.__disconnectFromDevice() |
|
573 self.disconnected.emit() |
563 |
574 |
564 if self.replButton.isChecked(): |
575 if self.replButton.isChecked(): |
565 self.on_replButton_clicked(False) |
576 self.on_replButton_clicked(False) |
566 if self.filesButton.isChecked(): |
577 if self.filesButton.isChecked(): |
567 self.on_filesButton_clicked(False) |
578 self.on_filesButton_clicked(False) |
1124 self.__superMenu.addAction( |
1135 self.__superMenu.addAction( |
1125 self.tr("Ignored Serial Devices"), self.__manageIgnored |
1136 self.tr("Ignored Serial Devices"), self.__manageIgnored |
1126 ) |
1137 ) |
1127 self.__superMenu.addSeparator() |
1138 self.__superMenu.addSeparator() |
1128 self.__superMenu.addAction(self.tr("Configure"), self.__configure) |
1139 self.__superMenu.addAction(self.tr("Configure"), self.__configure) |
|
1140 if self.__forMPyWindow: |
|
1141 self.__superMenu.addSeparator() |
|
1142 self.__superMenu.addAction(self.tr("Quit"), self.__quit) |
1129 |
1143 |
1130 @pyqtSlot() |
1144 @pyqtSlot() |
1131 def __showDeviceVersion(self): |
1145 def __showDeviceVersion(self): |
1132 """ |
1146 """ |
1133 Private slot to show some version info about MicroPython of the device. |
1147 Private slot to show some version info about MicroPython of the device. |
1713 if out: |
1727 if out: |
1714 dlg = EricPlainTextDialog( |
1728 dlg = EricPlainTextDialog( |
1715 title=title, text=out.decode("utf-8"), parent=self |
1729 title=title, text=out.decode("utf-8"), parent=self |
1716 ) |
1730 ) |
1717 dlg.exec() |
1731 dlg.exec() |
|
1732 |
|
1733 ####################################################################### |
|
1734 ## Methods below are specific for the MicroPython window. |
|
1735 ####################################################################### |
|
1736 |
|
1737 @pyqtSlot() |
|
1738 def __quit(self): |
|
1739 """ |
|
1740 Private slot to quit the main (MicroPython) window. |
|
1741 """ |
|
1742 self.__ui.close() |