24 QTextEdit, |
24 QTextEdit, |
25 QToolButton, |
25 QToolButton, |
26 QDialog, |
26 QDialog, |
27 ) |
27 ) |
28 |
28 |
29 from EricWidgets.EricZoomWidget import EricZoomWidget |
29 from eric7.EricWidgets.EricZoomWidget import EricZoomWidget |
30 from EricWidgets import EricMessageBox, EricFileDialog |
30 from eric7.EricWidgets import EricMessageBox, EricFileDialog |
31 from EricWidgets.EricApplication import ericApp |
31 from eric7.EricWidgets.EricApplication import ericApp |
32 from EricWidgets.EricProcessDialog import EricProcessDialog |
32 from eric7.EricWidgets.EricProcessDialog import EricProcessDialog |
33 from EricGui.EricOverrideCursor import EricOverrideCursor, EricOverridenCursor |
33 from eric7.EricGui.EricOverrideCursor import EricOverrideCursor, EricOverridenCursor |
34 |
34 |
35 from .Ui_MicroPythonWidget import Ui_MicroPythonWidget |
35 from .Ui_MicroPythonWidget import Ui_MicroPythonWidget |
36 |
36 |
37 from . import MicroPythonDevices |
37 from . import MicroPythonDevices |
38 from . import UF2FlashDialog |
38 from . import UF2FlashDialog |
50 |
50 |
51 HAS_QTSERIALPORT = True |
51 HAS_QTSERIALPORT = True |
52 except ImportError: |
52 except ImportError: |
53 HAS_QTSERIALPORT = False |
53 HAS_QTSERIALPORT = False |
54 |
54 |
55 import Globals |
55 from eric7.EricGui import EricPixmapCache |
56 import UI.PixmapCache |
56 from eric7 import Globals, Preferences, Utilities |
57 import Preferences |
57 |
58 import Utilities |
58 from eric7.UI.Info import BugAddress |
59 |
|
60 from UI.Info import BugAddress |
|
61 |
59 |
62 # ANSI Colors (see https://en.wikipedia.org/wiki/ANSI_escape_code) |
60 # ANSI Colors (see https://en.wikipedia.org/wiki/ANSI_escape_code) |
63 AnsiColorSchemes = { |
61 AnsiColorSchemes = { |
64 "Windows 7": { |
62 "Windows 7": { |
65 0: QBrush(QColor(0, 0, 0)), |
63 0: QBrush(QColor(0, 0, 0)), |
227 |
225 |
228 self.__superMenu = QMenu(self) |
226 self.__superMenu = QMenu(self) |
229 self.__superMenu.aboutToShow.connect(self.__aboutToShowSuperMenu) |
227 self.__superMenu.aboutToShow.connect(self.__aboutToShowSuperMenu) |
230 |
228 |
231 self.menuButton.setObjectName("micropython_supermenu_button") |
229 self.menuButton.setObjectName("micropython_supermenu_button") |
232 self.menuButton.setIcon(UI.PixmapCache.getIcon("superMenu")) |
230 self.menuButton.setIcon(EricPixmapCache.getIcon("superMenu")) |
233 self.menuButton.setToolTip(self.tr("MicroPython Menu")) |
231 self.menuButton.setToolTip(self.tr("MicroPython Menu")) |
234 self.menuButton.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup) |
232 self.menuButton.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup) |
235 self.menuButton.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonIconOnly) |
233 self.menuButton.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonIconOnly) |
236 self.menuButton.setFocusPolicy(Qt.FocusPolicy.NoFocus) |
234 self.menuButton.setFocusPolicy(Qt.FocusPolicy.NoFocus) |
237 self.menuButton.setAutoRaise(True) |
235 self.menuButton.setAutoRaise(True) |
238 self.menuButton.setShowMenuInside(True) |
236 self.menuButton.setShowMenuInside(True) |
239 self.menuButton.setMenu(self.__superMenu) |
237 self.menuButton.setMenu(self.__superMenu) |
240 |
238 |
241 self.deviceIconLabel.setPixmap(MicroPythonDevices.getDeviceIcon("", False)) |
239 self.deviceIconLabel.setPixmap(MicroPythonDevices.getDeviceIcon("", False)) |
242 |
240 |
243 self.openButton.setIcon(UI.PixmapCache.getIcon("open")) |
241 self.openButton.setIcon(EricPixmapCache.getIcon("open")) |
244 self.saveButton.setIcon(UI.PixmapCache.getIcon("fileSaveAs")) |
242 self.saveButton.setIcon(EricPixmapCache.getIcon("fileSaveAs")) |
245 |
243 |
246 self.checkButton.setIcon(UI.PixmapCache.getIcon("question")) |
244 self.checkButton.setIcon(EricPixmapCache.getIcon("question")) |
247 self.runButton.setIcon(UI.PixmapCache.getIcon("start")) |
245 self.runButton.setIcon(EricPixmapCache.getIcon("start")) |
248 self.replButton.setIcon(UI.PixmapCache.getIcon("terminal")) |
246 self.replButton.setIcon(EricPixmapCache.getIcon("terminal")) |
249 self.filesButton.setIcon(UI.PixmapCache.getIcon("filemanager")) |
247 self.filesButton.setIcon(EricPixmapCache.getIcon("filemanager")) |
250 self.chartButton.setIcon(UI.PixmapCache.getIcon("chart")) |
248 self.chartButton.setIcon(EricPixmapCache.getIcon("chart")) |
251 self.connectButton.setIcon(UI.PixmapCache.getIcon("linkConnect")) |
249 self.connectButton.setIcon(EricPixmapCache.getIcon("linkConnect")) |
252 |
250 |
253 self.__zoomLayout = QHBoxLayout() |
251 self.__zoomLayout = QHBoxLayout() |
254 spacerItem = QSpacerItem( |
252 spacerItem = QSpacerItem( |
255 40, 20, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum |
253 40, 20, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum |
256 ) |
254 ) |
257 self.__zoomLayout.addSpacerItem(spacerItem) |
255 self.__zoomLayout.addSpacerItem(spacerItem) |
258 |
256 |
259 self.__zoom0 = self.replEdit.fontPointSize() |
257 self.__zoom0 = self.replEdit.fontPointSize() |
260 self.__zoomWidget = EricZoomWidget( |
258 self.__zoomWidget = EricZoomWidget( |
261 UI.PixmapCache.getPixmap("zoomOut"), |
259 EricPixmapCache.getPixmap("zoomOut"), |
262 UI.PixmapCache.getPixmap("zoomIn"), |
260 EricPixmapCache.getPixmap("zoomIn"), |
263 UI.PixmapCache.getPixmap("zoomReset"), |
261 EricPixmapCache.getPixmap("zoomReset"), |
264 self, |
262 self, |
265 ) |
263 ) |
266 self.__zoomLayout.addWidget(self.__zoomWidget) |
264 self.__zoomLayout.addWidget(self.__zoomWidget) |
267 self.layout().insertLayout(self.layout().count() - 1, self.__zoomLayout) |
265 self.layout().insertLayout(self.layout().count() - 1, self.__zoomLayout) |
268 self.__zoomWidget.setMinimum(self.ZoomMin) |
266 self.__zoomWidget.setMinimum(self.ZoomMin) |
553 pasteKeys = QKeySequence("Ctrl+Shift+V") |
551 pasteKeys = QKeySequence("Ctrl+Shift+V") |
554 selectAllKeys = QKeySequence("Ctrl+Shift+A") |
552 selectAllKeys = QKeySequence("Ctrl+Shift+A") |
555 |
553 |
556 menu = QMenu(self) |
554 menu = QMenu(self) |
557 act = menu.addAction( |
555 act = menu.addAction( |
558 UI.PixmapCache.getIcon("editDelete"), self.tr("Clear"), self.__clear |
556 EricPixmapCache.getIcon("editDelete"), self.tr("Clear"), self.__clear |
559 ) |
557 ) |
560 act.setEnabled(bool(self.replEdit.toPlainText())) |
558 act.setEnabled(bool(self.replEdit.toPlainText())) |
561 menu.addSeparator() |
559 menu.addSeparator() |
562 act = menu.addAction( |
560 act = menu.addAction( |
563 UI.PixmapCache.getIcon("editCopy"), |
561 EricPixmapCache.getIcon("editCopy"), |
564 self.tr("Copy"), |
562 self.tr("Copy"), |
565 copyKeys, |
563 copyKeys, |
566 self.replEdit.copy, |
564 self.replEdit.copy, |
567 ) |
565 ) |
568 act.setEnabled(self.replEdit.textCursor().hasSelection()) |
566 act.setEnabled(self.replEdit.textCursor().hasSelection()) |
569 act = menu.addAction( |
567 act = menu.addAction( |
570 UI.PixmapCache.getIcon("editPaste"), |
568 EricPixmapCache.getIcon("editPaste"), |
571 self.tr("Paste"), |
569 self.tr("Paste"), |
572 pasteKeys, |
570 pasteKeys, |
573 self.__paste, |
571 self.__paste, |
574 ) |
572 ) |
575 act.setEnabled(self.replEdit.canPaste() and self.__interface.isConnected()) |
573 act.setEnabled(self.replEdit.canPaste() and self.__interface.isConnected()) |
576 menu.addSeparator() |
574 menu.addSeparator() |
577 act = menu.addAction( |
575 act = menu.addAction( |
578 UI.PixmapCache.getIcon("editSelectAll"), |
576 EricPixmapCache.getIcon("editSelectAll"), |
579 self.tr("Select All"), |
577 self.tr("Select All"), |
580 selectAllKeys, |
578 selectAllKeys, |
581 self.replEdit.selectAll, |
579 self.replEdit.selectAll, |
582 ) |
580 ) |
583 act.setEnabled(bool(self.replEdit.toPlainText())) |
581 act.setEnabled(bool(self.replEdit.toPlainText())) |
598 self.__fileManagerWidget.deviceConnectedLed.setOn(connected) |
596 self.__fileManagerWidget.deviceConnectedLed.setOn(connected) |
599 |
597 |
600 self.deviceTypeComboBox.setEnabled(not connected) |
598 self.deviceTypeComboBox.setEnabled(not connected) |
601 |
599 |
602 if connected: |
600 if connected: |
603 self.connectButton.setIcon(UI.PixmapCache.getIcon("linkDisconnect")) |
601 self.connectButton.setIcon(EricPixmapCache.getIcon("linkDisconnect")) |
604 self.connectButton.setToolTip( |
602 self.connectButton.setToolTip( |
605 self.tr("Press to disconnect the current device") |
603 self.tr("Press to disconnect the current device") |
606 ) |
604 ) |
607 else: |
605 else: |
608 self.connectButton.setIcon(UI.PixmapCache.getIcon("linkConnect")) |
606 self.connectButton.setIcon(EricPixmapCache.getIcon("linkConnect")) |
609 self.connectButton.setToolTip( |
607 self.connectButton.setToolTip( |
610 self.tr("Press to connect the selected device") |
608 self.tr("Press to connect the selected device") |
611 ) |
609 ) |
612 |
610 |
613 def isConnected(self): |
611 def isConnected(self): |
1264 self.__chartWidget.dataFlood.connect(self.handleDataFlood) |
1262 self.__chartWidget.dataFlood.connect(self.handleDataFlood) |
1265 |
1263 |
1266 self.__ui.addSideWidget( |
1264 self.__ui.addSideWidget( |
1267 self.__ui.BottomSide, |
1265 self.__ui.BottomSide, |
1268 self.__chartWidget, |
1266 self.__chartWidget, |
1269 UI.PixmapCache.getIcon("chart"), |
1267 EricPixmapCache.getIcon("chart"), |
1270 self.tr("µPy Chart"), |
1268 self.tr("µPy Chart"), |
1271 ) |
1269 ) |
1272 self.__ui.showSideWidget(self.__chartWidget) |
1270 self.__ui.showSideWidget(self.__chartWidget) |
1273 |
1271 |
1274 if not self.__interface.isConnected(): |
1272 if not self.__interface.isConnected(): |
1350 ) |
1348 ) |
1351 |
1349 |
1352 self.__ui.addSideWidget( |
1350 self.__ui.addSideWidget( |
1353 self.__ui.BottomSide, |
1351 self.__ui.BottomSide, |
1354 self.__fileManagerWidget, |
1352 self.__fileManagerWidget, |
1355 UI.PixmapCache.getIcon("filemanager"), |
1353 EricPixmapCache.getIcon("filemanager"), |
1356 self.tr("µPy Files"), |
1354 self.tr("µPy Files"), |
1357 ) |
1355 ) |
1358 self.__ui.showSideWidget(self.__fileManagerWidget) |
1356 self.__ui.showSideWidget(self.__fileManagerWidget) |
1359 |
1357 |
1360 self.__device.setFileManager(True) |
1358 self.__device.setFileManager(True) |
1887 @type list of tuple of (int, int, str) |
1885 @type list of tuple of (int, int, str) |
1888 """ |
1886 """ |
1889 from .AddEditDevicesDialog import AddEditDevicesDialog |
1887 from .AddEditDevicesDialog import AddEditDevicesDialog |
1890 |
1888 |
1891 if len(devices) > 1: |
1889 if len(devices) > 1: |
1892 from EricWidgets.EricListSelectionDialog import EricListSelectionDialog |
1890 from eric7.EricWidgets.EricListSelectionDialog import ( |
|
1891 EricListSelectionDialog, |
|
1892 ) |
1893 |
1893 |
1894 sdlg = EricListSelectionDialog( |
1894 sdlg = EricListSelectionDialog( |
1895 [d[2] for d in devices], |
1895 [d[2] for d in devices], |
1896 title=self.tr("Add Unknown Devices"), |
1896 title=self.tr("Add Unknown Devices"), |
1897 message=self.tr("Select the devices to be added:"), |
1897 message=self.tr("Select the devices to be added:"), |