Wed, 22 Feb 2023 07:45:54 +0100
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
9653
e67609152c5e
Updated copyright for 2023.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9624
diff
changeset
|
3 | # Copyright (c) 2019 - 2023 Detlev Offenbach <detlev@die-offenbachs.de> |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing the MicroPython REPL widget. |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
9765
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
10 | import contextlib |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9470
diff
changeset
|
11 | import functools |
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9470
diff
changeset
|
12 | import os |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | import re |
7133
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
14 | import time |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9470
diff
changeset
|
16 | from PyQt6.QtCore import QEvent, QPoint, Qt, pyqtSignal, pyqtSlot |
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9470
diff
changeset
|
17 | from PyQt6.QtGui import QBrush, QClipboard, QColor, QKeySequence, QTextCursor |
8318
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
18 | from PyQt6.QtWidgets import ( |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9470
diff
changeset
|
19 | QApplication, |
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9470
diff
changeset
|
20 | QDialog, |
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9470
diff
changeset
|
21 | QHBoxLayout, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
22 | QMenu, |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9470
diff
changeset
|
23 | QSizePolicy, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
24 | QSpacerItem, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
25 | QTextEdit, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
26 | QToolButton, |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9470
diff
changeset
|
27 | QWidget, |
7067
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
28 | ) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9576
diff
changeset
|
30 | from eric7 import Preferences |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9470
diff
changeset
|
31 | from eric7.EricGui import EricPixmapCache |
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9470
diff
changeset
|
32 | from eric7.EricGui.EricOverrideCursor import EricOverrideCursor, EricOverridenCursor |
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9470
diff
changeset
|
33 | from eric7.EricWidgets import EricFileDialog, EricMessageBox |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
34 | from eric7.EricWidgets.EricApplication import ericApp |
9482
a2bc06a54d9d
Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
35 | from eric7.EricWidgets.EricListSelectionDialog import EricListSelectionDialog |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
36 | from eric7.EricWidgets.EricProcessDialog import EricProcessDialog |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9470
diff
changeset
|
37 | from eric7.EricWidgets.EricZoomWidget import EricZoomWidget |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9576
diff
changeset
|
38 | from eric7.SystemUtilities import FileSystemUtilities, OSUtilities |
9470
34f2493c1d3f
Prepared the code for isort imports reordering.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
39 | from eric7.UI.Info import BugAddress |
34f2493c1d3f
Prepared the code for isort imports reordering.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
40 | |
9759
4543b7876047
Adapted some MicroPython modules to the new package layout.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9752
diff
changeset
|
41 | from . import Devices, UF2FlashDialog |
9482
a2bc06a54d9d
Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
42 | from .MicroPythonFileManagerWidget import MicroPythonFileManagerWidget |
7134
21d23ca51680
Renamed "MicroPythonReplWidget" to "MicroPythonWidget".
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7133
diff
changeset
|
43 | from .Ui_MicroPythonWidget import Ui_MicroPythonWidget |
9776
210bf87ae5c7
Continued implementing WiFi functionality for RP2040 based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9775
diff
changeset
|
44 | from .WifiDialogs.WifiController import WifiController |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
46 | try: |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
47 | from .MicroPythonGraphWidget import MicroPythonGraphWidget |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
48 | |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
49 | HAS_QTCHART = True |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
50 | except ImportError: |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
51 | HAS_QTCHART = False |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
52 | |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
53 | try: |
9765
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
54 | from .MicroPythonDeviceInterface import MicroPythonDeviceInterface |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
55 | |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
56 | HAS_QTSERIALPORT = True |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
57 | except ImportError: |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
58 | HAS_QTSERIALPORT = False |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
60 | # ANSI Colors (see https://en.wikipedia.org/wiki/ANSI_escape_code) |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
61 | AnsiColorSchemes = { |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
62 | "Windows 7": { |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
63 | 0: QBrush(QColor(0, 0, 0)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
64 | 1: QBrush(QColor(128, 0, 0)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
65 | 2: QBrush(QColor(0, 128, 0)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
66 | 3: QBrush(QColor(128, 128, 0)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
67 | 4: QBrush(QColor(0, 0, 128)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
68 | 5: QBrush(QColor(128, 0, 128)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
69 | 6: QBrush(QColor(0, 128, 128)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
70 | 7: QBrush(QColor(192, 192, 192)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
71 | 10: QBrush(QColor(128, 128, 128)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
72 | 11: QBrush(QColor(255, 0, 0)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
73 | 12: QBrush(QColor(0, 255, 0)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
74 | 13: QBrush(QColor(255, 255, 0)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
75 | 14: QBrush(QColor(0, 0, 255)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
76 | 15: QBrush(QColor(255, 0, 255)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
77 | 16: QBrush(QColor(0, 255, 255)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
78 | 17: QBrush(QColor(255, 255, 255)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
79 | }, |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
80 | "Windows 10": { |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
81 | 0: QBrush(QColor(12, 12, 12)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
82 | 1: QBrush(QColor(197, 15, 31)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
83 | 2: QBrush(QColor(19, 161, 14)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
84 | 3: QBrush(QColor(193, 156, 0)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
85 | 4: QBrush(QColor(0, 55, 218)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
86 | 5: QBrush(QColor(136, 23, 152)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
87 | 6: QBrush(QColor(58, 150, 221)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
88 | 7: QBrush(QColor(204, 204, 204)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
89 | 10: QBrush(QColor(118, 118, 118)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
90 | 11: QBrush(QColor(231, 72, 86)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
91 | 12: QBrush(QColor(22, 198, 12)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
92 | 13: QBrush(QColor(249, 241, 165)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
93 | 14: QBrush(QColor(59, 12, 255)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
94 | 15: QBrush(QColor(180, 0, 158)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
95 | 16: QBrush(QColor(97, 214, 214)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
96 | 17: QBrush(QColor(242, 242, 242)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
97 | }, |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
98 | "PuTTY": { |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
99 | 0: QBrush(QColor(0, 0, 0)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
100 | 1: QBrush(QColor(187, 0, 0)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
101 | 2: QBrush(QColor(0, 187, 0)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
102 | 3: QBrush(QColor(187, 187, 0)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
103 | 4: QBrush(QColor(0, 0, 187)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
104 | 5: QBrush(QColor(187, 0, 187)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
105 | 6: QBrush(QColor(0, 187, 187)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
106 | 7: QBrush(QColor(187, 187, 187)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
107 | 10: QBrush(QColor(85, 85, 85)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
108 | 11: QBrush(QColor(255, 85, 85)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
109 | 12: QBrush(QColor(85, 255, 85)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
110 | 13: QBrush(QColor(255, 255, 85)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
111 | 14: QBrush(QColor(85, 85, 255)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
112 | 15: QBrush(QColor(255, 85, 255)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
113 | 16: QBrush(QColor(85, 255, 255)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
114 | 17: QBrush(QColor(255, 255, 255)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
115 | }, |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
116 | "xterm": { |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
117 | 0: QBrush(QColor(0, 0, 0)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
118 | 1: QBrush(QColor(205, 0, 0)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
119 | 2: QBrush(QColor(0, 205, 0)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
120 | 3: QBrush(QColor(205, 205, 0)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
121 | 4: QBrush(QColor(0, 0, 238)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
122 | 5: QBrush(QColor(205, 0, 205)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
123 | 6: QBrush(QColor(0, 205, 205)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
124 | 7: QBrush(QColor(229, 229, 229)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
125 | 10: QBrush(QColor(127, 127, 127)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
126 | 11: QBrush(QColor(255, 0, 0)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
127 | 12: QBrush(QColor(0, 255, 0)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
128 | 13: QBrush(QColor(255, 255, 0)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
129 | 14: QBrush(QColor(0, 0, 255)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
130 | 15: QBrush(QColor(255, 0, 255)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
131 | 16: QBrush(QColor(0, 255, 255)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
132 | 17: QBrush(QColor(255, 255, 255)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
133 | }, |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
134 | "Ubuntu": { |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
135 | 0: QBrush(QColor(1, 1, 1)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
136 | 1: QBrush(QColor(222, 56, 43)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
137 | 2: QBrush(QColor(57, 181, 74)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
138 | 3: QBrush(QColor(255, 199, 6)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
139 | 4: QBrush(QColor(0, 11, 184)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
140 | 5: QBrush(QColor(118, 38, 113)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
141 | 6: QBrush(QColor(44, 181, 233)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
142 | 7: QBrush(QColor(204, 204, 204)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
143 | 10: QBrush(QColor(128, 128, 128)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
144 | 11: QBrush(QColor(255, 0, 0)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
145 | 12: QBrush(QColor(0, 255, 0)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
146 | 13: QBrush(QColor(255, 255, 0)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
147 | 14: QBrush(QColor(0, 0, 255)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
148 | 15: QBrush(QColor(255, 0, 255)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
149 | 16: QBrush(QColor(0, 255, 255)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
150 | 17: QBrush(QColor(255, 255, 255)), |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
151 | }, |
7535
dac9bc72a0f3
MicroPython: made the chart widget color scheme aware and added a config option to configure a specific chart color theme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
152 | "Ubuntu (dark)": { |
dac9bc72a0f3
MicroPython: made the chart widget color scheme aware and added a config option to configure a specific chart color theme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
153 | 0: QBrush(QColor(96, 96, 96)), |
dac9bc72a0f3
MicroPython: made the chart widget color scheme aware and added a config option to configure a specific chart color theme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
154 | 1: QBrush(QColor(235, 58, 45)), |
dac9bc72a0f3
MicroPython: made the chart widget color scheme aware and added a config option to configure a specific chart color theme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
155 | 2: QBrush(QColor(57, 181, 74)), |
dac9bc72a0f3
MicroPython: made the chart widget color scheme aware and added a config option to configure a specific chart color theme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
156 | 3: QBrush(QColor(255, 199, 29)), |
dac9bc72a0f3
MicroPython: made the chart widget color scheme aware and added a config option to configure a specific chart color theme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
157 | 4: QBrush(QColor(25, 56, 230)), |
dac9bc72a0f3
MicroPython: made the chart widget color scheme aware and added a config option to configure a specific chart color theme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
158 | 5: QBrush(QColor(200, 64, 193)), |
dac9bc72a0f3
MicroPython: made the chart widget color scheme aware and added a config option to configure a specific chart color theme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
159 | 6: QBrush(QColor(48, 200, 255)), |
dac9bc72a0f3
MicroPython: made the chart widget color scheme aware and added a config option to configure a specific chart color theme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
160 | 7: QBrush(QColor(204, 204, 204)), |
dac9bc72a0f3
MicroPython: made the chart widget color scheme aware and added a config option to configure a specific chart color theme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
161 | 10: QBrush(QColor(128, 128, 128)), |
dac9bc72a0f3
MicroPython: made the chart widget color scheme aware and added a config option to configure a specific chart color theme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
162 | 11: QBrush(QColor(255, 0, 0)), |
dac9bc72a0f3
MicroPython: made the chart widget color scheme aware and added a config option to configure a specific chart color theme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
163 | 12: QBrush(QColor(0, 255, 0)), |
dac9bc72a0f3
MicroPython: made the chart widget color scheme aware and added a config option to configure a specific chart color theme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
164 | 13: QBrush(QColor(255, 255, 0)), |
dac9bc72a0f3
MicroPython: made the chart widget color scheme aware and added a config option to configure a specific chart color theme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
165 | 14: QBrush(QColor(0, 0, 255)), |
dac9bc72a0f3
MicroPython: made the chart widget color scheme aware and added a config option to configure a specific chart color theme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
166 | 15: QBrush(QColor(255, 0, 255)), |
dac9bc72a0f3
MicroPython: made the chart widget color scheme aware and added a config option to configure a specific chart color theme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
167 | 16: QBrush(QColor(0, 255, 255)), |
dac9bc72a0f3
MicroPython: made the chart widget color scheme aware and added a config option to configure a specific chart color theme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
168 | 17: QBrush(QColor(255, 255, 255)), |
dac9bc72a0f3
MicroPython: made the chart widget color scheme aware and added a config option to configure a specific chart color theme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
169 | }, |
7545
cd2f489f11d5
MicroPythonWidget: added yet another color scheme for a dark background.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7535
diff
changeset
|
170 | "Breeze (dark)": { |
cd2f489f11d5
MicroPythonWidget: added yet another color scheme for a dark background.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7535
diff
changeset
|
171 | 0: QBrush(QColor(35, 38, 39)), |
cd2f489f11d5
MicroPythonWidget: added yet another color scheme for a dark background.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7535
diff
changeset
|
172 | 1: QBrush(QColor(237, 21, 21)), |
cd2f489f11d5
MicroPythonWidget: added yet another color scheme for a dark background.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7535
diff
changeset
|
173 | 2: QBrush(QColor(17, 209, 22)), |
cd2f489f11d5
MicroPythonWidget: added yet another color scheme for a dark background.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7535
diff
changeset
|
174 | 3: QBrush(QColor(246, 116, 0)), |
cd2f489f11d5
MicroPythonWidget: added yet another color scheme for a dark background.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7535
diff
changeset
|
175 | 4: QBrush(QColor(29, 153, 243)), |
cd2f489f11d5
MicroPythonWidget: added yet another color scheme for a dark background.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7535
diff
changeset
|
176 | 5: QBrush(QColor(155, 89, 182)), |
cd2f489f11d5
MicroPythonWidget: added yet another color scheme for a dark background.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7535
diff
changeset
|
177 | 6: QBrush(QColor(26, 188, 156)), |
cd2f489f11d5
MicroPythonWidget: added yet another color scheme for a dark background.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7535
diff
changeset
|
178 | 7: QBrush(QColor(252, 252, 252)), |
cd2f489f11d5
MicroPythonWidget: added yet another color scheme for a dark background.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7535
diff
changeset
|
179 | 10: QBrush(QColor(127, 140, 141)), |
cd2f489f11d5
MicroPythonWidget: added yet another color scheme for a dark background.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7535
diff
changeset
|
180 | 11: QBrush(QColor(192, 57, 43)), |
cd2f489f11d5
MicroPythonWidget: added yet another color scheme for a dark background.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7535
diff
changeset
|
181 | 12: QBrush(QColor(28, 220, 154)), |
cd2f489f11d5
MicroPythonWidget: added yet another color scheme for a dark background.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7535
diff
changeset
|
182 | 13: QBrush(QColor(253, 188, 75)), |
cd2f489f11d5
MicroPythonWidget: added yet another color scheme for a dark background.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7535
diff
changeset
|
183 | 14: QBrush(QColor(61, 174, 233)), |
cd2f489f11d5
MicroPythonWidget: added yet another color scheme for a dark background.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7535
diff
changeset
|
184 | 15: QBrush(QColor(142, 68, 173)), |
cd2f489f11d5
MicroPythonWidget: added yet another color scheme for a dark background.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7535
diff
changeset
|
185 | 16: QBrush(QColor(22, 160, 133)), |
cd2f489f11d5
MicroPythonWidget: added yet another color scheme for a dark background.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7535
diff
changeset
|
186 | 17: QBrush(QColor(255, 255, 255)), |
cd2f489f11d5
MicroPythonWidget: added yet another color scheme for a dark background.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7535
diff
changeset
|
187 | }, |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
188 | } |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
189 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
190 | |
7134
21d23ca51680
Renamed "MicroPythonReplWidget" to "MicroPythonWidget".
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7133
diff
changeset
|
191 | class MicroPythonWidget(QWidget, Ui_MicroPythonWidget): |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
192 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
193 | Class implementing the MicroPython REPL widget. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
194 | |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
195 | @signal dataReceived(data) emitted to send data received via the serial |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
196 | connection for further processing |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
197 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
198 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
199 | ZoomMin = -10 |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
200 | ZoomMax = 20 |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
201 | |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
202 | DeviceTypeRole = Qt.ItemDataRole.UserRole |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
203 | DeviceBoardRole = Qt.ItemDataRole.UserRole + 1 |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
204 | DevicePortRole = Qt.ItemDataRole.UserRole + 2 |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
205 | DeviceVidRole = Qt.ItemDataRole.UserRole + 3 |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
206 | DevicePidRole = Qt.ItemDataRole.UserRole + 4 |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
207 | DeviceSerNoRole = Qt.ItemDataRole.UserRole + 5 |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
208 | |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
209 | dataReceived = pyqtSignal(bytes) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
210 | |
8137
97d37389fbfd
MicroPython: changed the logic of the device/port selector slightly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8135
diff
changeset
|
211 | ManualMarker = "<manual>" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
212 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
213 | def __init__(self, parent=None): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
214 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
215 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
216 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
217 | @param parent reference to the parent widget |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
218 | @type QWidget |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
219 | """ |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
220 | super().__init__(parent) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
221 | self.setupUi(self) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
222 | |
8604
d25390ea2f19
Changed the margins of some right side bar managed items to (0, 3, 0, 0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8366
diff
changeset
|
223 | self.layout().setContentsMargins(0, 3, 0, 0) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
224 | |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
225 | self.__ui = parent |
9787
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
226 | |
9776
210bf87ae5c7
Continued implementing WiFi functionality for RP2040 based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9775
diff
changeset
|
227 | self.__wifiController = WifiController(self, self) |
9787
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
228 | self.__wifiMenu = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
229 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
230 | self.__superMenu = QMenu(self) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
231 | self.__superMenu.aboutToShow.connect(self.__aboutToShowSuperMenu) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
232 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
233 | self.menuButton.setObjectName("micropython_supermenu_button") |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
234 | self.menuButton.setIcon(EricPixmapCache.getIcon("superMenu")) |
7147
7f30b93eb51d
Updated German and English translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7140
diff
changeset
|
235 | self.menuButton.setToolTip(self.tr("MicroPython Menu")) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
236 | self.menuButton.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
237 | self.menuButton.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonIconOnly) |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
238 | self.menuButton.setFocusPolicy(Qt.FocusPolicy.NoFocus) |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
239 | self.menuButton.setAutoRaise(True) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
240 | self.menuButton.setShowMenuInside(True) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
241 | self.menuButton.setMenu(self.__superMenu) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
242 | |
9759
4543b7876047
Adapted some MicroPython modules to the new package layout.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9752
diff
changeset
|
243 | self.deviceIconLabel.setPixmap(Devices.getDeviceIcon("", False)) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
244 | |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
245 | self.checkButton.setIcon(EricPixmapCache.getIcon("question")) |
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
246 | self.runButton.setIcon(EricPixmapCache.getIcon("start")) |
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
247 | self.replButton.setIcon(EricPixmapCache.getIcon("terminal")) |
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
248 | self.filesButton.setIcon(EricPixmapCache.getIcon("filemanager")) |
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
249 | self.chartButton.setIcon(EricPixmapCache.getIcon("chart")) |
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
250 | self.connectButton.setIcon(EricPixmapCache.getIcon("linkConnect")) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
251 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
252 | self.__zoomLayout = QHBoxLayout() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
253 | spacerItem = QSpacerItem( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
254 | 40, 20, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
255 | ) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
256 | self.__zoomLayout.addSpacerItem(spacerItem) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
257 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
258 | self.__zoom0 = self.replEdit.fontPointSize() |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
259 | self.__zoomWidget = EricZoomWidget( |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
260 | EricPixmapCache.getPixmap("zoomOut"), |
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
261 | EricPixmapCache.getPixmap("zoomIn"), |
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
262 | EricPixmapCache.getPixmap("zoomReset"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
263 | self, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
264 | ) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
265 | self.__zoomLayout.addWidget(self.__zoomWidget) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
266 | self.layout().insertLayout(self.layout().count() - 1, self.__zoomLayout) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
267 | self.__zoomWidget.setMinimum(self.ZoomMin) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
268 | self.__zoomWidget.setMaximum(self.ZoomMax) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
269 | self.__zoomWidget.valueChanged.connect(self.__doZoom) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
270 | self.__currentZoom = 0 |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
271 | |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
272 | self.__fileManagerWidget = None |
7535
dac9bc72a0f3
MicroPython: made the chart widget color scheme aware and added a config option to configure a specific chart color theme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
273 | self.__chartWidget = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
274 | |
8133
4d1d1c248f79
MicroPython: started adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8121
diff
changeset
|
275 | self.__unknownPorts = [] |
4d1d1c248f79
MicroPython: started adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8121
diff
changeset
|
276 | self.__lastPort = None |
4d1d1c248f79
MicroPython: started adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8121
diff
changeset
|
277 | self.__lastDeviceType = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
278 | |
7148
25426353d632
MicroPythonWidget: fixed an issue causing eric to crash at startup, if QtSerialPort is not available.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7147
diff
changeset
|
279 | if HAS_QTSERIALPORT: |
9765
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
280 | self.__interface = MicroPythonDeviceInterface(self) |
7148
25426353d632
MicroPythonWidget: fixed an issue causing eric to crash at startup, if QtSerialPort is not available.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7147
diff
changeset
|
281 | else: |
25426353d632
MicroPythonWidget: fixed an issue causing eric to crash at startup, if QtSerialPort is not available.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7147
diff
changeset
|
282 | self.__interface = None |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
283 | self.__device = None |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
284 | self.__connected = False |
9749 | 285 | self.__linkConnected = False |
7135
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
286 | self.__setConnected(False) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
287 | |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
288 | self.__replBuffer = b"" |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
289 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
290 | if not HAS_QTSERIALPORT: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
291 | self.replEdit.setHtml( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
292 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
293 | "<h3>The QtSerialPort package is not available.<br/>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
294 | "MicroPython support is deactivated.</h3>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
295 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
296 | ) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
297 | self.setEnabled(False) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
298 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
299 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
300 | self.__vt100Re = re.compile( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
301 | r"(?P<count>\d*)(?P<color>(?:;?\d*)*)(?P<action>[ABCDKm])" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
302 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
303 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
304 | self.__populateDeviceTypeComboBox() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
305 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
306 | self.replEdit.installEventFilter(self) |
8104 | 307 | # Hack to intercept middle button paste |
308 | self.__origReplEditMouseReleaseEvent = self.replEdit.mouseReleaseEvent | |
309 | self.replEdit.mouseReleaseEvent = self.__replEditMouseReleaseEvent | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
310 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
311 | self.replEdit.customContextMenuRequested.connect(self.__showContextMenu) |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
312 | self.__ui.preferencesChanged.connect(self.__handlePreferencesChanged) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
313 | self.__ui.preferencesChanged.connect(self.__interface.handlePreferencesChanged) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
314 | |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
315 | self.__handlePreferencesChanged() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
316 | |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
317 | charFormat = self.replEdit.currentCharFormat() |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
318 | self.DefaultForeground = charFormat.foreground() |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
319 | self.DefaultBackground = charFormat.background() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
320 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
321 | def __populateDeviceTypeComboBox(self): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
322 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
323 | Private method to populate the device type selector. |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
324 | """ |
7120
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
325 | currentDevice = self.deviceTypeComboBox.currentText() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
326 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
327 | self.deviceTypeComboBox.clear() |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
328 | self.deviceInfoLabel.clear() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
329 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
330 | self.deviceTypeComboBox.addItem("", "") |
9759
4543b7876047
Adapted some MicroPython modules to the new package layout.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9752
diff
changeset
|
331 | devices, unknownDevices, unknownPorts = Devices.getFoundDevices() |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
332 | if devices: |
8139
418c2d9a767d
MicroPython: refined the selection of unknown dvices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8137
diff
changeset
|
333 | supportedMessage = self.tr( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
334 | "%n supported device(s) detected.", "", len(devices) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
335 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
336 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
337 | for index, ( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
338 | boardType, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
339 | boardName, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
340 | description, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
341 | portName, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
342 | vid, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
343 | pid, |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
344 | serialNumber, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
345 | ) in enumerate(sorted(devices), 1): |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
346 | self.deviceTypeComboBox.addItem( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
347 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
348 | "{0} - {1} ({2})", "board name, description, port name" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
349 | ).format(boardName, description, portName) |
8055
52fdd41517f3
MicroPython: made the value shown in the deveice selection list more descriptive.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
350 | ) |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
351 | self.deviceTypeComboBox.setItemData( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
352 | index, boardType, self.DeviceTypeRole |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
353 | ) |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
354 | self.deviceTypeComboBox.setItemData( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
355 | index, boardName, self.DeviceBoardRole |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
356 | ) |
8072
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8071
diff
changeset
|
357 | self.deviceTypeComboBox.setItemData( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
358 | index, portName, self.DevicePortRole |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
359 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
360 | self.deviceTypeComboBox.setItemData(index, vid, self.DeviceVidRole) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
361 | self.deviceTypeComboBox.setItemData(index, pid, self.DevicePidRole) |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
362 | self.deviceTypeComboBox.setItemData( |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
363 | index, serialNumber, self.DeviceSerNoRole |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
364 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
365 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
366 | else: |
8139
418c2d9a767d
MicroPython: refined the selection of unknown dvices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8137
diff
changeset
|
367 | supportedMessage = self.tr("No supported devices detected.") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
368 | |
8135
7cbb1ebf8d2d
MicroPython: fixed some logic issues related to handling of unknown devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8134
diff
changeset
|
369 | self.__unknownPorts = unknownPorts |
7cbb1ebf8d2d
MicroPython: fixed some logic issues related to handling of unknown devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8134
diff
changeset
|
370 | if self.__unknownPorts: |
8139
418c2d9a767d
MicroPython: refined the selection of unknown dvices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8137
diff
changeset
|
371 | unknownMessage = self.tr( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
372 | "\n%n unknown device(s) for manual selection.", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
373 | "", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
374 | len(self.__unknownPorts), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
375 | ) |
8137
97d37389fbfd
MicroPython: changed the logic of the device/port selector slightly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8135
diff
changeset
|
376 | if self.deviceTypeComboBox.count(): |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
377 | self.deviceTypeComboBox.insertSeparator(self.deviceTypeComboBox.count()) |
8137
97d37389fbfd
MicroPython: changed the logic of the device/port selector slightly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8135
diff
changeset
|
378 | self.deviceTypeComboBox.addItem(self.tr("Manual Selection")) |
97d37389fbfd
MicroPython: changed the logic of the device/port selector slightly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8135
diff
changeset
|
379 | self.deviceTypeComboBox.setItemData( |
97d37389fbfd
MicroPython: changed the logic of the device/port selector slightly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8135
diff
changeset
|
380 | self.deviceTypeComboBox.count() - 1, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
381 | self.ManualMarker, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
382 | self.DeviceTypeRole, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
383 | ) |
8139
418c2d9a767d
MicroPython: refined the selection of unknown dvices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8137
diff
changeset
|
384 | else: |
418c2d9a767d
MicroPython: refined the selection of unknown dvices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8137
diff
changeset
|
385 | unknownMessage = "" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
386 | |
8139
418c2d9a767d
MicroPython: refined the selection of unknown dvices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8137
diff
changeset
|
387 | self.deviceInfoLabel.setText(supportedMessage + unknownMessage) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
388 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
389 | index = self.deviceTypeComboBox.findText( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
390 | currentDevice, Qt.MatchFlag.MatchExactly |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
391 | ) |
7120
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
392 | if index == -1: |
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
393 | # entry is no longer present |
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
394 | index = 0 |
9749 | 395 | if self.__linkConnected: |
7120
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
396 | # we are still connected, so disconnect |
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
397 | self.on_connectButton_clicked() |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
398 | self.__device = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
399 | |
7120
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
400 | self.on_deviceTypeComboBox_activated(index) |
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
401 | self.deviceTypeComboBox.setCurrentIndex(index) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
402 | |
7588
881eebfefd34
MicroPython: added code to report detected non-supported devices to the user asking to report them.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7545
diff
changeset
|
403 | if unknownDevices: |
7595
5db6bfeff23e
MicroPython: added code to allow the user to select the flash mod for flashing the MicroPython firmware for ESP32/ESP8266 devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7592
diff
changeset
|
404 | ignoredUnknown = { |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
405 | tuple(d) for d in Preferences.getMicroPython("IgnoredUnknownDevices") |
7595
5db6bfeff23e
MicroPython: added code to allow the user to select the flash mod for flashing the MicroPython firmware for ESP32/ESP8266 devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7592
diff
changeset
|
406 | } |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
407 | uf2Devices = {(*x[2], x[1]) for x in UF2FlashDialog.getFoundDevices()} |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
408 | newUnknownDevices = set(unknownDevices) - ignoredUnknown - uf2Devices |
7592
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
409 | if newUnknownDevices: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
410 | button = EricMessageBox.information( |
7592
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
411 | self, |
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
412 | self.tr("Unknown MicroPython Device"), |
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
413 | self.tr( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
414 | "<p>Detected these unknown serial devices</p>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
415 | "<ul>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
416 | "<li>{0}</li>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
417 | "</ul>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
418 | "<p>Please report them together with the board name" |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
419 | ' and a short description to <a href="mailto:{1}">' |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
420 | " the eric bug reporting address</a> if it is a" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
421 | " MicroPython board.</p>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
422 | ).format( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
423 | "</li><li>".join( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
424 | [ |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
425 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
426 | "{0} (0x{1:04x}/0x{2:04x})", "description, VId, PId" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
427 | ).format(desc, vid, pid) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
428 | for vid, pid, desc in newUnknownDevices |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
429 | ] |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
430 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
431 | BugAddress, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
432 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
433 | EricMessageBox.Ignore | EricMessageBox.Ok, |
7592
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
434 | ) |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
435 | if button == EricMessageBox.Ignore: |
7592
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
436 | ignoredUnknown = list(ignoredUnknown | newUnknownDevices) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
437 | Preferences.setMicroPython("IgnoredUnknownDevices", ignoredUnknown) |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
438 | else: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
439 | yes = EricMessageBox.yesNo( |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
440 | self, |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
441 | self.tr("Unknown MicroPython Device"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
442 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
443 | """Would you like to add them to the list of""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
444 | """ manually configured devices?""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
445 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
446 | yesDefault=True, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
447 | ) |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
448 | if yes: |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
449 | self.__addUnknownDevices(list(newUnknownDevices)) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
450 | |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
451 | def __handlePreferencesChanged(self): |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
452 | """ |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
453 | Private slot to handle a change in preferences. |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
454 | """ |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
455 | self.__colorScheme = Preferences.getMicroPython("ColorScheme") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
456 | |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
457 | self.__font = Preferences.getEditorOtherFonts("MonospacedFont") |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
458 | self.replEdit.setFontFamily(self.__font.family()) |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
459 | self.replEdit.setFontPointSize(self.__font.pointSize()) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
460 | |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
461 | if Preferences.getMicroPython("ReplLineWrap"): |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
462 | self.replEdit.setLineWrapMode(QTextEdit.LineWrapMode.WidgetWidth) |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
463 | else: |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
464 | self.replEdit.setLineWrapMode(QTextEdit.LineWrapMode.NoWrap) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
465 | |
7535
dac9bc72a0f3
MicroPython: made the chart widget color scheme aware and added a config option to configure a specific chart color theme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
466 | if self.__chartWidget is not None: |
dac9bc72a0f3
MicroPython: made the chart widget color scheme aware and added a config option to configure a specific chart color theme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
467 | self.__chartWidget.preferencesChanged() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
468 | |
9765
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
469 | def deviceInterface(self): |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
470 | """ |
9765
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
471 | Public method to get a reference to the device interface object. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
472 | |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
473 | @return reference to the commands interface object |
9765
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
474 | @rtype MicroPythonDeviceInterface |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
475 | """ |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
476 | return self.__interface |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
477 | |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7123
diff
changeset
|
478 | def isMicrobit(self): |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7123
diff
changeset
|
479 | """ |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7123
diff
changeset
|
480 | Public method to check, if the connected/selected device is a |
8038
73ec029d4107
MicroPython: improved the support for "BBC micro:bit" and "Calliope mini".
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8024
diff
changeset
|
481 | BBC micro:bit or Calliope mini. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
482 | |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7123
diff
changeset
|
483 | @return flag indicating a micro:bit device |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7123
diff
changeset
|
484 | rtype bool |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7123
diff
changeset
|
485 | """ |
9766
f0e22f3a5878
Fixed a few issue introduced during the recent changes to the MicroPython package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9765
diff
changeset
|
486 | if ( |
f0e22f3a5878
Fixed a few issue introduced during the recent changes to the MicroPython package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9765
diff
changeset
|
487 | self.__device |
f0e22f3a5878
Fixed a few issue introduced during the recent changes to the MicroPython package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9765
diff
changeset
|
488 | and ( |
f0e22f3a5878
Fixed a few issue introduced during the recent changes to the MicroPython package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9765
diff
changeset
|
489 | "micro:bit" in self.__device.deviceName() |
f0e22f3a5878
Fixed a few issue introduced during the recent changes to the MicroPython package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9765
diff
changeset
|
490 | or "Calliope" in self.__device.deviceName() |
f0e22f3a5878
Fixed a few issue introduced during the recent changes to the MicroPython package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9765
diff
changeset
|
491 | ) |
f0e22f3a5878
Fixed a few issue introduced during the recent changes to the MicroPython package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9765
diff
changeset
|
492 | and not self.__device.hasCircuitPython() |
8038
73ec029d4107
MicroPython: improved the support for "BBC micro:bit" and "Calliope mini".
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8024
diff
changeset
|
493 | ): |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7123
diff
changeset
|
494 | return True |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
495 | |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7123
diff
changeset
|
496 | return False |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
497 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
498 | @pyqtSlot(int) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
499 | def on_deviceTypeComboBox_activated(self, index): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
500 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
501 | Private slot handling the selection of a device type. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
502 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
503 | @param index index of the selected device |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
504 | @type int |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
505 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
506 | deviceType = self.deviceTypeComboBox.itemData(index, self.DeviceTypeRole) |
8137
97d37389fbfd
MicroPython: changed the logic of the device/port selector slightly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8135
diff
changeset
|
507 | if deviceType == self.ManualMarker: |
97d37389fbfd
MicroPython: changed the logic of the device/port selector slightly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8135
diff
changeset
|
508 | self.connectButton.setEnabled(bool(self.__unknownPorts)) |
97d37389fbfd
MicroPython: changed the logic of the device/port selector slightly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8135
diff
changeset
|
509 | else: |
9765
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
510 | self.deviceIconLabel.setPixmap(Devices.getDeviceIcon(deviceType, False)) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
511 | |
9738 | 512 | boardName = self.deviceTypeComboBox.itemData(index, self.DeviceBoardRole) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
513 | vid = self.deviceTypeComboBox.itemData(index, self.DeviceVidRole) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
514 | pid = self.deviceTypeComboBox.itemData(index, self.DevicePidRole) |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
515 | serNo = self.deviceTypeComboBox.itemData(index, self.DeviceSerNoRole) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
516 | |
9496
05017f795c24
Changed MicroPython device imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
517 | if deviceType or (pid is not None and pid is not None): |
9759
4543b7876047
Adapted some MicroPython modules to the new package layout.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9752
diff
changeset
|
518 | self.__device = Devices.getDevice( |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
519 | deviceType, self, vid, pid, boardName=boardName, serialNumber=serNo |
9738 | 520 | ) |
9496
05017f795c24
Changed MicroPython device imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
521 | self.__device.setButtons() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
522 | |
9496
05017f795c24
Changed MicroPython device imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
523 | self.connectButton.setEnabled(bool(deviceType)) |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
524 | else: |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
525 | self.__device = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
526 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
527 | @pyqtSlot() |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
528 | def on_checkButton_clicked(self): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
529 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
530 | Private slot to check for connected devices. |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
531 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
532 | self.__populateDeviceTypeComboBox() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
533 | |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
534 | def setActionButtons(self, **kwargs): |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
535 | """ |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
536 | Public method to set the enabled state of the various action buttons. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
537 | |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
538 | @keyparam kwargs keyword arguments containg the enabled states (keys |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
539 | are 'run', 'repl', 'files', 'chart', 'open', 'save' |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
540 | @type dict |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
541 | """ |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
542 | if "run" in kwargs: |
9749 | 543 | self.runButton.setEnabled(kwargs["run"] and self.__connected) |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
544 | if "repl" in kwargs: |
9749 | 545 | self.replButton.setEnabled(kwargs["repl"] and self.__linkConnected) |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
546 | if "files" in kwargs: |
9749 | 547 | self.filesButton.setEnabled(kwargs["files"] and self.__connected) |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
548 | if "chart" in kwargs: |
9749 | 549 | self.chartButton.setEnabled( |
550 | kwargs["chart"] and HAS_QTCHART and self.__connected | |
551 | ) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
552 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
553 | @pyqtSlot(QPoint) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
554 | def __showContextMenu(self, pos): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
555 | """ |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
556 | Private slot to show the REPL context menu. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
557 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
558 | @param pos position to show the menu at |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
559 | @type QPoint |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
560 | """ |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9576
diff
changeset
|
561 | if OSUtilities.isMacPlatform(): |
8807
f4486646a233
Fixed an issue in the MicroPython widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8604
diff
changeset
|
562 | copyKeys = QKeySequence("Ctrl+C") |
f4486646a233
Fixed an issue in the MicroPython widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8604
diff
changeset
|
563 | pasteKeys = QKeySequence("Ctrl+V") |
9163
9ae6990affcd
Corrected the MicroPython context menu code and added some more actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8945
diff
changeset
|
564 | selectAllKeys = QKeySequence("Ctrl+A") |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
565 | else: |
8807
f4486646a233
Fixed an issue in the MicroPython widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8604
diff
changeset
|
566 | copyKeys = QKeySequence("Ctrl+Shift+C") |
f4486646a233
Fixed an issue in the MicroPython widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8604
diff
changeset
|
567 | pasteKeys = QKeySequence("Ctrl+Shift+V") |
9163
9ae6990affcd
Corrected the MicroPython context menu code and added some more actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8945
diff
changeset
|
568 | selectAllKeys = QKeySequence("Ctrl+Shift+A") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
569 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
570 | menu = QMenu(self) |
9749 | 571 | menu.addAction( |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
572 | EricPixmapCache.getIcon("editDelete"), self.tr("Clear"), self.__clear |
9749 | 573 | ).setEnabled(bool(self.replEdit.toPlainText())) |
7094
d5f340dfb986
MicroPythonReplWidget: added a context menu action to clear the REPL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7090
diff
changeset
|
574 | menu.addSeparator() |
9749 | 575 | menu.addAction( |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
576 | EricPixmapCache.getIcon("editCopy"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
577 | self.tr("Copy"), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
578 | copyKeys, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
579 | self.replEdit.copy, |
9749 | 580 | ).setEnabled(self.replEdit.textCursor().hasSelection()) |
581 | menu.addAction( | |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
582 | EricPixmapCache.getIcon("editPaste"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
583 | self.tr("Paste"), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
584 | pasteKeys, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
585 | self.__paste, |
9749 | 586 | ).setEnabled(self.replEdit.canPaste() and self.__connected) |
7066
e3d034e65afc
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7065
diff
changeset
|
587 | menu.addSeparator() |
9749 | 588 | menu.addAction( |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
589 | EricPixmapCache.getIcon("editSelectAll"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
590 | self.tr("Select All"), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
591 | selectAllKeys, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
592 | self.replEdit.selectAll, |
9749 | 593 | ).setEnabled(bool(self.replEdit.toPlainText())) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
594 | |
7759
51aa6c6b66f7
Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7609
diff
changeset
|
595 | menu.exec(self.replEdit.mapToGlobal(pos)) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
596 | |
7135
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
597 | def __setConnected(self, connected): |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
598 | """ |
7135
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
599 | Private method to set the connection status LED. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
600 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
601 | @param connected connection state |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
602 | @type bool |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
603 | """ |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
604 | self.__connected = connected |
9749 | 605 | self.__linkConnected = self.__interface.isConnected() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
606 | |
9749 | 607 | self.deviceConnectedLed.setOn(self.__linkConnected) |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
608 | if self.__fileManagerWidget: |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
609 | self.__fileManagerWidget.deviceConnectedLed.setOn(connected) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
610 | |
9749 | 611 | self.deviceTypeComboBox.setEnabled(not self.__linkConnected) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
612 | |
9749 | 613 | if self.__linkConnected: |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
614 | self.connectButton.setIcon(EricPixmapCache.getIcon("linkDisconnect")) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
615 | self.connectButton.setToolTip( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
616 | self.tr("Press to disconnect the current device") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
617 | ) |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
618 | else: |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
619 | self.connectButton.setIcon(EricPixmapCache.getIcon("linkConnect")) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
620 | self.connectButton.setToolTip( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
621 | self.tr("Press to connect the selected device") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
622 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
623 | |
9787
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
624 | if not connected and self.__wifiMenu and self.__wifiMenu.isTearOffMenuVisible(): |
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
625 | self.__wifiMenu.hideTearOffMenu() |
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
626 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
627 | def isConnected(self): |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
628 | """ |
9749 | 629 | Public method to get the MicroPython device connection state. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
630 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
631 | @return connection state |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
632 | @rtype bool |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
633 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
634 | return self.__connected |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
635 | |
9749 | 636 | def isLinkConnected(self): |
637 | """ | |
638 | Public method to get the link connection state. | |
639 | ||
640 | @return connection state | |
641 | @rtype bool | |
642 | """ | |
643 | return self.__linkConnected | |
644 | ||
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
645 | def __showNoDeviceMessage(self): |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
646 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
647 | Private method to show a message dialog indicating a missing device. |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
648 | """ |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
649 | EricMessageBox.critical( |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
650 | self, |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
651 | self.tr("No device attached"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
652 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
653 | """Please ensure the device is plugged into your""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
654 | """ computer and selected.\n\nIt must have a version""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
655 | """ of MicroPython (or CircuitPython) flashed onto""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
656 | """ it before anything will work.\n\nFinally press""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
657 | """ the device's reset button and wait a few seconds""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
658 | """ before trying again.""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
659 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
660 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
661 | |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
662 | @pyqtSlot(bool) |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
663 | def on_replButton_clicked(self, checked): |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
664 | """ |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
665 | Private slot to connect to enable or disable the REPL widget. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
666 | |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
667 | If the selected device is not connected yet, this will be done now. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
668 | |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
669 | @param checked state of the button |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
670 | @type bool |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
671 | """ |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
672 | if not self.__device: |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
673 | self.__showNoDeviceMessage() |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
674 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
675 | |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
676 | if checked: |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
677 | ok, reason = self.__device.canStartRepl() |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
678 | if not ok: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
679 | EricMessageBox.warning( |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
680 | self, |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
681 | self.tr("Start REPL"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
682 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
683 | """<p>The REPL cannot be started.</p><p>Reason:""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
684 | """ {0}</p>""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
685 | ).format(reason), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
686 | ) |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
687 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
688 | |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
689 | self.replEdit.clear() |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
690 | self.__interface.dataReceived.connect(self.__processData) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
691 | |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
692 | if not self.__interface.isConnected(): |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
693 | self.__connectToDevice() |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
694 | if self.__device.forceInterrupt(): |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
695 | # send a Ctrl-B (exit raw mode) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
696 | self.__interface.write(b"\x02") |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
697 | # send Ctrl-C (keyboard interrupt) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
698 | self.__interface.write(b"\x03") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
699 | |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
700 | self.__device.setRepl(True) |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
701 | self.replEdit.setFocus(Qt.FocusReason.OtherFocusReason) |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
702 | else: |
9765
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
703 | with contextlib.suppress(TypeError): |
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
704 | self.__interface.dataReceived.disconnect(self.__processData) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
705 | if not self.chartButton.isChecked() and not self.filesButton.isChecked(): |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
706 | self.__disconnectFromDevice() |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
707 | self.__device.setRepl(False) |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
708 | self.replButton.setChecked(checked) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
709 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
710 | @pyqtSlot() |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
711 | def on_connectButton_clicked(self): |
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
712 | """ |
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
713 | Private slot to connect to the selected device or disconnect from the |
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
714 | currently connected device. |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
715 | """ |
9749 | 716 | if self.__linkConnected: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
717 | with EricOverrideCursor(): |
8061
979562f350bf
MicroPython: implemented fixes for a few issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8055
diff
changeset
|
718 | self.__disconnectFromDevice() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
719 | |
7120
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
720 | if self.replButton.isChecked(): |
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
721 | self.on_replButton_clicked(False) |
7111
62191d1aeeed
MicroPythonReplWidget: made the connect button more intelligent.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
722 | if self.filesButton.isChecked(): |
62191d1aeeed
MicroPythonReplWidget: made the connect button more intelligent.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
723 | self.on_filesButton_clicked(False) |
62191d1aeeed
MicroPythonReplWidget: made the connect button more intelligent.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
724 | if self.chartButton.isChecked(): |
62191d1aeeed
MicroPythonReplWidget: made the connect button more intelligent.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
725 | self.on_chartButton_clicked(False) |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
726 | else: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
727 | with EricOverrideCursor(): |
9763
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
728 | self.__connectToDevice(withAutostart=True) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
729 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
730 | @pyqtSlot() |
7094
d5f340dfb986
MicroPythonReplWidget: added a context menu action to clear the REPL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7090
diff
changeset
|
731 | def __clear(self): |
d5f340dfb986
MicroPythonReplWidget: added a context menu action to clear the REPL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7090
diff
changeset
|
732 | """ |
d5f340dfb986
MicroPythonReplWidget: added a context menu action to clear the REPL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7090
diff
changeset
|
733 | Private slot to clear the REPL pane. |
d5f340dfb986
MicroPythonReplWidget: added a context menu action to clear the REPL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7090
diff
changeset
|
734 | """ |
d5f340dfb986
MicroPythonReplWidget: added a context menu action to clear the REPL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7090
diff
changeset
|
735 | self.replEdit.clear() |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
736 | self.__interface.isConnected() and self.__interface.write(b"\r") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
737 | |
7094
d5f340dfb986
MicroPythonReplWidget: added a context menu action to clear the REPL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7090
diff
changeset
|
738 | @pyqtSlot() |
8104 | 739 | def __paste(self, mode=QClipboard.Mode.Clipboard): |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
740 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
741 | Private slot to perform a paste operation. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
742 | |
8104 | 743 | @param mode paste mode (defaults to QClipboard.Mode.Clipboard) |
744 | @type QClipboard.Mode (optional) | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
745 | """ |
8061
979562f350bf
MicroPython: implemented fixes for a few issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8055
diff
changeset
|
746 | # add support for paste by mouse middle button |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
747 | clipboard = QApplication.clipboard() |
7087
2ca7fb61a82f
MicroPythonReplWidget: added special handling for the Return and Enter keys to move the cursor to the end of line before passing it on to the REPL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
748 | if clipboard: |
8104 | 749 | pasteText = clipboard.text(mode=mode) |
7087
2ca7fb61a82f
MicroPythonReplWidget: added special handling for the Return and Enter keys to move the cursor to the end of line before passing it on to the REPL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
750 | if pasteText: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
751 | pasteText = pasteText.replace("\n\r", "\r") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
752 | pasteText = pasteText.replace("\n", "\r") |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
753 | self.__interface.isConnected() and self.__interface.write( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
754 | pasteText.encode("utf-8") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
755 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
756 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
757 | def eventFilter(self, obj, evt): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
758 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
759 | Public method to process events for the REPL pane. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
760 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
761 | @param obj reference to the object the event was meant for |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
762 | @type QObject |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
763 | @param evt reference to the event object |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
764 | @type QEvent |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
765 | @return flag to indicate that the event was handled |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
766 | @rtype bool |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
767 | """ |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
768 | if obj is self.replEdit and evt.type() == QEvent.Type.KeyPress: |
9767
2eed840795c0
Fixed a few issues in the MicroPython file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9766
diff
changeset
|
769 | # handle the key press event on behalf of the REPL pane |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
770 | key = evt.key() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
771 | msg = bytes(evt.text(), "utf8") |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
772 | if key == Qt.Key.Key_Backspace: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
773 | msg = b"\b" |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
774 | elif key == Qt.Key.Key_Delete: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
775 | msg = b"\x1B[\x33\x7E" |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
776 | elif key == Qt.Key.Key_Up: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
777 | msg = b"\x1B[A" |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
778 | elif key == Qt.Key.Key_Down: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
779 | msg = b"\x1B[B" |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
780 | elif key == Qt.Key.Key_Right: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
781 | msg = b"\x1B[C" |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
782 | elif key == Qt.Key.Key_Left: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
783 | msg = b"\x1B[D" |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
784 | elif key == Qt.Key.Key_Home: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
785 | msg = b"\x1B[H" |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
786 | elif key == Qt.Key.Key_End: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
787 | msg = b"\x1B[F" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
788 | elif ( |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9576
diff
changeset
|
789 | OSUtilities.isMacPlatform() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
790 | and evt.modifiers() == Qt.KeyboardModifier.MetaModifier |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
791 | ) or ( |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9576
diff
changeset
|
792 | not OSUtilities.isMacPlatform() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
793 | and evt.modifiers() == Qt.KeyboardModifier.ControlModifier |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
794 | ): |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
795 | if Qt.Key.Key_A <= key <= Qt.Key.Key_Z: |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
796 | # devices treat an input of \x01 as Ctrl+A, etc. |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
797 | msg = bytes([1 + key - Qt.Key.Key_A]) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
798 | elif evt.modifiers() == ( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
799 | Qt.KeyboardModifier.ControlModifier | Qt.KeyboardModifier.ShiftModifier |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
800 | ) or ( |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9576
diff
changeset
|
801 | OSUtilities.isMacPlatform() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
802 | and evt.modifiers() == Qt.KeyboardModifier.ControlModifier |
8104 | 803 | ): |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
804 | if key == Qt.Key.Key_C: |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
805 | self.replEdit.copy() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
806 | msg = b"" |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
807 | elif key == Qt.Key.Key_V: |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
808 | self.__paste() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
809 | msg = b"" |
9163
9ae6990affcd
Corrected the MicroPython context menu code and added some more actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8945
diff
changeset
|
810 | elif key == Qt.Key.Key_A: |
9ae6990affcd
Corrected the MicroPython context menu code and added some more actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8945
diff
changeset
|
811 | self.replEdit.selectAll() |
9ae6990affcd
Corrected the MicroPython context menu code and added some more actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8945
diff
changeset
|
812 | msg = b"" |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
813 | elif key in (Qt.Key.Key_Return, Qt.Key.Key_Enter): |
7087
2ca7fb61a82f
MicroPythonReplWidget: added special handling for the Return and Enter keys to move the cursor to the end of line before passing it on to the REPL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
814 | tc = self.replEdit.textCursor() |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
815 | tc.movePosition(QTextCursor.MoveOperation.EndOfLine) |
7087
2ca7fb61a82f
MicroPythonReplWidget: added special handling for the Return and Enter keys to move the cursor to the end of line before passing it on to the REPL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7082
diff
changeset
|
816 | self.replEdit.setTextCursor(tc) |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
817 | self.__interface.isConnected() and self.__interface.write(msg) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
818 | return True |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
819 | else: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
820 | # standard event processing |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
821 | return super().eventFilter(obj, evt) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
822 | |
8104 | 823 | def __replEditMouseReleaseEvent(self, evt): |
824 | """ | |
825 | Private method handling mouse release events for the replEdit widget. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
826 | |
8104 | 827 | Note: this is a hack because QTextEdit does not allow filtering of |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
828 | QEvent.Type.MouseButtonRelease. To make middle button paste work, we |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
829 | had to intercept the protected event method (some kind of |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
830 | reimplementing it). |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
831 | |
8104 | 832 | @param evt reference to the event object |
833 | @type QMouseEvent | |
834 | """ | |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
835 | if evt.button() == Qt.MouseButton.MiddleButton: |
8104 | 836 | self.__paste(mode=QClipboard.Mode.Selection) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
837 | msg = b"" |
8104 | 838 | if self.__interface.isConnected(): |
839 | self.__interface.write(msg) | |
840 | evt.accept() | |
841 | else: | |
842 | self.__origReplEditMouseReleaseEvent(evt) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
843 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
844 | def __processData(self, data): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
845 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
846 | Private slot to process bytes received from the device. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
847 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
848 | @param data bytes received from the device |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
849 | @type bytes |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
850 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
851 | tc = self.replEdit.textCursor() |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
852 | # the text cursor must be on the last line |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
853 | while tc.movePosition(QTextCursor.MoveOperation.Down): |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
854 | pass |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
855 | |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
856 | # set the font |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
857 | charFormat = tc.charFormat() |
8318
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
858 | charFormat.setFontFamilies([self.__font.family()]) |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
859 | charFormat.setFontPointSize(self.__font.pointSize()) |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
860 | tc.setCharFormat(charFormat) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
861 | |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
862 | # add received data to the buffered one |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
863 | data = self.__replBuffer + data |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
864 | |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
865 | index = 0 |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
866 | while index < len(data): |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
867 | if data[index] == 8: # \b |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
868 | tc.movePosition(QTextCursor.MoveOperation.Left) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
869 | self.replEdit.setTextCursor(tc) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
870 | elif data[index] in (4, 13): # EOT, \r |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
871 | pass |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
872 | elif len(data) > index + 1 and data[index] == 27 and data[index + 1] == 91: |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
873 | # VT100 cursor command detected: <Esc>[ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
874 | index += 2 # move index to after the [ |
8945 | 875 | match = self.__vt100Re.search( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
876 | data[index:].decode("utf-8", errors="replace") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
877 | ) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
878 | if match: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
879 | # move to last position in control sequence |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
880 | # ++ will be done at end of loop |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
881 | index += match.end() - 1 |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
882 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
883 | action = match.group("action") |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
884 | if action in "ABCD": |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
885 | if match.group("count") == "": |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
886 | count = 1 |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
887 | else: |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
888 | count = int(match.group("count")) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
889 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
890 | if action == "A": # up |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
891 | tc.movePosition(QTextCursor.MoveOperation.Up, n=count) |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
892 | self.replEdit.setTextCursor(tc) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
893 | elif action == "B": # down |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
894 | tc.movePosition(QTextCursor.MoveOperation.Down, n=count) |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
895 | self.replEdit.setTextCursor(tc) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
896 | elif action == "C": # right |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
897 | tc.movePosition(QTextCursor.MoveOperation.Right, n=count) |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
898 | self.replEdit.setTextCursor(tc) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
899 | elif action == "D": # left |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
900 | tc.movePosition(QTextCursor.MoveOperation.Left, n=count) |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
901 | self.replEdit.setTextCursor(tc) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
902 | elif action == "K": # delete things |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
903 | if match.group("count") in ("", "0"): |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
904 | # delete to end of line |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
905 | tc.movePosition( |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
906 | QTextCursor.MoveOperation.EndOfLine, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
907 | mode=QTextCursor.MoveMode.KeepAnchor, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
908 | ) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
909 | tc.removeSelectedText() |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
910 | self.replEdit.setTextCursor(tc) |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
911 | elif match.group("count") == "1": |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
912 | # delete to beginning of line |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
913 | tc.movePosition( |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
914 | QTextCursor.MoveOperation.StartOfLine, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
915 | mode=QTextCursor.MoveMode.KeepAnchor, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
916 | ) |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
917 | tc.removeSelectedText() |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
918 | self.replEdit.setTextCursor(tc) |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
919 | elif match.group("count") == "2": |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
920 | # delete whole line |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
921 | tc.movePosition(QTextCursor.MoveOperation.EndOfLine) |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
922 | tc.movePosition( |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
923 | QTextCursor.MoveOperation.StartOfLine, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
924 | mode=QTextCursor.MoveMode.KeepAnchor, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
925 | ) |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
926 | tc.removeSelectedText() |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
927 | self.replEdit.setTextCursor(tc) |
7066
e3d034e65afc
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7065
diff
changeset
|
928 | elif action == "m": |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
929 | self.__setCharFormat(match.group(0)[:-1].split(";"), tc) |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
930 | elif ( |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
931 | len(data) > index + 1 |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
932 | and data[index] == 27 |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
933 | and data[index + 1 : index + 4] == b"]0;" |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
934 | ): |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
935 | if b"\x1b\\" in data[index + 4 :]: |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
936 | # 'set window title' command detected: <Esc>]0;...<Esc>\ |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
937 | # __IGNORE_WARNING_M891__ |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
938 | titleData = data[index + 4 :].split(b"\x1b\\")[0] |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
939 | title = titleData.decode() |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
940 | index += len(titleData) + 5 # one more is done at the end |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
941 | tc.deleteChar() |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
942 | self.replEdit.setTextCursor(tc) |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
943 | self.replEdit.insertPlainText(title) |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
944 | else: |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
945 | # data is incomplete; buffer and stop processing |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
946 | self.__replBuffer = data[index:] |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
947 | return |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
948 | else: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
949 | tc.deleteChar() |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
950 | self.replEdit.setTextCursor(tc) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
951 | self.replEdit.insertPlainText(chr(data[index])) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
952 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
953 | index += 1 |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
954 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
955 | self.replEdit.ensureCursorVisible() |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
956 | self.__replBuffer = b"" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
957 | |
7067
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
958 | def __setCharFormat(self, formatCodes, textCursor): |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
959 | """ |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
960 | Private method setting the current text format of the REPL pane based |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
961 | on the passed ANSI codes. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
962 | |
7067
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
963 | Following codes are used: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
964 | <ul> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
965 | <li>0: Reset</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
966 | <li>1: Bold font (weight 75)</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
967 | <li>2: Light font (weight 25)</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
968 | <li>3: Italic font</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
969 | <li>4: Underlined font</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
970 | <li>9: Strikeout font</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
971 | <li>21: Bold off (weight 50)</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
972 | <li>22: Light off (weight 50)</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
973 | <li>23: Italic off</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
974 | <li>24: Underline off</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
975 | <li>29: Strikeout off</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
976 | <li>30: foreground Black</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
977 | <li>31: foreground Dark Red</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
978 | <li>32: foreground Dark Green</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
979 | <li>33: foreground Dark Yellow</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
980 | <li>34: foreground Dark Blue</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
981 | <li>35: foreground Dark Magenta</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
982 | <li>36: foreground Dark Cyan</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
983 | <li>37: foreground Light Gray</li> |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
984 | <li>39: reset foreground to default</li> |
7067
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
985 | <li>40: background Black</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
986 | <li>41: background Dark Red</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
987 | <li>42: background Dark Green</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
988 | <li>43: background Dark Yellow</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
989 | <li>44: background Dark Blue</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
990 | <li>45: background Dark Magenta</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
991 | <li>46: background Dark Cyan</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
992 | <li>47: background Light Gray</li> |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
993 | <li>49: reset background to default</li> |
7067
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
994 | <li>53: Overlined font</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
995 | <li>55: Overline off</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
996 | <li>90: bright foreground Dark Gray</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
997 | <li>91: bright foreground Red</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
998 | <li>92: bright foreground Green</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
999 | <li>93: bright foreground Yellow</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1000 | <li>94: bright foreground Blue</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1001 | <li>95: bright foreground Magenta</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1002 | <li>96: bright foreground Cyan</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1003 | <li>97: bright foreground White</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1004 | <li>100: bright background Dark Gray</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1005 | <li>101: bright background Red</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1006 | <li>102: bright background Green</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1007 | <li>103: bright background Yellow</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1008 | <li>104: bright background Blue</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1009 | <li>105: bright background Magenta</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1010 | <li>106: bright background Cyan</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1011 | <li>107: bright background White</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1012 | </ul> |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1013 | |
7067
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1014 | @param formatCodes list of format codes |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1015 | @type list of str |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1016 | @param textCursor reference to the text cursor |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1017 | @type QTextCursor |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1018 | """ |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1019 | if not formatCodes: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1020 | # empty format codes list is treated as a reset |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1021 | formatCodes = ["0"] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1022 | |
7067
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1023 | charFormat = textCursor.charFormat() |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1024 | for formatCode in formatCodes: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1025 | try: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1026 | formatCode = int(formatCode) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1027 | except ValueError: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1028 | # ignore non digit values |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1029 | continue |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1030 | |
7067
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1031 | if formatCode == 0: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1032 | charFormat.setFontWeight(50) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1033 | charFormat.setFontItalic(False) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1034 | charFormat.setFontUnderline(False) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1035 | charFormat.setFontStrikeOut(False) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1036 | charFormat.setFontOverline(False) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1037 | charFormat.setForeground(self.DefaultForeground) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1038 | charFormat.setBackground(self.DefaultBackground) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1039 | elif formatCode == 1: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1040 | charFormat.setFontWeight(75) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1041 | elif formatCode == 2: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1042 | charFormat.setFontWeight(25) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1043 | elif formatCode == 3: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1044 | charFormat.setFontItalic(True) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1045 | elif formatCode == 4: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1046 | charFormat.setFontUnderline(True) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1047 | elif formatCode == 9: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1048 | charFormat.setFontStrikeOut(True) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1049 | elif formatCode in (21, 22): |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1050 | charFormat.setFontWeight(50) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1051 | elif formatCode == 23: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1052 | charFormat.setFontItalic(False) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1053 | elif formatCode == 24: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1054 | charFormat.setFontUnderline(False) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1055 | elif formatCode == 29: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1056 | charFormat.setFontStrikeOut(False) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1057 | elif formatCode == 53: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1058 | charFormat.setFontOverline(True) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1059 | elif formatCode == 55: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1060 | charFormat.setFontOverline(False) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1061 | elif formatCode in (30, 31, 32, 33, 34, 35, 36, 37): |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
1062 | charFormat.setForeground( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1063 | AnsiColorSchemes[self.__colorScheme][formatCode - 30] |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1064 | ) |
7067
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1065 | elif formatCode in (40, 41, 42, 43, 44, 45, 46, 47): |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
1066 | charFormat.setBackground( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1067 | AnsiColorSchemes[self.__colorScheme][formatCode - 40] |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1068 | ) |
7067
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1069 | elif formatCode in (90, 91, 92, 93, 94, 95, 96, 97): |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
1070 | charFormat.setForeground( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1071 | AnsiColorSchemes[self.__colorScheme][formatCode - 80] |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1072 | ) |
7067
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1073 | elif formatCode in (100, 101, 102, 103, 104, 105, 106, 107): |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
1074 | charFormat.setBackground( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1075 | AnsiColorSchemes[self.__colorScheme][formatCode - 90] |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1076 | ) |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
1077 | elif formatCode == 39: |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
1078 | charFormat.setForeground(self.DefaultForeground) |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
1079 | elif formatCode == 49: |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
1080 | charFormat.setBackground(self.DefaultBackground) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1081 | |
7067
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
1082 | textCursor.setCharFormat(charFormat) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1083 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1084 | def __doZoom(self, value): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1085 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1086 | Private slot to zoom the REPL pane. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1087 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1088 | @param value zoom value |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1089 | @type int |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1090 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1091 | if value < self.__currentZoom: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1092 | self.replEdit.zoomOut(self.__currentZoom - value) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1093 | elif value > self.__currentZoom: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1094 | self.replEdit.zoomIn(value - self.__currentZoom) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1095 | self.__currentZoom = value |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1096 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1097 | def getCurrentPort(self): |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
1098 | """ |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1099 | Public method to determine the port path of the selected device. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1100 | |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
1101 | @return path of the port of the selected device |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
1102 | @rtype str |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
1103 | """ |
8072
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8071
diff
changeset
|
1104 | portName = self.deviceTypeComboBox.currentData(self.DevicePortRole) |
8133
4d1d1c248f79
MicroPython: started adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8121
diff
changeset
|
1105 | if portName: |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9576
diff
changeset
|
1106 | if OSUtilities.isWindowsPlatform(): |
8133
4d1d1c248f79
MicroPython: started adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8121
diff
changeset
|
1107 | # return it unchanged |
4d1d1c248f79
MicroPython: started adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8121
diff
changeset
|
1108 | return portName |
4d1d1c248f79
MicroPython: started adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8121
diff
changeset
|
1109 | else: |
4d1d1c248f79
MicroPython: started adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8121
diff
changeset
|
1110 | # return with device path prepended |
4d1d1c248f79
MicroPython: started adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8121
diff
changeset
|
1111 | return "/dev/{0}".format(portName) |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
1112 | else: |
8133
4d1d1c248f79
MicroPython: started adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8121
diff
changeset
|
1113 | return "" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1114 | |
8072
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8071
diff
changeset
|
1115 | def getCurrentBoard(self): |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8071
diff
changeset
|
1116 | """ |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8071
diff
changeset
|
1117 | Public method to get the board name of the selected device. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1118 | |
8072
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8071
diff
changeset
|
1119 | @return board name of the selected device |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8071
diff
changeset
|
1120 | @rtype str |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8071
diff
changeset
|
1121 | """ |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8071
diff
changeset
|
1122 | boardName = self.deviceTypeComboBox.currentData(self.DeviceBoardRole) |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8071
diff
changeset
|
1123 | return boardName |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1124 | |
9776
210bf87ae5c7
Continued implementing WiFi functionality for RP2040 based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9775
diff
changeset
|
1125 | def getDevice(self): |
210bf87ae5c7
Continued implementing WiFi functionality for RP2040 based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9775
diff
changeset
|
1126 | """ |
210bf87ae5c7
Continued implementing WiFi functionality for RP2040 based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9775
diff
changeset
|
1127 | Public method to get a reference to the current device. |
210bf87ae5c7
Continued implementing WiFi functionality for RP2040 based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9775
diff
changeset
|
1128 | |
210bf87ae5c7
Continued implementing WiFi functionality for RP2040 based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9775
diff
changeset
|
1129 | @return reference to the current device |
210bf87ae5c7
Continued implementing WiFi functionality for RP2040 based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9775
diff
changeset
|
1130 | @rtype BaseDevice |
210bf87ae5c7
Continued implementing WiFi functionality for RP2040 based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9775
diff
changeset
|
1131 | """ |
210bf87ae5c7
Continued implementing WiFi functionality for RP2040 based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9775
diff
changeset
|
1132 | return self.__device |
210bf87ae5c7
Continued implementing WiFi functionality for RP2040 based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9775
diff
changeset
|
1133 | |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7127
diff
changeset
|
1134 | def getDeviceWorkspace(self): |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7127
diff
changeset
|
1135 | """ |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7127
diff
changeset
|
1136 | Public method to get the workspace directory of the device. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1137 | |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7127
diff
changeset
|
1138 | @return workspace directory of the device |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7127
diff
changeset
|
1139 | @rtype str |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7127
diff
changeset
|
1140 | """ |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7127
diff
changeset
|
1141 | if self.__device: |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7127
diff
changeset
|
1142 | return self.__device.getWorkspace() |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7127
diff
changeset
|
1143 | else: |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7127
diff
changeset
|
1144 | return "" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1145 | |
9767
2eed840795c0
Fixed a few issues in the MicroPython file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9766
diff
changeset
|
1146 | def deviceSupportsLocalFileAccess(self): |
2eed840795c0
Fixed a few issues in the MicroPython file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9766
diff
changeset
|
1147 | """ |
2eed840795c0
Fixed a few issues in the MicroPython file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9766
diff
changeset
|
1148 | Public method to indicate that the device access the device file system |
2eed840795c0
Fixed a few issues in the MicroPython file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9766
diff
changeset
|
1149 | via a local directory. |
2eed840795c0
Fixed a few issues in the MicroPython file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9766
diff
changeset
|
1150 | |
2eed840795c0
Fixed a few issues in the MicroPython file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9766
diff
changeset
|
1151 | @return flag indicating file access via local directory |
2eed840795c0
Fixed a few issues in the MicroPython file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9766
diff
changeset
|
1152 | @rtype bool |
2eed840795c0
Fixed a few issues in the MicroPython file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9766
diff
changeset
|
1153 | """ |
2eed840795c0
Fixed a few issues in the MicroPython file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9766
diff
changeset
|
1154 | return self.__device is not None and self.__device.supportsLocalFileAccess() |
2eed840795c0
Fixed a few issues in the MicroPython file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9766
diff
changeset
|
1155 | |
9763
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
1156 | def __connectToDevice(self, withAutostart=False): |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
1157 | """ |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1158 | Private method to connect to the selected device. |
9763
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
1159 | |
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
1160 | @param withAutostart flag indicating to start the repl and file manager |
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
1161 | automatically |
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
1162 | @type bool |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
1163 | """ |
9482
a2bc06a54d9d
Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
1164 | from .ConnectionSelectionDialog import ConnectionSelectionDialog |
a2bc06a54d9d
Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
1165 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1166 | port = self.getCurrentPort() |
8133
4d1d1c248f79
MicroPython: started adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8121
diff
changeset
|
1167 | if not port: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1168 | with EricOverridenCursor(): |
8134
a5c4ac339f2a
MicroPython: finished adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8133
diff
changeset
|
1169 | dlg = ConnectionSelectionDialog( |
a5c4ac339f2a
MicroPython: finished adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8133
diff
changeset
|
1170 | self.__unknownPorts, self.__lastPort, self.__lastDeviceType |
a5c4ac339f2a
MicroPython: finished adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8133
diff
changeset
|
1171 | ) |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
1172 | if dlg.exec() == QDialog.DialogCode.Accepted: |
8134
a5c4ac339f2a
MicroPython: finished adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8133
diff
changeset
|
1173 | vid, pid, port, deviceType = dlg.getData() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1174 | |
8134
a5c4ac339f2a
MicroPython: finished adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8133
diff
changeset
|
1175 | self.deviceIconLabel.setPixmap( |
9759
4543b7876047
Adapted some MicroPython modules to the new package layout.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9752
diff
changeset
|
1176 | Devices.getDeviceIcon(deviceType, False) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1177 | ) |
9765
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
1178 | self.__device = Devices.getDevice(deviceType, self, vid, pid) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1179 | |
8134
a5c4ac339f2a
MicroPython: finished adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8133
diff
changeset
|
1180 | self.__lastPort = port |
a5c4ac339f2a
MicroPython: finished adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8133
diff
changeset
|
1181 | self.__lastDeviceType = deviceType |
8135
7cbb1ebf8d2d
MicroPython: fixed some logic issues related to handling of unknown devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8134
diff
changeset
|
1182 | else: |
7cbb1ebf8d2d
MicroPython: fixed some logic issues related to handling of unknown devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8134
diff
changeset
|
1183 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1184 | |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1185 | if self.__interface.connectToDevice(port): |
9749 | 1186 | deviceResponding = self.__interface.probeDevice() |
1187 | self.__setConnected(deviceResponding) | |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1188 | self.__device.setConnected(deviceResponding) |
9749 | 1189 | if deviceResponding: |
1190 | if ( | |
1191 | Preferences.getMicroPython("SyncTimeAfterConnect") | |
1192 | and self.__device.hasTimeCommands() | |
1193 | ): | |
1194 | self.__synchronizeTime(quiet=True) | |
1195 | else: | |
1196 | with EricOverridenCursor(): | |
1197 | EricMessageBox.warning( | |
1198 | self, | |
1199 | self.tr("Serial Device Connect"), | |
1200 | self.tr( | |
1201 | """<p>The device at serial port <b>{0}</b> does not""" | |
1202 | """ respond. It may not have a MicroPython firmware""" | |
1203 | """ flashed.</p>""" | |
1204 | ).format(port), | |
1205 | ) | |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
1206 | else: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1207 | with EricOverridenCursor(): |
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1208 | EricMessageBox.warning( |
8061
979562f350bf
MicroPython: implemented fixes for a few issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8055
diff
changeset
|
1209 | self, |
979562f350bf
MicroPython: implemented fixes for a few issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8055
diff
changeset
|
1210 | self.tr("Serial Device Connect"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1211 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1212 | """<p>Cannot connect to device at serial""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1213 | """ port <b>{0}</b>.</p>""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1214 | ).format(port), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1215 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1216 | |
9749 | 1217 | self.__device.setButtons() |
9763
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
1218 | if withAutostart: |
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
1219 | self.on_replButton_clicked( |
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
1220 | self.replButton.isEnabled() and self.__linkConnected |
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
1221 | ) |
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
1222 | self.on_filesButton_clicked( |
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
1223 | self.filesButton.isEnabled() and self.__connected |
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
1224 | ) |
9749 | 1225 | |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1226 | def __disconnectFromDevice(self): |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
1227 | """ |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1228 | Private method to disconnect from the device. |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
1229 | """ |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1230 | self.__device.setConnected(False) |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1231 | self.__interface.disconnectFromDevice() |
7135
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1232 | self.__setConnected(False) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1233 | |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
1234 | @pyqtSlot() |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
1235 | def on_runButton_clicked(self): |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
1236 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
1237 | Private slot to execute the script of the active editor on the |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
1238 | selected device. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1239 | |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
1240 | If the REPL is not active yet, it will be activated, which might cause |
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
1241 | an unconnected device to be connected. |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
1242 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
1243 | if not self.__device: |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
1244 | self.__showNoDeviceMessage() |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
1245 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1246 | |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1247 | aw = ericApp().getObject("ViewManager").activeWindow() |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
1248 | if aw is None: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1249 | EricMessageBox.critical( |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
1250 | self, |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
1251 | self.tr("Run Script"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1252 | self.tr("""There is no editor open. Abort..."""), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1253 | ) |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
1254 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1255 | |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
1256 | script = aw.text() |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
1257 | if not script: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1258 | EricMessageBox.critical( |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
1259 | self, |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
1260 | self.tr("Run Script"), |
9576
be9f8e7e42e0
Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9573
diff
changeset
|
1261 | self.tr("""The current editor does not contain a script. Abort..."""), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1262 | ) |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
1263 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1264 | |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
1265 | ok, reason = self.__device.canRunScript() |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
1266 | if not ok: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1267 | EricMessageBox.warning( |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
1268 | self, |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
1269 | self.tr("Run Script"), |
9576
be9f8e7e42e0
Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9573
diff
changeset
|
1270 | self.tr("""<p>Cannot run script.</p><p>Reason: {0}</p>""").format( |
be9f8e7e42e0
Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9573
diff
changeset
|
1271 | reason |
be9f8e7e42e0
Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9573
diff
changeset
|
1272 | ), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1273 | ) |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
1274 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1275 | |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
1276 | if not self.replButton.isChecked(): |
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
1277 | # activate on the REPL |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1278 | self.on_replButton_clicked(True) |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
1279 | if self.replButton.isChecked(): |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
1280 | self.__device.runScript(script) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1281 | |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1282 | @pyqtSlot(bool) |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1283 | def on_chartButton_clicked(self, checked): |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1284 | """ |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1285 | Private slot to open a chart view to plot data received from the |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1286 | connected device. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1287 | |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
1288 | If the selected device is not connected yet, this will be done now. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1289 | |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1290 | @param checked state of the button |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1291 | @type bool |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1292 | """ |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1293 | if not HAS_QTCHART: |
8343
242d5dae2937
Corrected some place to import QtCharts instead of QtChart.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8322
diff
changeset
|
1294 | # QtCharts not available => fail silently |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1295 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1296 | |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1297 | if not self.__device: |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1298 | self.__showNoDeviceMessage() |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1299 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1300 | |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1301 | if checked: |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1302 | ok, reason = self.__device.canStartPlotter() |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1303 | if not ok: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1304 | EricMessageBox.warning( |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1305 | self, |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1306 | self.tr("Start Chart"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1307 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1308 | """<p>The Chart cannot be started.</p><p>Reason:""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1309 | """ {0}</p>""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1310 | ).format(reason), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1311 | ) |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1312 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1313 | |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1314 | self.__chartWidget = MicroPythonGraphWidget(self) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1315 | self.__interface.dataReceived.connect(self.__chartWidget.processData) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1316 | self.__chartWidget.dataFlood.connect(self.handleDataFlood) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1317 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1318 | self.__ui.addSideWidget( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1319 | self.__ui.BottomSide, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1320 | self.__chartWidget, |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
1321 | EricPixmapCache.getIcon("chart"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1322 | self.tr("µPy Chart"), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1323 | ) |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1324 | self.__ui.showSideWidget(self.__chartWidget) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1325 | |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1326 | if not self.__interface.isConnected(): |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1327 | self.__connectToDevice() |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1328 | if self.__device.forceInterrupt(): |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1329 | # send a Ctrl-B (exit raw mode) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1330 | self.__interface.write(b"\x02") |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1331 | # send Ctrl-C (keyboard interrupt) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1332 | self.__interface.write(b"\x03") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1333 | |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1334 | self.__device.setPlotter(True) |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1335 | else: |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1336 | if self.__chartWidget.isDirty(): |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1337 | res = EricMessageBox.okToClearData( |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1338 | self, |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1339 | self.tr("Unsaved Chart Data"), |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1340 | self.tr("""The chart contains unsaved data."""), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1341 | self.__chartWidget.saveData, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1342 | ) |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1343 | if not res: |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1344 | # abort |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1345 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1346 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1347 | self.__interface.dataReceived.disconnect(self.__chartWidget.processData) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1348 | self.__chartWidget.dataFlood.disconnect(self.handleDataFlood) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1349 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1350 | if not self.replButton.isChecked() and not self.filesButton.isChecked(): |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1351 | self.__disconnectFromDevice() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1352 | |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1353 | self.__device.setPlotter(False) |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1354 | self.__ui.removeSideWidget(self.__chartWidget) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1355 | |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1356 | self.__chartWidget.deleteLater() |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1357 | self.__chartWidget = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1358 | |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1359 | self.chartButton.setChecked(checked) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1360 | |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1361 | @pyqtSlot() |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1362 | def handleDataFlood(self): |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1363 | """ |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1364 | Public slot handling a data flood from the device. |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1365 | """ |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
1366 | self.on_connectButton_clicked() |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1367 | self.__device.handleDataFlood() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1368 | |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1369 | @pyqtSlot(bool) |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1370 | def on_filesButton_clicked(self, checked): |
7077
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1371 | """ |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1372 | Private slot to open a file manager window to the connected device. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1373 | |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
1374 | If the selected device is not connected yet, this will be done now. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1375 | |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1376 | @param checked state of the button |
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1377 | @type bool |
7077
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1378 | """ |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1379 | if not self.__device: |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1380 | self.__showNoDeviceMessage() |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1381 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1382 | |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1383 | if checked: |
7077
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1384 | ok, reason = self.__device.canStartFileManager() |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1385 | if not ok: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1386 | EricMessageBox.warning( |
7077
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1387 | self, |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1388 | self.tr("Start File Manager"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1389 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1390 | """<p>The File Manager cannot be started.</p>""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1391 | """<p>Reason: {0}</p>""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1392 | ).format(reason), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1393 | ) |
7077
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1394 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1395 | |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1396 | with EricOverrideCursor(): |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8061
diff
changeset
|
1397 | if not self.__interface.isConnected(): |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8061
diff
changeset
|
1398 | self.__connectToDevice() |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8061
diff
changeset
|
1399 | if self.__connected: |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8061
diff
changeset
|
1400 | self.__fileManagerWidget = MicroPythonFileManagerWidget( |
9765
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
1401 | self.__device, self |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1402 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1403 | |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8061
diff
changeset
|
1404 | self.__ui.addSideWidget( |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8061
diff
changeset
|
1405 | self.__ui.BottomSide, |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8061
diff
changeset
|
1406 | self.__fileManagerWidget, |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
1407 | EricPixmapCache.getIcon("filemanager"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1408 | self.tr("µPy Files"), |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8061
diff
changeset
|
1409 | ) |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8061
diff
changeset
|
1410 | self.__ui.showSideWidget(self.__fileManagerWidget) |
7077
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1411 | |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8061
diff
changeset
|
1412 | self.__device.setFileManager(True) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1413 | |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8061
diff
changeset
|
1414 | self.__fileManagerWidget.start() |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1415 | else: |
9738 | 1416 | if self.__fileManagerWidget is not None: |
1417 | self.__fileManagerWidget.stop() | |
9765
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
1418 | self.__fileManagerWidget.deleteLater() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1419 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1420 | if not self.replButton.isChecked() and not self.chartButton.isChecked(): |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
1421 | self.__disconnectFromDevice() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1422 | |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1423 | self.__device.setFileManager(False) |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
1424 | self.__ui.removeSideWidget(self.__fileManagerWidget) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1425 | |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7094
diff
changeset
|
1426 | self.__fileManagerWidget = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1427 | |
7127
aa6fc2d252ad
MicroPythonReplWidget: fixed an issue resetting the files button on disconnect.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
1428 | self.filesButton.setChecked(checked) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1429 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1430 | ################################################################## |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1431 | ## Super Menu related methods below |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1432 | ################################################################## |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1433 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1434 | def __aboutToShowSuperMenu(self): |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1435 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1436 | Private slot to populate the Super Menu before showing it. |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1437 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1438 | self.__superMenu.clear() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1439 | |
8051
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1440 | # prepare the download menu |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1441 | if self.__device: |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1442 | menuEntries = self.__device.getDownloadMenuEntries() |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1443 | if menuEntries: |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1444 | downloadMenu = QMenu(self.tr("Downloads"), self.__superMenu) |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1445 | for text, url in menuEntries: |
8121
9a2aa5353a32
MicroPythonWidget: added the capability to have menu separators in the downloads sub-menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8117
diff
changeset
|
1446 | if text == "<separator>": |
9a2aa5353a32
MicroPythonWidget: added the capability to have menu separators in the downloads sub-menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8117
diff
changeset
|
1447 | downloadMenu.addSeparator() |
9a2aa5353a32
MicroPythonWidget: added the capability to have menu separators in the downloads sub-menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8117
diff
changeset
|
1448 | else: |
9a2aa5353a32
MicroPythonWidget: added the capability to have menu separators in the downloads sub-menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8117
diff
changeset
|
1449 | downloadMenu.addAction( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1450 | text, functools.partial(self.__downloadFromUrl, url) |
8121
9a2aa5353a32
MicroPythonWidget: added the capability to have menu separators in the downloads sub-menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8117
diff
changeset
|
1451 | ) |
8051
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1452 | else: |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1453 | downloadMenu = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1454 | |
9775
c6806d24468b
Created new branch <mpy_network>.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9772
diff
changeset
|
1455 | # prepare the WiFi menu |
c6806d24468b
Created new branch <mpy_network>.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9772
diff
changeset
|
1456 | if self.__device and self.__connected and self.__device.getDeviceData("wifi"): |
9787
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
1457 | if self.__wifiMenu is not None: |
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
1458 | self.__wifiMenu.deleteLater() |
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
1459 | self.__wifiMenu = self.__wifiController.createMenu(self.__superMenu) |
9775
c6806d24468b
Created new branch <mpy_network>.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9772
diff
changeset
|
1460 | else: |
9787
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
1461 | self.__wifiMenu = None |
9775
c6806d24468b
Created new branch <mpy_network>.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9772
diff
changeset
|
1462 | |
8051
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1463 | # populate the super menu |
8234
fcb6b4b96274
Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
1464 | hasTime = self.__device.hasTimeCommands() if self.__device else False |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1465 | |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1466 | self.__superMenu.addAction( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1467 | self.tr("Show Version"), self.__showDeviceVersion |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1468 | ).setEnabled(self.__connected) |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1469 | self.__superMenu.addAction( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1470 | self.tr("Show Implementation"), self.__showImplementation |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1471 | ).setEnabled(self.__connected) |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1472 | self.__superMenu.addAction( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1473 | self.tr("Show Board Data"), self.__showBoardInformation |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1474 | ).setEnabled(self.__connected) |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1475 | self.__superMenu.addSeparator() |
7123
94948e2aa0a5
Implemented the support for the 'BBC micro:bit' device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7120
diff
changeset
|
1476 | if hasTime: |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1477 | self.__superMenu.addAction( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1478 | self.tr("Synchronize Time"), self.__synchronizeTime |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1479 | ).setEnabled(self.__connected) |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1480 | self.__superMenu.addAction( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1481 | self.tr("Show Device Time"), self.__showDeviceTime |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1482 | ).setEnabled(self.__connected) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1483 | self.__superMenu.addAction(self.tr("Show Local Time"), self.__showLocalTime) |
7325
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1484 | if hasTime: |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1485 | self.__superMenu.addAction( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1486 | self.tr("Show Time"), self.__showLocalAndDeviceTime |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1487 | ).setEnabled(self.__connected) |
7150
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1488 | self.__superMenu.addSeparator() |
9748 | 1489 | self.__superMenu.addAction( |
1490 | self.tr("Show Builtin Modules"), self.__showBuiltinModules | |
1491 | ).setEnabled(self.__connected) | |
1492 | self.__superMenu.addSeparator() | |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9576
diff
changeset
|
1493 | if not OSUtilities.isWindowsPlatform(): |
7150
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1494 | available = self.__mpyCrossAvailable() |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1495 | self.__superMenu.addAction( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1496 | self.tr("Compile Python File"), self.__compileFile2Mpy |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1497 | ).setEnabled(available) |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1498 | aw = ericApp().getObject("ViewManager").activeWindow() |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1499 | self.__superMenu.addAction( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1500 | self.tr("Compile Current Editor"), self.__compileEditor2Mpy |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1501 | ).setEnabled(available and bool(aw)) |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1502 | self.__superMenu.addSeparator() |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1503 | if self.__device: |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1504 | self.__device.addDeviceMenuEntries(self.__superMenu) |
7161
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7150
diff
changeset
|
1505 | self.__superMenu.addSeparator() |
9787
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
1506 | if self.__wifiMenu is not None: |
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
1507 | self.__superMenu.addMenu(self.__wifiMenu) |
9775
c6806d24468b
Created new branch <mpy_network>.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9772
diff
changeset
|
1508 | self.__superMenu.addSeparator() |
8051
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1509 | if downloadMenu is None: |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1510 | # generic download action |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1511 | self.__superMenu.addAction( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1512 | self.tr("Download Firmware"), self.__downloadFirmware |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1513 | ).setEnabled(self.__device.hasFirmwareUrl()) |
8051
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1514 | else: |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1515 | # download sub-menu |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1516 | self.__superMenu.addMenu(downloadMenu) |
7328 | 1517 | self.__superMenu.addSeparator() |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1518 | self.__superMenu.addAction( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1519 | self.tr("Show Documentation"), self.__showDocumentation |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1520 | ).setEnabled(self.__device.hasDocumentationUrl()) |
8096 | 1521 | self.__superMenu.addSeparator() |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1522 | if bool(UF2FlashDialog.getFoundDevices()): |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1523 | self.__superMenu.addAction(self.tr("Flash UF2 Device"), self.__flashUF2) |
8096 | 1524 | self.__superMenu.addSeparator() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1525 | self.__superMenu.addAction( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1526 | self.tr("Manage Unknown Devices"), self.__manageUnknownDevices |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1527 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1528 | self.__superMenu.addAction( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1529 | self.tr("Ignored Serial Devices"), self.__manageIgnored |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1530 | ) |
7592
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
1531 | self.__superMenu.addSeparator() |
7161
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7150
diff
changeset
|
1532 | self.__superMenu.addAction(self.tr("Configure"), self.__configure) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1533 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1534 | @pyqtSlot() |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1535 | def __showDeviceVersion(self): |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1536 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1537 | Private slot to show some version info about MicroPython of the device. |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1538 | """ |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1539 | data = self.__device.getDeviceData() |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1540 | if data: |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1541 | msg = self.tr("<h3>Device Version Information</h3>") |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1542 | msg += "<table>" |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1543 | for key in ("sysname", "nodename", "release", "version", "machine"): |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1544 | msg += "<tr><td><b>{0}</b></td><td>{1}</td></tr>".format( |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1545 | key.capitalize(), data[key] |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1546 | ) |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1547 | msg += "</table>" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1548 | EricMessageBox.information(self, self.tr("Device Version Information"), msg) |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1549 | else: |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1550 | EricMessageBox.critical( |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1551 | self, |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1552 | self.tr("Device Version Information"), |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1553 | self.tr("No version information available."), |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1554 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1555 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1556 | @pyqtSlot() |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1557 | def __showImplementation(self): |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1558 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1559 | Private slot to show some implementation related information. |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1560 | """ |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1561 | data = self.__device.getDeviceData() |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1562 | if data: |
9772
06ef28082c4d
Changed the RP2040 related code of the MicroPython package to show the version info for a MicroPython variant (like Pimoroni Pico) if such is available (e.g. Pimoroni Pico 1.19.14 or newer).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9767
diff
changeset
|
1563 | # name |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1564 | if data["mpy_name"] == "micropython": |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1565 | name = "MicroPython" |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1566 | elif data["mpy_name"] == "circuitpython": |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1567 | name = "CircuitPython" |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1568 | elif data["mpy_name"] == "unknown": |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1569 | name = self.tr("unknown") |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1570 | else: |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1571 | name = data["mpy_name"] |
9772
06ef28082c4d
Changed the RP2040 related code of the MicroPython package to show the version info for a MicroPython variant (like Pimoroni Pico) if such is available (e.g. Pimoroni Pico 1.19.14 or newer).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9767
diff
changeset
|
1572 | |
06ef28082c4d
Changed the RP2040 related code of the MicroPython package to show the version info for a MicroPython variant (like Pimoroni Pico) if such is available (e.g. Pimoroni Pico 1.19.14 or newer).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9767
diff
changeset
|
1573 | # version |
06ef28082c4d
Changed the RP2040 related code of the MicroPython package to show the version info for a MicroPython variant (like Pimoroni Pico) if such is available (e.g. Pimoroni Pico 1.19.14 or newer).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9767
diff
changeset
|
1574 | if data["mpy_variant_version"]: |
06ef28082c4d
Changed the RP2040 related code of the MicroPython package to show the version info for a MicroPython variant (like Pimoroni Pico) if such is available (e.g. Pimoroni Pico 1.19.14 or newer).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9767
diff
changeset
|
1575 | version = data["mpy_variant_version"] |
06ef28082c4d
Changed the RP2040 related code of the MicroPython package to show the version info for a MicroPython variant (like Pimoroni Pico) if such is available (e.g. Pimoroni Pico 1.19.14 or newer).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9767
diff
changeset
|
1576 | elif data["mpy_version"] == "unknown": |
06ef28082c4d
Changed the RP2040 related code of the MicroPython package to show the version info for a MicroPython variant (like Pimoroni Pico) if such is available (e.g. Pimoroni Pico 1.19.14 or newer).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9767
diff
changeset
|
1577 | version = self.tr("unknown") |
06ef28082c4d
Changed the RP2040 related code of the MicroPython package to show the version info for a MicroPython variant (like Pimoroni Pico) if such is available (e.g. Pimoroni Pico 1.19.14 or newer).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9767
diff
changeset
|
1578 | else: |
06ef28082c4d
Changed the RP2040 related code of the MicroPython package to show the version info for a MicroPython variant (like Pimoroni Pico) if such is available (e.g. Pimoroni Pico 1.19.14 or newer).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9767
diff
changeset
|
1579 | version = data["mpy_version"] |
06ef28082c4d
Changed the RP2040 related code of the MicroPython package to show the version info for a MicroPython variant (like Pimoroni Pico) if such is available (e.g. Pimoroni Pico 1.19.14 or newer).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9767
diff
changeset
|
1580 | |
06ef28082c4d
Changed the RP2040 related code of the MicroPython package to show the version info for a MicroPython variant (like Pimoroni Pico) if such is available (e.g. Pimoroni Pico 1.19.14 or newer).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9767
diff
changeset
|
1581 | # variant |
9747 | 1582 | variant = ( |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1583 | self.tr(" ({0})").format(data["mpy_variant"]) |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1584 | if data["mpy_variant"] |
9747 | 1585 | else "" |
1586 | ) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1587 | |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1588 | EricMessageBox.information( |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1589 | self, |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1590 | self.tr("Device Implementation Information"), |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1591 | self.tr( |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1592 | "<h3>Device Implementation Information</h3>" |
9747 | 1593 | "<p>This device contains <b>{0} {1}{2}</b>.</p>" |
1594 | ).format(name, version, variant), | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1595 | ) |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1596 | else: |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1597 | EricMessageBox.critical( |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1598 | self, |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1599 | self.tr("Device Implementation Information"), |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1600 | self.tr("No device implementation information available."), |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1601 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1602 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1603 | @pyqtSlot() |
8928 | 1604 | def __showBoardInformation(self): |
1605 | """ | |
1606 | Private slot to show all available information about a board. | |
1607 | """ | |
9482
a2bc06a54d9d
Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
1608 | from .BoardDataDialog import BoardDataDialog |
a2bc06a54d9d
Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
1609 | |
8928 | 1610 | try: |
9765
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
1611 | boardInfo = self.__device.getBoardInformation() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1612 | |
8928 | 1613 | dlg = BoardDataDialog(boardInfo) |
1614 | dlg.exec() | |
1615 | except Exception as exc: | |
9787
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
1616 | self.showError("getBoardInformation()", str(exc)) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1617 | |
8928 | 1618 | @pyqtSlot() |
7135
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1619 | def __synchronizeTime(self, quiet=False): |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1620 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1621 | Private slot to set the time of the connected device to the local |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1622 | computer's time. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1623 | |
7135
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1624 | @param quiet flag indicating to not show a message |
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1625 | @type bool |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1626 | """ |
8117
aaa5e0eacd4e
MicroPython: changed the logic to synchronize the time because some devices don't implement long integer and failed defining the 'set_time()' function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8104
diff
changeset
|
1627 | if self.__device and self.__device.hasTimeCommands(): |
aaa5e0eacd4e
MicroPython: changed the logic to synchronize the time because some devices don't implement long integer and failed defining the 'set_time()' function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8104
diff
changeset
|
1628 | try: |
9766
f0e22f3a5878
Fixed a few issue introduced during the recent changes to the MicroPython package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9765
diff
changeset
|
1629 | self.__device.syncTime( |
f0e22f3a5878
Fixed a few issue introduced during the recent changes to the MicroPython package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9765
diff
changeset
|
1630 | self.__device.getDeviceType(), |
f0e22f3a5878
Fixed a few issue introduced during the recent changes to the MicroPython package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9765
diff
changeset
|
1631 | hasCPy=self.__device.hasCircuitPython(), |
f0e22f3a5878
Fixed a few issue introduced during the recent changes to the MicroPython package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9765
diff
changeset
|
1632 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1633 | |
8117
aaa5e0eacd4e
MicroPython: changed the logic to synchronize the time because some devices don't implement long integer and failed defining the 'set_time()' function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8104
diff
changeset
|
1634 | if not quiet: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1635 | with EricOverridenCursor(): |
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1636 | EricMessageBox.information( |
8117
aaa5e0eacd4e
MicroPython: changed the logic to synchronize the time because some devices don't implement long integer and failed defining the 'set_time()' function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8104
diff
changeset
|
1637 | self, |
aaa5e0eacd4e
MicroPython: changed the logic to synchronize the time because some devices don't implement long integer and failed defining the 'set_time()' function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8104
diff
changeset
|
1638 | self.tr("Synchronize Time"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1639 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1640 | "<p>The time of the connected device was" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1641 | " synchronized with the local time.</p>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1642 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1643 | + self.__getDeviceTime(), |
8117
aaa5e0eacd4e
MicroPython: changed the logic to synchronize the time because some devices don't implement long integer and failed defining the 'set_time()' function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8104
diff
changeset
|
1644 | ) |
aaa5e0eacd4e
MicroPython: changed the logic to synchronize the time because some devices don't implement long integer and failed defining the 'set_time()' function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8104
diff
changeset
|
1645 | except Exception as exc: |
9787
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
1646 | self.showError("syncTime()", str(exc)) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1647 | |
7135
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1648 | def __getDeviceTime(self): |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1649 | """ |
7135
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1650 | Private method to get a string containing the date and time of the |
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1651 | connected device. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1652 | |
7135
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1653 | @return date and time of the connected device |
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1654 | @rtype str |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1655 | """ |
8117
aaa5e0eacd4e
MicroPython: changed the logic to synchronize the time because some devices don't implement long integer and failed defining the 'set_time()' function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8104
diff
changeset
|
1656 | if self.__device and self.__device.hasTimeCommands(): |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1657 | try: |
9765
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
1658 | dateTimeString = self.__device.getTime() |
8117
aaa5e0eacd4e
MicroPython: changed the logic to synchronize the time because some devices don't implement long integer and failed defining the 'set_time()' function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8104
diff
changeset
|
1659 | try: |
aaa5e0eacd4e
MicroPython: changed the logic to synchronize the time because some devices don't implement long integer and failed defining the 'set_time()' function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8104
diff
changeset
|
1660 | date, time = dateTimeString.strip().split(None, 1) |
aaa5e0eacd4e
MicroPython: changed the logic to synchronize the time because some devices don't implement long integer and failed defining the 'set_time()' function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8104
diff
changeset
|
1661 | return self.tr( |
aaa5e0eacd4e
MicroPython: changed the logic to synchronize the time because some devices don't implement long integer and failed defining the 'set_time()' function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8104
diff
changeset
|
1662 | "<h3>Device Date and Time</h3>" |
aaa5e0eacd4e
MicroPython: changed the logic to synchronize the time because some devices don't implement long integer and failed defining the 'set_time()' function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8104
diff
changeset
|
1663 | "<table>" |
aaa5e0eacd4e
MicroPython: changed the logic to synchronize the time because some devices don't implement long integer and failed defining the 'set_time()' function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8104
diff
changeset
|
1664 | "<tr><td><b>Date</b></td><td>{0}</td></tr>" |
aaa5e0eacd4e
MicroPython: changed the logic to synchronize the time because some devices don't implement long integer and failed defining the 'set_time()' function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8104
diff
changeset
|
1665 | "<tr><td><b>Time</b></td><td>{1}</td></tr>" |
aaa5e0eacd4e
MicroPython: changed the logic to synchronize the time because some devices don't implement long integer and failed defining the 'set_time()' function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8104
diff
changeset
|
1666 | "</table>" |
aaa5e0eacd4e
MicroPython: changed the logic to synchronize the time because some devices don't implement long integer and failed defining the 'set_time()' function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8104
diff
changeset
|
1667 | ).format(date, time) |
aaa5e0eacd4e
MicroPython: changed the logic to synchronize the time because some devices don't implement long integer and failed defining the 'set_time()' function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8104
diff
changeset
|
1668 | except ValueError: |
9576
be9f8e7e42e0
Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9573
diff
changeset
|
1669 | return self.tr("<h3>Device Date and Time</h3><p>{0}</p>").format( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1670 | dateTimeString.strip() |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1671 | ) |
8117
aaa5e0eacd4e
MicroPython: changed the logic to synchronize the time because some devices don't implement long integer and failed defining the 'set_time()' function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8104
diff
changeset
|
1672 | except Exception as exc: |
9787
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
1673 | self.showError("getTime()", str(exc)) |
8117
aaa5e0eacd4e
MicroPython: changed the logic to synchronize the time because some devices don't implement long integer and failed defining the 'set_time()' function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8104
diff
changeset
|
1674 | return "" |
aaa5e0eacd4e
MicroPython: changed the logic to synchronize the time because some devices don't implement long integer and failed defining the 'set_time()' function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8104
diff
changeset
|
1675 | else: |
7135
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1676 | return "" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1677 | |
7135
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1678 | @pyqtSlot() |
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1679 | def __showDeviceTime(self): |
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1680 | """ |
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1681 | Private slot to show the date and time of the connected device. |
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1682 | """ |
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1683 | msg = self.__getDeviceTime() |
8061
979562f350bf
MicroPython: implemented fixes for a few issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8055
diff
changeset
|
1684 | if msg: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1685 | EricMessageBox.information(self, self.tr("Device Date and Time"), msg) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1686 | |
7133
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1687 | @pyqtSlot() |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1688 | def __showLocalTime(self): |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1689 | """ |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1690 | Private slot to show the local date and time. |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1691 | """ |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1692 | localdatetime = time.localtime() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1693 | localdate = time.strftime("%Y-%m-%d", localdatetime) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1694 | localtime = time.strftime("%H:%M:%S", localdatetime) |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1695 | EricMessageBox.information( |
7133
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1696 | self, |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1697 | self.tr("Local Date and Time"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1698 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1699 | "<h3>Local Date and Time</h3>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1700 | "<table>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1701 | "<tr><td><b>Date</b></td><td>{0}</td></tr>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1702 | "<tr><td><b>Time</b></td><td>{1}</td></tr>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1703 | "</table>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1704 | ).format(localdate, localtime), |
7133
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1705 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1706 | |
7325
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1707 | @pyqtSlot() |
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1708 | def __showLocalAndDeviceTime(self): |
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1709 | """ |
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1710 | Private slot to show the local and device time side-by-side. |
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1711 | """ |
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1712 | localdatetime = time.localtime() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1713 | localdate = time.strftime("%Y-%m-%d", localdatetime) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1714 | localtime = time.strftime("%H:%M:%S", localdatetime) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1715 | |
7325
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1716 | try: |
9765
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
1717 | deviceDateTimeString = self.__device.getTime() |
7325
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1718 | try: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1719 | devicedate, devicetime = deviceDateTimeString.strip().split(None, 1) |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1720 | EricMessageBox.information( |
7325
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1721 | self, |
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1722 | self.tr("Date and Time"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1723 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1724 | "<table>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1725 | "<tr><th></th><th>Local Date and Time</th>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1726 | "<th>Device Date and Time</th></tr>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1727 | "<tr><td><b>Date</b></td>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1728 | "<td align='center'>{0}</td>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1729 | "<td align='center'>{2}</td></tr>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1730 | "<tr><td><b>Time</b></td>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1731 | "<td align='center'>{1}</td>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1732 | "<td align='center'>{3}</td></tr>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1733 | "</table>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1734 | ).format(localdate, localtime, devicedate, devicetime), |
7325
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1735 | ) |
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1736 | except ValueError: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1737 | EricMessageBox.information( |
7325
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1738 | self, |
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1739 | self.tr("Date and Time"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1740 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1741 | "<table>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1742 | "<tr><th>Local Date and Time</th>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1743 | "<th>Device Date and Time</th></tr>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1744 | "<tr><td align='center'>{0} {1}</td>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1745 | "<td align='center'>{2}</td></tr>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1746 | "</table>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1747 | ).format(localdate, localtime, deviceDateTimeString.strip()), |
7325
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1748 | ) |
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1749 | except Exception as exc: |
9787
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
1750 | self.showError("getTime()", str(exc)) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1751 | |
9787
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
1752 | def showError(self, method, error): |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1753 | """ |
9787
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
1754 | Public method to show some error message. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1755 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1756 | @param method name of the method the error occured in |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1757 | @type str |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1758 | @param error error message |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1759 | @type str |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1760 | """ |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1761 | with EricOverridenCursor(): |
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1762 | EricMessageBox.warning( |
8061
979562f350bf
MicroPython: implemented fixes for a few issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8055
diff
changeset
|
1763 | self, |
979562f350bf
MicroPython: implemented fixes for a few issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8055
diff
changeset
|
1764 | self.tr("Error handling device"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1765 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1766 | "<p>There was an error communicating with the" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1767 | " connected device.</p><p>Method: {0}</p>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1768 | "<p>Message: {1}</p>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1769 | ).format(method, error), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1770 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1771 | |
7150
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1772 | def __mpyCrossAvailable(self): |
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1773 | """ |
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1774 | Private method to check the availability of mpy-cross. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1775 | |
7150
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1776 | @return flag indicating the availability of mpy-cross |
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1777 | @rtype bool |
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1778 | """ |
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1779 | available = False |
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1780 | program = Preferences.getMicroPython("MpyCrossCompiler") |
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1781 | if not program: |
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1782 | program = "mpy-cross" |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9576
diff
changeset
|
1783 | if FileSystemUtilities.isinpath(program): |
7150
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1784 | available = True |
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1785 | else: |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9576
diff
changeset
|
1786 | if FileSystemUtilities.isExecutable(program): |
7150
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1787 | available = True |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1788 | |
7150
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1789 | return available |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1790 | |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1791 | def __crossCompile(self, pythonFile="", title=""): |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1792 | """ |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1793 | Private method to cross compile a Python file to a .mpy file. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1794 | |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1795 | @param pythonFile name of the Python file to be compiled |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1796 | @type str |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1797 | @param title title for the various dialogs |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1798 | @type str |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1799 | """ |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1800 | program = Preferences.getMicroPython("MpyCrossCompiler") |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1801 | if not program: |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1802 | program = "mpy-cross" |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9576
diff
changeset
|
1803 | if not FileSystemUtilities.isinpath(program): |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1804 | EricMessageBox.critical( |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1805 | self, |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1806 | title, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1807 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1808 | """The MicroPython cross compiler""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1809 | """ <b>mpy-cross</b> cannot be found. Ensure it""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1810 | """ is in the search path or configure it on""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1811 | """ the MicroPython configuration page.""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1812 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1813 | ) |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1814 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1815 | |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1816 | if not pythonFile: |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1817 | defaultDirectory = "" |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1818 | aw = ericApp().getObject("ViewManager").activeWindow() |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1819 | if aw: |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1820 | fn = aw.getFileName() |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1821 | if fn: |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1822 | defaultDirectory = os.path.dirname(fn) |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1823 | if not defaultDirectory: |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8061
diff
changeset
|
1824 | defaultDirectory = ( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1825 | Preferences.getMicroPython("MpyWorkspace") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1826 | or Preferences.getMultiProject("Workspace") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1827 | or os.path.expanduser("~") |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8061
diff
changeset
|
1828 | ) |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1829 | pythonFile = EricFileDialog.getOpenFileName( |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1830 | self, |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1831 | title, |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1832 | defaultDirectory, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1833 | self.tr("Python Files (*.py);;All Files (*)"), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1834 | ) |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1835 | if not pythonFile: |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1836 | # user cancelled |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1837 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1838 | |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1839 | if not os.path.exists(pythonFile): |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1840 | EricMessageBox.critical( |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1841 | self, |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1842 | title, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1843 | self.tr( |
9573
9960d19d66b5
Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9496
diff
changeset
|
1844 | """The Python file <b>{0}</b> does not exist. Aborting...""" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1845 | ).format(pythonFile), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1846 | ) |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1847 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1848 | |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1849 | compileArgs = [ |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1850 | pythonFile, |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1851 | ] |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1852 | dlg = EricProcessDialog(self.tr("'mpy-cross' Output"), title) |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1853 | res = dlg.startProcess(program, compileArgs) |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1854 | if res: |
7759
51aa6c6b66f7
Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7609
diff
changeset
|
1855 | dlg.exec() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1856 | |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1857 | @pyqtSlot() |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1858 | def __compileFile2Mpy(self): |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1859 | """ |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1860 | Private slot to cross compile a Python file (*.py) to a .mpy file. |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1861 | """ |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1862 | self.__crossCompile(title=self.tr("Compile Python File")) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1863 | |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1864 | @pyqtSlot() |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1865 | def __compileEditor2Mpy(self): |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1866 | """ |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1867 | Private slot to cross compile the current editor to a .mpy file. |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1868 | """ |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1869 | aw = ericApp().getObject("ViewManager").activeWindow() |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1870 | if not aw.checkDirty(): |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1871 | # editor still has unsaved changes, abort... |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1872 | return |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1873 | if not aw.isPyFile(): |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1874 | # no Python file |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1875 | EricMessageBox.critical( |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1876 | self, |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1877 | self.tr("Compile Current Editor"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1878 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1879 | """The current editor does not contain a Python""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1880 | """ file. Aborting...""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1881 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1882 | ) |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1883 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1884 | |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1885 | self.__crossCompile( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1886 | pythonFile=aw.getFileName(), title=self.tr("Compile Current Editor") |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1887 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1888 | |
7161
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7150
diff
changeset
|
1889 | @pyqtSlot() |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7150
diff
changeset
|
1890 | def __showDocumentation(self): |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7150
diff
changeset
|
1891 | """ |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7150
diff
changeset
|
1892 | Private slot to open the documentation URL for the selected device. |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7150
diff
changeset
|
1893 | """ |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7150
diff
changeset
|
1894 | if self.__device is None or not self.__device.hasDocumentationUrl(): |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7150
diff
changeset
|
1895 | # abort silently |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7150
diff
changeset
|
1896 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1897 | |
7161
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7150
diff
changeset
|
1898 | url = self.__device.getDocumentationUrl() |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1899 | ericApp().getObject("UserInterface").launchHelpViewer(url) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1900 | |
7161
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7150
diff
changeset
|
1901 | @pyqtSlot() |
7328 | 1902 | def __downloadFirmware(self): |
1903 | """ | |
1904 | Private slot to open the firmware download page. | |
1905 | """ | |
1906 | if self.__device is None or not self.__device.hasFirmwareUrl(): | |
1907 | # abort silently | |
1908 | return | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1909 | |
8038
73ec029d4107
MicroPython: improved the support for "BBC micro:bit" and "Calliope mini".
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8024
diff
changeset
|
1910 | self.__device.downloadFirmware() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1911 | |
8051
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1912 | def __downloadFromUrl(self, url): |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1913 | """ |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1914 | Private method to open a web browser for the given URL. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1915 | |
8051
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1916 | @param url URL to be opened |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1917 | @type str |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1918 | """ |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1919 | if self.__device is None: |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1920 | # abort silently |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1921 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1922 | |
8051
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1923 | if url: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1924 | ericApp().getObject("UserInterface").launchHelpViewer(url) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1925 | |
7328 | 1926 | @pyqtSlot() |
7592
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
1927 | def __manageIgnored(self): |
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
1928 | """ |
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
1929 | Private slot to manage the list of ignored serial devices. |
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
1930 | """ |
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
1931 | from .IgnoredDevicesDialog import IgnoredDevicesDialog |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1932 | |
7592
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
1933 | dlg = IgnoredDevicesDialog( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1934 | Preferences.getMicroPython("IgnoredUnknownDevices"), self |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1935 | ) |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
1936 | if dlg.exec() == QDialog.DialogCode.Accepted: |
7592
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
1937 | ignoredDevices = dlg.getDevices() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1938 | Preferences.setMicroPython("IgnoredUnknownDevices", ignoredDevices) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1939 | |
7592
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
1940 | @pyqtSlot() |
7161
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7150
diff
changeset
|
1941 | def __configure(self): |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7150
diff
changeset
|
1942 | """ |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7150
diff
changeset
|
1943 | Private slot to open the MicroPython configuration page. |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7150
diff
changeset
|
1944 | """ |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1945 | ericApp().getObject("UserInterface").showPreferences("microPythonPage") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1946 | |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1947 | @pyqtSlot() |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1948 | def __manageUnknownDevices(self): |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1949 | """ |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1950 | Private slot to manage manually added boards (i.e. those not in the |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1951 | list of supported boards). |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1952 | """ |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1953 | from .UnknownDevicesDialog import UnknownDevicesDialog |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1954 | |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1955 | dlg = UnknownDevicesDialog() |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1956 | dlg.exec() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1957 | |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1958 | def __addUnknownDevices(self, devices): |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1959 | """ |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1960 | Private method to add devices to the list of manually added boards. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1961 | |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1962 | @param devices list of not ignored but unknown devices |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1963 | @type list of tuple of (int, int, str) |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1964 | """ |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1965 | from .AddEditDevicesDialog import AddEditDevicesDialog |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1966 | |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1967 | if len(devices) > 1: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1968 | sdlg = EricListSelectionDialog( |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1969 | [d[2] for d in devices], |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1970 | title=self.tr("Add Unknown Devices"), |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1971 | message=self.tr("Select the devices to be added:"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1972 | checkBoxSelection=True, |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1973 | ) |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
1974 | if sdlg.exec() == QDialog.DialogCode.Accepted: |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1975 | selectedDevices = sdlg.getSelection() |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1976 | else: |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1977 | selectedDevices = devices[0][2] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1978 | |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1979 | if selectedDevices: |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1980 | manualDevices = Preferences.getMicroPython("ManualDevices") |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1981 | for vid, pid, description in devices: |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1982 | if description in selectedDevices: |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1983 | dlg = AddEditDevicesDialog(vid, pid, description) |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8139
diff
changeset
|
1984 | if dlg.exec() == QDialog.DialogCode.Accepted: |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1985 | manualDevices.append(dlg.getDeviceDict()) |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1986 | Preferences.setMicroPython("ManualDevices", manualDevices) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1987 | |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1988 | # rescan the ports |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1989 | self.__populateDeviceTypeComboBox() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1990 | |
8096 | 1991 | @pyqtSlot() |
1992 | def __flashUF2(self): | |
1993 | """ | |
1994 | Private slot to flash MicroPython/CircuitPython to a device | |
1995 | support the UF2 bootloader. | |
1996 | """ | |
1997 | dlg = UF2FlashDialog.UF2FlashDialog() | |
1998 | dlg.exec() | |
9748 | 1999 | |
2000 | @pyqtSlot() | |
2001 | def __showBuiltinModules(self): | |
2002 | """ | |
2003 | Private slot to show a list of builtin modules. | |
2004 | """ | |
2005 | from .ShowModulesDialog import ShowModulesDialog | |
2006 | ||
2007 | if self.__connected: | |
9749 | 2008 | try: |
9765
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
2009 | moduleNames = self.__device.getModules() |
9749 | 2010 | dlg = ShowModulesDialog( |
2011 | moduleNames, | |
2012 | info=self.tr("Plus any modules on the filesystem."), | |
2013 | parent=self, | |
2014 | ) | |
2015 | dlg.show() | |
2016 | except Exception as exc: | |
9787
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
2017 | self.showError("getModules()", str(exc)) |