Thu, 15 Aug 2019 17:19:28 +0200
Fixed some code style issues.
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 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
3 | # Copyright (c) 2019 Detlev Offenbach <detlev@die-offenbachs.de> |
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 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | from __future__ import unicode_literals |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | 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
|
13 | import time |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
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
|
15 | from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QPoint, QEvent |
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
|
16 | from PyQt5.QtGui import QColor, QKeySequence, QTextCursor, QBrush |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | from PyQt5.QtWidgets import ( |
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
|
18 | QWidget, QMenu, QApplication, QHBoxLayout, QSpacerItem, QSizePolicy, |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
19 | QTextEdit, QToolButton |
7067
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
20 | ) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | from E5Gui.E5ZoomWidget import E5ZoomWidget |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
23 | from E5Gui import E5MessageBox, E5FileDialog |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
24 | from E5Gui.E5Application import e5App |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | |
7134
21d23ca51680
Renamed "MicroPythonReplWidget" to "MicroPythonWidget".
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7133
diff
changeset
|
26 | from .Ui_MicroPythonWidget import Ui_MicroPythonWidget |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | from . import MicroPythonDevices |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
29 | try: |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
30 | from .MicroPythonGraphWidget import MicroPythonGraphWidget |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
31 | HAS_QTCHART = True |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
32 | except ImportError: |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
33 | HAS_QTCHART = False |
7077
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
34 | from .MicroPythonFileManagerWidget import MicroPythonFileManagerWidget |
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
|
35 | try: |
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
|
36 | from .MicroPythonCommandsInterface import MicroPythonCommandsInterface |
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
|
37 | 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
|
38 | 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
|
39 | HAS_QTSERIALPORT = False |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | import Globals |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | import UI.PixmapCache |
7067
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
43 | import Preferences |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
45 | # 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
|
46 | AnsiColorSchemes = { |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
47 | "Windows 7": { |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
48 | 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
|
49 | 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
|
50 | 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
|
51 | 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
|
52 | 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
|
53 | 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
|
54 | 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
|
55 | 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
|
56 | 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
|
57 | 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
|
58 | 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
|
59 | 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
|
60 | 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
|
61 | 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
|
62 | 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
|
63 | 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
|
64 | }, |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
65 | "Windows 10": { |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
66 | 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
|
67 | 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
|
68 | 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
|
69 | 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
|
70 | 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
|
71 | 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
|
72 | 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
|
73 | 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
|
74 | 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
|
75 | 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
|
76 | 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
|
77 | 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
|
78 | 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
|
79 | 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
|
80 | 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
|
81 | 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
|
82 | }, |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
83 | "PuTTY": { |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
84 | 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
|
85 | 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
|
86 | 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
|
87 | 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
|
88 | 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
|
89 | 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
|
90 | 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
|
91 | 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
|
92 | 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
|
93 | 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
|
94 | 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
|
95 | 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
|
96 | 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
|
97 | 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
|
98 | 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
|
99 | 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
|
100 | }, |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
101 | "xterm": { |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
102 | 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
|
103 | 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
|
104 | 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
|
105 | 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
|
106 | 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
|
107 | 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
|
108 | 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
|
109 | 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
|
110 | 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
|
111 | 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
|
112 | 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
|
113 | 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
|
114 | 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
|
115 | 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
|
116 | 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
|
117 | 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
|
118 | }, |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
119 | "Ubuntu": { |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
120 | 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
|
121 | 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
|
122 | 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
|
123 | 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
|
124 | 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
|
125 | 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
|
126 | 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
|
127 | 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
|
128 | 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
|
129 | 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
|
130 | 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
|
131 | 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
|
132 | 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
|
133 | 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
|
134 | 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
|
135 | 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
|
136 | }, |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
137 | } |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
138 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
139 | |
7134
21d23ca51680
Renamed "MicroPythonReplWidget" to "MicroPythonWidget".
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7133
diff
changeset
|
140 | class MicroPythonWidget(QWidget, Ui_MicroPythonWidget): |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
141 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
142 | Class implementing the MicroPython REPL widget. |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
143 | |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
144 | @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
|
145 | connection for further processing |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
146 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
147 | ZoomMin = -10 |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
148 | ZoomMax = 20 |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
149 | |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
150 | DeviceTypeRole = Qt.UserRole |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
151 | DevicePortRole = Qt.UserRole + 1 |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
152 | |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
153 | dataReceived = pyqtSignal(bytes) |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
154 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
155 | def __init__(self, parent=None): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
156 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | Constructor |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
159 | @param parent reference to the parent widget |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
160 | @type QWidget |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
161 | """ |
7134
21d23ca51680
Renamed "MicroPythonReplWidget" to "MicroPythonWidget".
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7133
diff
changeset
|
162 | super(MicroPythonWidget, self).__init__(parent) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | self.setupUi(self) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
165 | self.__ui = parent |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
166 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
167 | 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
|
168 | self.__superMenu.aboutToShow.connect(self.__aboutToShowSuperMenu) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
169 | |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
170 | self.menuButton.setObjectName( |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
171 | "micropython_supermenu_button") |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
172 | self.menuButton.setIcon(UI.PixmapCache.getIcon("superMenu")) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
173 | self.menuButton.setToolTip(self.tr("pip Menu")) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
174 | self.menuButton.setPopupMode(QToolButton.InstantPopup) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
175 | self.menuButton.setToolButtonStyle(Qt.ToolButtonIconOnly) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
176 | self.menuButton.setFocusPolicy(Qt.NoFocus) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
177 | 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
|
178 | 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
|
179 | self.menuButton.setMenu(self.__superMenu) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
180 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
181 | self.deviceIconLabel.setPixmap(MicroPythonDevices.getDeviceIcon( |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
182 | "", False)) |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
183 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
184 | self.openButton.setIcon(UI.PixmapCache.getIcon("open")) |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
185 | self.saveButton.setIcon(UI.PixmapCache.getIcon("fileSaveAs")) |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
186 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
187 | self.checkButton.setIcon(UI.PixmapCache.getIcon("question")) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
188 | self.runButton.setIcon(UI.PixmapCache.getIcon("start")) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
189 | self.replButton.setIcon(UI.PixmapCache.getIcon("terminal")) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
190 | self.filesButton.setIcon(UI.PixmapCache.getIcon("filemanager")) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
191 | self.chartButton.setIcon(UI.PixmapCache.getIcon("chart")) |
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
|
192 | self.connectButton.setIcon(UI.PixmapCache.getIcon("linkConnect")) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
193 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
194 | self.__zoomLayout = QHBoxLayout() |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
195 | spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
196 | QSizePolicy.Minimum) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
197 | self.__zoomLayout.addSpacerItem(spacerItem) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
198 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
199 | self.__zoom0 = self.replEdit.fontPointSize() |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
200 | self.__zoomWidget = E5ZoomWidget( |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
201 | UI.PixmapCache.getPixmap("zoomOut"), |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
202 | UI.PixmapCache.getPixmap("zoomIn"), |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
203 | UI.PixmapCache.getPixmap("zoomReset"), self) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
204 | self.__zoomLayout.addWidget(self.__zoomWidget) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
205 | self.layout().insertLayout( |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
206 | self.layout().count() - 1, |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
207 | self.__zoomLayout) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
208 | self.__zoomWidget.setMinimum(self.ZoomMin) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
209 | self.__zoomWidget.setMaximum(self.ZoomMax) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
210 | self.__zoomWidget.valueChanged.connect(self.__doZoom) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
211 | self.__currentZoom = 0 |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
212 | |
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
|
213 | self.__fileManagerWidget = None |
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
|
214 | |
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
|
215 | self.__interface = MicroPythonCommandsInterface(self) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
216 | 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
|
217 | self.__connected = 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
|
218 | self.__setConnected(False) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
219 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
220 | if not HAS_QTSERIALPORT: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
221 | self.replEdit.setHtml(self.tr( |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
222 | "<h3>The QtSerialPort package is not available.<br/>" |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
223 | "MicroPython support is deactivated.</h3>")) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
224 | self.setEnabled(False) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
225 | return |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
226 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
227 | self.__vt100Re = re.compile( |
7067
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
228 | r'(?P<count>\d*)(?P<color>(?:;?\d*)*)(?P<action>[ABCDKm])') |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
229 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
230 | self.__populateDeviceTypeComboBox() |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
231 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
232 | self.replEdit.installEventFilter(self) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
233 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
234 | self.replEdit.customContextMenuRequested.connect( |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
235 | self.__showContextMenu) |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
236 | self.__ui.preferencesChanged.connect(self.__handlePreferencesChanged) |
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
|
237 | self.__ui.preferencesChanged.connect( |
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
|
238 | self.__interface.handlePreferencesChanged) |
7066
e3d034e65afc
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7065
diff
changeset
|
239 | |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
240 | self.__handlePreferencesChanged() |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
241 | |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
242 | charFormat = self.replEdit.currentCharFormat() |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
243 | self.DefaultForeground = charFormat.foreground() |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
244 | self.DefaultBackground = charFormat.background() |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
245 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
246 | def __populateDeviceTypeComboBox(self): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
247 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
248 | Private method to populate the device type selector. |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
249 | """ |
7120
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
250 | currentDevice = self.deviceTypeComboBox.currentText() |
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
251 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
252 | self.deviceTypeComboBox.clear() |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
253 | self.deviceInfoLabel.clear() |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
254 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
255 | self.deviceTypeComboBox.addItem("", "") |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
256 | devices = MicroPythonDevices.getFoundDevices() |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
257 | if devices: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
258 | self.deviceInfoLabel.setText( |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
259 | self.tr("%n supported device(s) detected.", n=len(devices))) |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
260 | |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
261 | index = 0 |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
262 | for device in sorted(devices): |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
263 | index += 1 |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
264 | self.deviceTypeComboBox.addItem( |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
265 | self.tr("{0} at {1}".format(device[1], device[2]))) |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
266 | self.deviceTypeComboBox.setItemData( |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
267 | index, device[0], self.DeviceTypeRole) |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
268 | self.deviceTypeComboBox.setItemData( |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
269 | index, device[2], self.DevicePortRole) |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
270 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
271 | else: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
272 | self.deviceInfoLabel.setText( |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
273 | self.tr("No supported devices detected.")) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
274 | |
7120
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
275 | index = self.deviceTypeComboBox.findText(currentDevice, |
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
276 | Qt.MatchExactly) |
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
277 | if index == -1: |
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
278 | # entry is no longer present |
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
279 | index = 0 |
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
280 | if self.__connected: |
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
281 | # we are still connected, so disconnect |
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
282 | self.on_connectButton_clicked() |
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
283 | |
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
284 | self.on_deviceTypeComboBox_activated(index) |
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
285 | self.deviceTypeComboBox.setCurrentIndex(index) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
286 | |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
287 | def __handlePreferencesChanged(self): |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
288 | """ |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
289 | 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
|
290 | """ |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
291 | self.__colorScheme = Preferences.getMicroPython("ColorScheme") |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
292 | |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
293 | 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
|
294 | 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
|
295 | self.replEdit.setFontPointSize(self.__font.pointSize()) |
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
|
296 | |
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
|
297 | if Preferences.getMicroPython("ReplLineWrap"): |
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
|
298 | self.replEdit.setLineWrapMode(QTextEdit.WidgetWidth) |
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
|
299 | else: |
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
|
300 | self.replEdit.setLineWrapMode(QTextEdit.NoWrap) |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
301 | |
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
|
302 | def commandsInterface(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
|
303 | """ |
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
|
304 | Public method to get a reference to the commands interface object. |
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
|
305 | |
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
|
306 | @return reference to the commands interface object |
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
|
307 | @rtype MicroPythonCommandsInterface |
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
|
308 | """ |
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
|
309 | return self.__interface |
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
|
310 | |
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
|
311 | 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
|
312 | """ |
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
|
313 | Public method to check, if the connected/selected device is a |
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
|
314 | BBC micro:bit. |
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
|
315 | |
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
|
316 | @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
|
317 | 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
|
318 | """ |
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
|
319 | if self.__device and "micro:bit" in self.__device.deviceName(): |
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
|
320 | return True |
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
|
321 | |
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
|
322 | return False |
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
|
323 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
324 | @pyqtSlot(int) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
325 | def on_deviceTypeComboBox_activated(self, index): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
326 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
327 | Private slot handling the selection of a device type. |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
328 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
329 | @param index index of the selected device |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
330 | @type int |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
331 | """ |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
332 | deviceType = self.deviceTypeComboBox.itemData( |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
333 | index, self.DeviceTypeRole) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
334 | self.deviceIconLabel.setPixmap(MicroPythonDevices.getDeviceIcon( |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
335 | deviceType, False)) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
336 | |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
337 | self.__device = MicroPythonDevices.getDevice(deviceType, self) |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
338 | self.__device.setButtons() |
7111
62191d1aeeed
MicroPythonReplWidget: made the connect button more intelligent.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
339 | |
62191d1aeeed
MicroPythonReplWidget: made the connect button more intelligent.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
340 | self.connectButton.setEnabled(bool(deviceType)) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
341 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
342 | @pyqtSlot() |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
343 | def on_checkButton_clicked(self): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
344 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
345 | Private slot to check for connected devices. |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
346 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
347 | self.__populateDeviceTypeComboBox() |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
348 | |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
349 | def setActionButtons(self, **kwargs): |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
350 | """ |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
351 | Public method to set the enabled state of the various action buttons. |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
352 | |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
353 | @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
|
354 | are 'run', 'repl', 'files', 'chart', 'open', 'save' |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
355 | @type dict |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
356 | """ |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
357 | if "open" in kwargs: |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
358 | self.openButton.setEnabled(kwargs["open"]) |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
359 | if "save" in kwargs: |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
360 | self.saveButton.setEnabled(kwargs["save"]) |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
361 | if "run" in kwargs: |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
362 | self.runButton.setEnabled(kwargs["run"]) |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
363 | if "repl" in kwargs: |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
364 | self.replButton.setEnabled(kwargs["repl"]) |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
365 | if "files" in kwargs: |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
366 | self.filesButton.setEnabled(kwargs["files"]) |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
367 | if "chart" in kwargs: |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
368 | self.chartButton.setEnabled(kwargs["chart"]) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
369 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
370 | @pyqtSlot(QPoint) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
371 | def __showContextMenu(self, pos): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
372 | """ |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
373 | Private slot to show the REPL context menu. |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
374 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
375 | @param pos position to show the menu at |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
376 | @type QPoint |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
377 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
378 | if Globals.isMacPlatform(): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
379 | copyKeys = QKeySequence(Qt.CTRL + Qt.Key_C) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
380 | pasteKeys = QKeySequence(Qt.CTRL + Qt.Key_V) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
381 | else: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
382 | copyKeys = QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_C) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
383 | pasteKeys = QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_V) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
384 | menu = QMenu(self) |
7094
d5f340dfb986
MicroPythonReplWidget: added a context menu action to clear the REPL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7090
diff
changeset
|
385 | menu.addAction(self.tr("Clear"), self.__clear) |
d5f340dfb986
MicroPythonReplWidget: added a context menu action to clear the REPL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7090
diff
changeset
|
386 | menu.addSeparator() |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
387 | menu.addAction(self.tr("Copy"), self.replEdit.copy, copyKeys) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
388 | menu.addAction(self.tr("Paste"), self.__paste, pasteKeys) |
7066
e3d034e65afc
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7065
diff
changeset
|
389 | menu.addSeparator() |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
390 | menu.exec_(self.replEdit.mapToGlobal(pos)) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
391 | |
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
|
392 | def __setConnected(self, connected): |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
393 | """ |
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
|
394 | Private method to set the connection status LED. |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
395 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
396 | @param connected connection state |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
397 | @type bool |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
398 | """ |
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
|
399 | self.__connected = connected |
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
|
400 | |
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
|
401 | self.deviceConnectedLed.setOn(connected) |
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
|
402 | 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
|
403 | self.__fileManagerWidget.deviceConnectedLed.setOn(connected) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
404 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
405 | self.deviceTypeComboBox.setEnabled(not connected) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
406 | |
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
|
407 | if connected: |
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
|
408 | self.connectButton.setIcon( |
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
|
409 | UI.PixmapCache.getIcon("linkDisconnect")) |
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
|
410 | self.connectButton.setToolTip(self.tr( |
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
|
411 | "Press to disconnect the current device")) |
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
|
412 | else: |
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
|
413 | self.connectButton.setIcon( |
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
|
414 | UI.PixmapCache.getIcon("linkConnect")) |
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
|
415 | self.connectButton.setToolTip(self.tr( |
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
|
416 | "Press to connect the selected device")) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
417 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
418 | def isConnected(self): |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
419 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
420 | Public method to get the connection state. |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
421 | |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
422 | @return connection state |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
423 | @rtype bool |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
424 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
425 | return self.__connected |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
426 | |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
427 | def __showNoDeviceMessage(self): |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
428 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
429 | 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
|
430 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
431 | E5MessageBox.critical( |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
432 | self, |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
433 | self.tr("No device attached"), |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
434 | self.tr("""Please ensure the device is plugged into your""" |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
435 | """ computer and selected.\n\nIt must have a version""" |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
436 | """ of MicroPython (or CircuitPython) flashed onto""" |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
437 | """ it before anything will work.\n\nFinally press""" |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
438 | """ the device's reset button and wait a few seconds""" |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
439 | """ before trying again.""")) |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
440 | |
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
|
441 | @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
|
442 | def on_replButton_clicked(self, checked): |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
443 | """ |
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
|
444 | Private slot to connect to enable or disable the REPL widget. |
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
|
445 | |
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
|
446 | If the selected device is not connected yet, this will be done now. |
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
|
447 | |
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
|
448 | @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
|
449 | @type bool |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
450 | """ |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
451 | if not self.__device: |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
452 | self.__showNoDeviceMessage() |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
453 | return |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
454 | |
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
|
455 | if checked: |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
456 | ok, reason = self.__device.canStartRepl() |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
457 | if not ok: |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
458 | E5MessageBox.warning( |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
459 | self, |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
460 | self.tr("Start REPL"), |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
461 | self.tr("""<p>The REPL cannot be started.</p><p>Reason:""" |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
462 | """ {0}</p>""").format(reason)) |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
463 | return |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
464 | |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
465 | 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
|
466 | self.__interface.dataReceived.connect(self.__processData) |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
467 | |
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
|
468 | 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
|
469 | 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
|
470 | 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
|
471 | # send a Ctrl-B (exit raw mode) |
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
|
472 | self.__interface.write(b'\x02') |
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 | # send Ctrl-C (keyboard interrupt) |
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
|
474 | self.__interface.write(b'\x03') |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
475 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
476 | self.__device.setRepl(True) |
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
|
477 | self.replEdit.setFocus(Qt.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
|
478 | 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
|
479 | self.__interface.dataReceived.disconnect(self.__processData) |
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
|
480 | if (not self.chartButton.isChecked() and |
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
|
481 | 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
|
482 | 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
|
483 | 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
|
484 | self.replButton.setChecked(checked) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
485 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
486 | @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
|
487 | 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
|
488 | """ |
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
|
489 | 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
|
490 | currently connected device. |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
491 | """ |
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
|
492 | if self.__connected: |
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
|
493 | self.__disconnectFromDevice() |
7111
62191d1aeeed
MicroPythonReplWidget: made the connect button more intelligent.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
494 | |
7120
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
495 | if self.replButton.isChecked(): |
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
496 | self.on_replButton_clicked(False) |
7111
62191d1aeeed
MicroPythonReplWidget: made the connect button more intelligent.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
497 | if self.filesButton.isChecked(): |
62191d1aeeed
MicroPythonReplWidget: made the connect button more intelligent.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
498 | self.on_filesButton_clicked(False) |
62191d1aeeed
MicroPythonReplWidget: made the connect button more intelligent.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
499 | if self.chartButton.isChecked(): |
62191d1aeeed
MicroPythonReplWidget: made the connect button more intelligent.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
500 | 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
|
501 | else: |
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
|
502 | self.__connectToDevice() |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
503 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
504 | @pyqtSlot() |
7094
d5f340dfb986
MicroPythonReplWidget: added a context menu action to clear the REPL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7090
diff
changeset
|
505 | def __clear(self): |
d5f340dfb986
MicroPythonReplWidget: added a context menu action to clear the REPL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7090
diff
changeset
|
506 | """ |
d5f340dfb986
MicroPythonReplWidget: added a context menu action to clear the REPL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7090
diff
changeset
|
507 | 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
|
508 | """ |
d5f340dfb986
MicroPythonReplWidget: added a context menu action to clear the REPL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7090
diff
changeset
|
509 | 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
|
510 | self.__interface.isConnected() and self.__interface.write(b"\r") |
7094
d5f340dfb986
MicroPythonReplWidget: added a context menu action to clear the REPL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7090
diff
changeset
|
511 | |
d5f340dfb986
MicroPythonReplWidget: added a context menu action to clear the REPL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7090
diff
changeset
|
512 | @pyqtSlot() |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
513 | def __paste(self): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
514 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
515 | Private slot to perform a paste operation. |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
516 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
517 | 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
|
518 | if clipboard: |
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
|
519 | pasteText = clipboard.text() |
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
|
520 | if pasteText: |
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
|
521 | pasteText = pasteText.replace('\n\r', '\r') |
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
|
522 | 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
|
523 | self.__interface.isConnected() and self.__interface.write( |
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
|
524 | pasteText.encode("utf-8")) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
525 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
526 | def eventFilter(self, obj, evt): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
527 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
528 | Public method to process events for the REPL pane. |
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 | @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
|
531 | @type QObject |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
532 | @param evt reference to the event object |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
533 | @type QEvent |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
534 | @return flag to indicate that the event was handled |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
535 | @rtype bool |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
536 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
537 | if obj is self.replEdit and evt.type() == QEvent.KeyPress: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
538 | # handle the key press event on behalve of the REPL pane |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
539 | key = evt.key() |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
540 | msg = bytes(evt.text(), 'utf8') |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
541 | if key == Qt.Key_Backspace: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
542 | msg = b'\b' |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
543 | elif key == Qt.Key_Delete: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
544 | msg = b'\x1B[\x33\x7E' |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
545 | elif key == Qt.Key_Up: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
546 | msg = b'\x1B[A' |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
547 | elif key == Qt.Key_Down: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
548 | msg = b'\x1B[B' |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
549 | elif key == Qt.Key_Right: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
550 | msg = b'\x1B[C' |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
551 | elif key == Qt.Key_Left: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
552 | msg = b'\x1B[D' |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
553 | elif key == Qt.Key_Home: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
554 | msg = b'\x1B[H' |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
555 | elif key == Qt.Key_End: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
556 | msg = b'\x1B[F' |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
557 | elif ((Globals.isMacPlatform() and |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
558 | evt.modifiers() == Qt.MetaModifier) or |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
559 | (not Globals.isMacPlatform() and |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
560 | evt.modifiers() == Qt.ControlModifier)): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
561 | if Qt.Key_A <= key <= Qt.Key_Z: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
562 | # devices treat an input of \x01 as Ctrl+A, etc. |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
563 | msg = bytes([1 + key - Qt.Key_A]) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
564 | elif (evt.modifiers() == Qt.ControlModifier | Qt.ShiftModifier or |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
565 | (Globals.isMacPlatform() and |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
566 | evt.modifiers() == Qt.ControlModifier)): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
567 | if key == Qt.Key_C: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
568 | self.replEdit.copy() |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
569 | msg = b'' |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
570 | elif key == Qt.Key_V: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
571 | self.__paste() |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
572 | msg = b'' |
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
|
573 | elif key in (Qt.Key_Return, Qt.Key_Enter): |
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
|
574 | tc = self.replEdit.textCursor() |
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
|
575 | tc.movePosition(QTextCursor.EndOfLine) |
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
|
576 | 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
|
577 | self.__interface.isConnected() and self.__interface.write(msg) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
578 | return True |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
579 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
580 | else: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
581 | # standard event processing |
7134
21d23ca51680
Renamed "MicroPythonReplWidget" to "MicroPythonWidget".
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7133
diff
changeset
|
582 | return super(MicroPythonWidget, self).eventFilter(obj, evt) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
583 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
584 | def __processData(self, data): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
585 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
586 | Private slot to process bytes received from the device. |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
587 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
588 | @param data bytes received from the device |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
589 | @type bytes |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
590 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
591 | tc = self.replEdit.textCursor() |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
592 | # the text cursor must be on the last line |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
593 | while tc.movePosition(QTextCursor.Down): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
594 | pass |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
595 | |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
596 | # set the font |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
597 | charFormat = tc.charFormat() |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
598 | charFormat.setFontFamily(self.__font.family()) |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
599 | 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
|
600 | tc.setCharFormat(charFormat) |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
601 | |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
602 | index = 0 |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
603 | while index < len(data): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
604 | if data[index] == 8: # \b |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
605 | tc.movePosition(QTextCursor.Left) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
606 | self.replEdit.setTextCursor(tc) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
607 | elif data[index] == 13: # \r |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
608 | pass |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
609 | elif (len(data) > index + 1 and |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
610 | data[index] == 27 and |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
611 | data[index + 1] == 91): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
612 | # VT100 cursor command detected: <Esc>[ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
613 | index += 2 # move index to after the [ |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
614 | match = self.__vt100Re.search(data[index:].decode("utf-8")) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
615 | if match: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
616 | # move to last position in control sequence |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
617 | # ++ will be done at end of loop |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
618 | index += match.end() - 1 |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
619 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
620 | 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
|
621 | if action in "ABCD": |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
622 | if match.group("count") == "": |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
623 | count = 1 |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
624 | else: |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
625 | count = int(match.group("count")) |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
626 | |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
627 | if action == "A": # up |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
628 | tc.movePosition(QTextCursor.Up, n=count) |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
629 | self.replEdit.setTextCursor(tc) |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
630 | elif action == "B": # down |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
631 | tc.movePosition(QTextCursor.Down, n=count) |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
632 | self.replEdit.setTextCursor(tc) |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
633 | elif action == "C": # right |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
634 | tc.movePosition(QTextCursor.Right, n=count) |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
635 | self.replEdit.setTextCursor(tc) |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
636 | elif action == "D": # left |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
637 | tc.movePosition(QTextCursor.Left, n=count) |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
638 | self.replEdit.setTextCursor(tc) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
639 | 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
|
640 | 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
|
641 | # delete to end of line |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
642 | tc.movePosition(QTextCursor.EndOfLine, |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
643 | mode=QTextCursor.KeepAnchor) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
644 | tc.removeSelectedText() |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
645 | 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
|
646 | elif match.group("count") == "1": |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
647 | # delete to beinning of line |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
648 | tc.movePosition(QTextCursor.StartOfLine, |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
649 | mode=QTextCursor.KeepAnchor) |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
650 | tc.removeSelectedText() |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
651 | self.replEdit.setTextCursor(tc) |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
652 | 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
|
653 | # delete whole line |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
654 | tc.movePosition(QTextCursor.EndOfLine) |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
655 | tc.movePosition(QTextCursor.StartOfLine, |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
656 | mode=QTextCursor.KeepAnchor) |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
657 | tc.removeSelectedText() |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
658 | self.replEdit.setTextCursor(tc) |
7066
e3d034e65afc
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7065
diff
changeset
|
659 | elif action == "m": |
7067
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
660 | self.__setCharFormat(match.group(0)[:-1].split(";"), |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
661 | tc) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
662 | else: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
663 | tc.deleteChar() |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
664 | self.replEdit.setTextCursor(tc) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
665 | self.replEdit.insertPlainText(chr(data[index])) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
666 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
667 | index += 1 |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
668 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
669 | self.replEdit.ensureCursorVisible() |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
670 | |
7067
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
671 | def __setCharFormat(self, formatCodes, textCursor): |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
672 | """ |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
673 | 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
|
674 | on the passed ANSI codes. |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
675 | |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
676 | Following codes are used: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
677 | <ul> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
678 | <li>0: Reset</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
679 | <li>1: Bold font (weight 75)</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
680 | <li>2: Light font (weight 25)</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
681 | <li>3: Italic font</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
682 | <li>4: Underlined font</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
683 | <li>9: Strikeout font</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
684 | <li>21: Bold off (weight 50)</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
685 | <li>22: Light off (weight 50)</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
686 | <li>23: Italic off</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
687 | <li>24: Underline off</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
688 | <li>29: Strikeout off</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
689 | <li>30: foreground Black</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
690 | <li>31: foreground Dark Red</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
691 | <li>32: foreground Dark Green</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
692 | <li>33: foreground Dark Yellow</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
693 | <li>34: foreground Dark Blue</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
694 | <li>35: foreground Dark Magenta</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
695 | <li>36: foreground Dark Cyan</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
696 | <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
|
697 | <li>39: reset foreground to default</li> |
7067
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
698 | <li>40: background Black</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
699 | <li>41: background Dark Red</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
700 | <li>42: background Dark Green</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
701 | <li>43: background Dark Yellow</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
702 | <li>44: background Dark Blue</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
703 | <li>45: background Dark Magenta</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
704 | <li>46: background Dark Cyan</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
705 | <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
|
706 | <li>49: reset background to default</li> |
7067
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
707 | <li>53: Overlined font</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
708 | <li>55: Overline off</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
709 | <li>90: bright foreground Dark Gray</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
710 | <li>91: bright foreground Red</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
711 | <li>92: bright foreground Green</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
712 | <li>93: bright foreground Yellow</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
713 | <li>94: bright foreground Blue</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
714 | <li>95: bright foreground Magenta</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
715 | <li>96: bright foreground Cyan</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
716 | <li>97: bright foreground White</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
717 | <li>100: bright background Dark Gray</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
718 | <li>101: bright background Red</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
719 | <li>102: bright background Green</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
720 | <li>103: bright background Yellow</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
721 | <li>104: bright background Blue</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
722 | <li>105: bright background Magenta</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
723 | <li>106: bright background Cyan</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
724 | <li>107: bright background White</li> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
725 | </ul> |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
726 | |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
727 | @param formatCodes list of format codes |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
728 | @type list of str |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
729 | @param textCursor reference to the text cursor |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
730 | @type QTextCursor |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
731 | """ |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
732 | if not formatCodes: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
733 | # 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
|
734 | formatCodes = ["0"] |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
735 | |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
736 | charFormat = textCursor.charFormat() |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
737 | for formatCode in formatCodes: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
738 | try: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
739 | formatCode = int(formatCode) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
740 | except ValueError: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
741 | # ignore non digit values |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
742 | continue |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
743 | |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
744 | if formatCode == 0: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
745 | charFormat.setFontWeight(50) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
746 | charFormat.setFontItalic(False) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
747 | charFormat.setFontUnderline(False) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
748 | charFormat.setFontStrikeOut(False) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
749 | charFormat.setFontOverline(False) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
750 | charFormat.setForeground(self.DefaultForeground) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
751 | charFormat.setBackground(self.DefaultBackground) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
752 | elif formatCode == 1: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
753 | charFormat.setFontWeight(75) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
754 | elif formatCode == 2: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
755 | charFormat.setFontWeight(25) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
756 | elif formatCode == 3: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
757 | charFormat.setFontItalic(True) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
758 | elif formatCode == 4: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
759 | charFormat.setFontUnderline(True) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
760 | elif formatCode == 9: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
761 | charFormat.setFontStrikeOut(True) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
762 | elif formatCode in (21, 22): |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
763 | charFormat.setFontWeight(50) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
764 | elif formatCode == 23: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
765 | charFormat.setFontItalic(False) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
766 | elif formatCode == 24: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
767 | charFormat.setFontUnderline(False) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
768 | elif formatCode == 29: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
769 | charFormat.setFontStrikeOut(False) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
770 | elif formatCode == 53: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
771 | charFormat.setFontOverline(True) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
772 | elif formatCode == 55: |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
773 | charFormat.setFontOverline(False) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
774 | 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
|
775 | charFormat.setForeground( |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
776 | AnsiColorSchemes[self.__colorScheme][formatCode - 30]) |
7067
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
777 | 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
|
778 | charFormat.setBackground( |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
779 | AnsiColorSchemes[self.__colorScheme][formatCode - 40]) |
7067
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
780 | 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
|
781 | charFormat.setForeground( |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
782 | AnsiColorSchemes[self.__colorScheme][formatCode - 80]) |
7067
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
783 | 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
|
784 | charFormat.setBackground( |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
785 | AnsiColorSchemes[self.__colorScheme][formatCode - 90]) |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
786 | elif formatCode == 39: |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
787 | charFormat.setForeground(self.DefaultForeground) |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
788 | elif formatCode == 49: |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
789 | charFormat.setBackground(self.DefaultBackground) |
7067
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
790 | |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
791 | textCursor.setCharFormat(charFormat) |
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
792 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
793 | def __doZoom(self, value): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
794 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
795 | Private slot to zoom the REPL pane. |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
796 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
797 | @param value zoom value |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
798 | @type int |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
799 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
800 | if value < self.__currentZoom: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
801 | self.replEdit.zoomOut(self.__currentZoom - value) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
802 | elif value > self.__currentZoom: |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
803 | self.replEdit.zoomIn(value - self.__currentZoom) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
804 | self.__currentZoom = value |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
805 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
806 | def getCurrentPort(self): |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
807 | """ |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
808 | Public method to determine the port path of the selected device. |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
809 | |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
810 | @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
|
811 | @rtype str |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
812 | """ |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
813 | portName = self.deviceTypeComboBox.itemData( |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
814 | self.deviceTypeComboBox.currentIndex(), |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
815 | self.DevicePortRole) |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
816 | |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
817 | if Globals.isWindowsPlatform(): |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
818 | # return it unchanged |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
819 | return portName |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
820 | else: |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
821 | # return with device path prepended |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
822 | return "/dev/{0}".format(portName) |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
823 | |
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
|
824 | 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
|
825 | """ |
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
|
826 | Public method to get the 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
|
827 | |
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
|
828 | @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
|
829 | @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
|
830 | """ |
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
|
831 | 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
|
832 | 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
|
833 | 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
|
834 | return "" |
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
|
835 | |
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
|
836 | def __connectToDevice(self): |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
837 | """ |
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
|
838 | Private method to connect to the selected device. |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
839 | """ |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
840 | port = self.getCurrentPort() |
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
|
841 | if self.__interface.connectToDevice(port): |
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
|
842 | self.__setConnected(True) |
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
|
843 | |
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
|
844 | if Preferences.getMicroPython("SyncTimeAfterConnect"): |
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
|
845 | self.__synchronizeTime(quiet=True) |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
846 | else: |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
847 | E5MessageBox.warning( |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
848 | self, |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
849 | self.tr("Serial Device Connect"), |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
850 | self.tr("""<p>Cannot connect to device at serial port""" |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
851 | """ <b>{0}</b>.</p>""").format(port)) |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
852 | |
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
|
853 | def __disconnectFromDevice(self): |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
854 | """ |
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
|
855 | Private method to disconnect from the device. |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
856 | """ |
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
|
857 | 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
|
858 | self.__setConnected(False) |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
859 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
860 | @pyqtSlot() |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
861 | def on_runButton_clicked(self): |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
862 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
863 | 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
|
864 | selected device. |
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
|
865 | |
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
|
866 | 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
|
867 | an unconnected device to be connected. |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
868 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
869 | if not self.__device: |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
870 | self.__showNoDeviceMessage() |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
871 | return |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
872 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
873 | aw = e5App().getObject("ViewManager").activeWindow() |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
874 | if aw is None: |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
875 | E5MessageBox.critical( |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
876 | self, |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
877 | self.tr("Run Script"), |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
878 | self.tr("""There is no editor open. Abort...""")) |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
879 | return |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
880 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
881 | script = aw.text() |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
882 | if not script: |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
883 | E5MessageBox.critical( |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
884 | self, |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
885 | self.tr("Run Script"), |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
886 | self.tr("""The current editor does not contain a script.""" |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
887 | """ Abort...""")) |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
888 | return |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
889 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
890 | ok, reason = self.__device.canRunScript() |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
891 | if not ok: |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
892 | E5MessageBox.warning( |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
893 | self, |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
894 | self.tr("Run Script"), |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
895 | self.tr("""<p>Cannot run script.</p><p>Reason:""" |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
896 | """ {0}</p>""").format(reason)) |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
897 | return |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
898 | |
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
|
899 | 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
|
900 | # 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
|
901 | 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
|
902 | if self.replButton.isChecked(): |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
903 | self.__device.runScript(script) |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
904 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
905 | @pyqtSlot() |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
906 | def on_openButton_clicked(self): |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
907 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
908 | Private slot to open a file of the connected device. |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
909 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
910 | if not self.__device: |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
911 | self.__showNoDeviceMessage() |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
912 | return |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
913 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
914 | workspace = self.__device.getWorkspace() |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
915 | fileName = E5FileDialog.getOpenFileName( |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
916 | self, |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
917 | self.tr("Open Python File"), |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
918 | workspace, |
7090
f4427962a4da
MicroPythonRepl: fixed an issue caused by no editor being open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7087
diff
changeset
|
919 | self.tr("Python3 Files (*.py);;All Files (*)")) |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
920 | if fileName: |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
921 | e5App().getObject("ViewManager").openSourceFile(fileName) |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
922 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
923 | @pyqtSlot() |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
924 | def on_saveButton_clicked(self): |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
925 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
926 | Private slot to save the current editor to the connected device. |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
927 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
928 | if not self.__device: |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
929 | self.__showNoDeviceMessage() |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
930 | return |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
931 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
932 | workspace = self.__device.getWorkspace() |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
933 | aw = e5App().getObject("ViewManager").activeWindow() |
7090
f4427962a4da
MicroPythonRepl: fixed an issue caused by no editor being open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7087
diff
changeset
|
934 | if aw: |
f4427962a4da
MicroPythonRepl: fixed an issue caused by no editor being open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7087
diff
changeset
|
935 | aw.saveFileAs(workspace) |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
936 | |
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
|
937 | @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
|
938 | def on_chartButton_clicked(self, checked): |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
939 | """ |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
940 | 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
|
941 | connected device. |
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
|
942 | |
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
|
943 | If the selected device is not connected yet, this will be done now. |
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
|
944 | |
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
|
945 | @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
|
946 | @type bool |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
947 | """ |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
948 | if not HAS_QTCHART: |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
949 | # QtChart not available => fail silently |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
950 | return |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
951 | |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
952 | if not self.__device: |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
953 | self.__showNoDeviceMessage() |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
954 | return |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
955 | |
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
|
956 | if checked: |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
957 | ok, reason = self.__device.canStartPlotter() |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
958 | if not ok: |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
959 | E5MessageBox.warning( |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
960 | self, |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
961 | self.tr("Start Chart"), |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
962 | self.tr("""<p>The Chart cannot be started.</p><p>Reason:""" |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
963 | """ {0}</p>""").format(reason)) |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
964 | return |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
965 | |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
966 | self.__chartWidget = MicroPythonGraphWidget(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
|
967 | self.__interface.dataReceived.connect( |
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
|
968 | self.__chartWidget.processData) |
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
|
969 | self.__chartWidget.dataFlood.connect( |
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
|
970 | self.handleDataFlood) |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
971 | |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
972 | self.__ui.addSideWidget(self.__ui.BottomSide, self.__chartWidget, |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
973 | UI.PixmapCache.getIcon("chart"), |
7066
e3d034e65afc
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7065
diff
changeset
|
974 | self.tr("μPy Chart")) |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
975 | self.__ui.showSideWidget(self.__chartWidget) |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
976 | |
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
|
977 | 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
|
978 | 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
|
979 | 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
|
980 | # send a Ctrl-B (exit raw mode) |
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
|
981 | self.__interface.write(b'\x02') |
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
|
982 | # send Ctrl-C (keyboard interrupt) |
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
|
983 | self.__interface.write(b'\x03') |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
984 | |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
985 | 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
|
986 | 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
|
987 | if self.__chartWidget.isDirty(): |
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
|
988 | res = E5MessageBox.okToClearData( |
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
|
989 | 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
|
990 | 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
|
991 | self.tr("""The chart contains unsaved 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
|
992 | self.__chartWidget.saveData) |
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
|
993 | 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
|
994 | # 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
|
995 | return |
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
|
996 | |
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
|
997 | self.__interface.dataReceived.disconnect( |
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
|
998 | self.__chartWidget.processData) |
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
|
999 | self.__chartWidget.dataFlood.disconnect( |
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
|
1000 | self.handleDataFlood) |
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
|
1001 | |
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
|
1002 | if (not self.replButton.isChecked() and |
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
|
1003 | 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
|
1004 | 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
|
1005 | |
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
|
1006 | 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
|
1007 | self.__ui.removeSideWidget(self.__chartWidget) |
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
|
1008 | |
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
|
1009 | 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
|
1010 | self.__chartWidget = None |
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
|
1011 | |
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
|
1012 | self.chartButton.setChecked(checked) |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1013 | |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1014 | @pyqtSlot() |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1015 | def handleDataFlood(self): |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1016 | """ |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1017 | 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
|
1018 | """ |
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
|
1019 | self.on_connectButton_clicked() |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
1020 | self.__device.handleDataFlood() |
7077
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1021 | |
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
|
1022 | @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
|
1023 | 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
|
1024 | """ |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1025 | Private slot to open a file manager window to the connected device. |
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
|
1026 | |
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
|
1027 | If the selected device is not connected yet, this will be done now. |
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
|
1028 | |
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
|
1029 | @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
|
1030 | @type bool |
7077
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1031 | """ |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1032 | if not self.__device: |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1033 | self.__showNoDeviceMessage() |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1034 | return |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1035 | |
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
|
1036 | if checked: |
7077
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1037 | ok, reason = self.__device.canStartFileManager() |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1038 | if not ok: |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1039 | E5MessageBox.warning( |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1040 | self, |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1041 | self.tr("Start File Manager"), |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1042 | self.tr("""<p>The File Manager cannot be started.</p>""" |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1043 | """<p>Reason: {0}</p>""").format(reason)) |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1044 | return |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1045 | |
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
|
1046 | 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
|
1047 | 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
|
1048 | self.__fileManagerWidget = MicroPythonFileManagerWidget( |
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
|
1049 | self.__interface, self.__device.supportsLocalFileAccess(), |
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
|
1050 | self) |
7077
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1051 | |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1052 | self.__ui.addSideWidget(self.__ui.BottomSide, |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1053 | self.__fileManagerWidget, |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1054 | UI.PixmapCache.getIcon("filemanager"), |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1055 | self.tr("μPy Files")) |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1056 | self.__ui.showSideWidget(self.__fileManagerWidget) |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1057 | |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1058 | self.__device.setFileManager(True) |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1059 | |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
1060 | 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
|
1061 | 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
|
1062 | self.__fileManagerWidget.stop() |
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
|
1063 | |
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
|
1064 | if (not self.replButton.isChecked() and |
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
|
1065 | not self.chartButton.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
|
1066 | self.__disconnectFromDevice() |
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
|
1067 | |
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
|
1068 | 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
|
1069 | self.__ui.removeSideWidget(self.__fileManagerWidget) |
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
|
1070 | |
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
|
1071 | self.__fileManagerWidget.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
|
1072 | self.__fileManagerWidget = None |
7127
aa6fc2d252ad
MicroPythonReplWidget: fixed an issue resetting the files button on disconnect.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
1073 | |
aa6fc2d252ad
MicroPythonReplWidget: fixed an issue resetting the files button on disconnect.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
1074 | self.filesButton.setChecked(checked) |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1075 | |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1076 | ################################################################## |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1077 | ## 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
|
1078 | ################################################################## |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1079 | |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1080 | def __aboutToShowSuperMenu(self): |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1081 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1082 | 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
|
1083 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1084 | self.__superMenu.clear() |
7123
94948e2aa0a5
Implemented the support for the 'BBC micro:bit' device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7120
diff
changeset
|
1085 | if self.__device: |
94948e2aa0a5
Implemented the support for the 'BBC micro:bit' device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7120
diff
changeset
|
1086 | hasTime = self.__device.hasTimeCommands() |
94948e2aa0a5
Implemented the support for the 'BBC micro:bit' device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7120
diff
changeset
|
1087 | else: |
94948e2aa0a5
Implemented the support for the 'BBC micro:bit' device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7120
diff
changeset
|
1088 | hasTime = False |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1089 | |
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
|
1090 | # TODO: add menu entry to cross-compile a .py file (using mpy-cross) |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1091 | act = self.__superMenu.addAction( |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1092 | self.tr("Show Version"), self.__showDeviceVersion) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1093 | act.setEnabled(self.__connected) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1094 | act = self.__superMenu.addAction( |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1095 | self.tr("Show Implementation"), self.__showImplementation) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1096 | act.setEnabled(self.__connected) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1097 | self.__superMenu.addSeparator() |
7123
94948e2aa0a5
Implemented the support for the 'BBC micro:bit' device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7120
diff
changeset
|
1098 | if hasTime: |
94948e2aa0a5
Implemented the support for the 'BBC micro:bit' device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7120
diff
changeset
|
1099 | act = self.__superMenu.addAction( |
94948e2aa0a5
Implemented the support for the 'BBC micro:bit' device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7120
diff
changeset
|
1100 | self.tr("Synchronize Time"), self.__synchronizeTime) |
94948e2aa0a5
Implemented the support for the 'BBC micro:bit' device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7120
diff
changeset
|
1101 | act.setEnabled(self.__connected) |
94948e2aa0a5
Implemented the support for the 'BBC micro:bit' device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7120
diff
changeset
|
1102 | act = self.__superMenu.addAction( |
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
|
1103 | self.tr("Show Device Time"), self.__showDeviceTime) |
7123
94948e2aa0a5
Implemented the support for the 'BBC micro:bit' device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7120
diff
changeset
|
1104 | act.setEnabled(self.__connected) |
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
|
1105 | self.__superMenu.addAction( |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1106 | self.tr("Show Local Time"), self.__showLocalTime) |
7123
94948e2aa0a5
Implemented the support for the 'BBC micro:bit' device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7120
diff
changeset
|
1107 | 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
|
1108 | if self.__device: |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1109 | self.__device.addDeviceMenuEntries(self.__superMenu) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1110 | |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1111 | @pyqtSlot() |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1112 | def __showDeviceVersion(self): |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1113 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1114 | 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
|
1115 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1116 | try: |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1117 | versionInfo = self.__interface.version() |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1118 | if versionInfo: |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1119 | msg = self.tr( |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1120 | "<h3>Device Version Information</h3>" |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1121 | ) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1122 | msg += "<table>" |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1123 | for key, value in versionInfo.items(): |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1124 | msg += "<tr><td><b>{0}</b></td><td>{1}</td></tr>".format( |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1125 | key.capitalize(), value) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1126 | msg += "</table>" |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1127 | else: |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1128 | msg = self.tr("No version information available.") |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1129 | |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1130 | E5MessageBox.information( |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1131 | self, |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1132 | self.tr("Device Version Information"), |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1133 | msg) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1134 | except Exception as exc: |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1135 | self.__showError("version()", str(exc)) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1136 | |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1137 | @pyqtSlot() |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1138 | def __showImplementation(self): |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1139 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1140 | 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
|
1141 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1142 | try: |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1143 | impInfo = self.__interface.getImplementation() |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1144 | if impInfo["name"] == "micropython": |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1145 | name = "MicroPython" |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1146 | elif impInfo["name"] == "circuitpython": |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1147 | name = "CircuitPython" |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1148 | elif impInfo["name"] == "unknown": |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1149 | 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
|
1150 | else: |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1151 | name = impInfo["name"] |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1152 | if impInfo["version"] == "unknown": |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1153 | version = self.tr("unknown") |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1154 | else: |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1155 | version = impInfo["version"] |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1156 | |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1157 | E5MessageBox.information( |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1158 | self, |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1159 | 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
|
1160 | self.tr( |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1161 | "<h3>Device Implementation Information</h3>" |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1162 | "<p>This device contains <b>{0} {1}</b>.</p>" |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1163 | ).format(name, version) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1164 | ) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1165 | except Exception as exc: |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1166 | self.__showError("getImplementation()", str(exc)) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1167 | |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1168 | @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
|
1169 | 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
|
1170 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1171 | 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
|
1172 | computer's time. |
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
|
1173 | |
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
|
1174 | @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
|
1175 | @type bool |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1176 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1177 | try: |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1178 | self.__interface.syncTime() |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1179 | |
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
|
1180 | if not quiet: |
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
|
1181 | E5MessageBox.information( |
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
|
1182 | 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
|
1183 | self.tr("Synchronize Time"), |
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
|
1184 | self.tr("<p>The time of the connected device was" |
7139
9bb36ec2d1b5
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7135
diff
changeset
|
1185 | " synchronized with the local time.</p>") + |
9bb36ec2d1b5
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7135
diff
changeset
|
1186 | self.__getDeviceTime() |
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
|
1187 | ) |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1188 | except Exception as exc: |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1189 | self.__showError("syncTime()", str(exc)) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1190 | |
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
|
1191 | 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
|
1192 | """ |
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
|
1193 | 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
|
1194 | 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
|
1195 | |
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
|
1196 | @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
|
1197 | @rtype str |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1198 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1199 | try: |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1200 | dateTimeString = self.__interface.getTime() |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1201 | try: |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1202 | date, time = dateTimeString.strip().split(None, 1) |
7139
9bb36ec2d1b5
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7135
diff
changeset
|
1203 | return self.tr( |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1204 | "<h3>Device Date and Time</h3>" |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1205 | "<table>" |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1206 | "<tr><td><b>Date</b></td><td>{0}</td></tr>" |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1207 | "<tr><td><b>Time</b></td><td>{1}</td></tr>" |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1208 | "</table>" |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1209 | ).format(date, time) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1210 | except ValueError: |
7139
9bb36ec2d1b5
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7135
diff
changeset
|
1211 | return self.tr( |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1212 | "<h3>Device Date and Time</h3>" |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1213 | "<p>{0}</p>" |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1214 | ).format(dateTimeString.strip()) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1215 | except Exception as exc: |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1216 | self.__showError("getTime()", str(exc)) |
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
|
1217 | return "" |
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
|
1218 | |
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
|
1219 | @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
|
1220 | 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
|
1221 | """ |
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
|
1222 | 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
|
1223 | """ |
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
|
1224 | msg = self.__getDeviceTime() |
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
|
1225 | E5MessageBox.information( |
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
|
1226 | 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
|
1227 | self.tr("Device Date and Time"), |
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
|
1228 | msg) |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1229 | |
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
|
1230 | @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
|
1231 | 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
|
1232 | """ |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1233 | 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
|
1234 | """ |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1235 | localdatetime = time.localtime() |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1236 | loacldate = time.strftime('%Y-%m-%d', localdatetime) |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1237 | localtime = time.strftime('%H:%M:%S', localdatetime) |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1238 | E5MessageBox.information( |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1239 | 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
|
1240 | self.tr("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
|
1241 | self.tr("<h3>Local Date and Time</h3>" |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1242 | "<table>" |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1243 | "<tr><td><b>Date</b></td><td>{0}</td></tr>" |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1244 | "<tr><td><b>Time</b></td><td>{1}</td></tr>" |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1245 | "</table>" |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1246 | ).format(loacldate, localtime) |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1247 | ) |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1248 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1249 | def __showError(self, method, error): |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1250 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1251 | Private method to show some error message. |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1252 | |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1253 | @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
|
1254 | @type str |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1255 | @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
|
1256 | @type str |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1257 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1258 | E5MessageBox.warning( |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1259 | self, |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1260 | self.tr("Error handling device"), |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1261 | self.tr("<p>There was an error communicating with the connected" |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1262 | " device.</p><p>Method: {0}</p><p>Message: {1}</p>") |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1263 | .format(method, error)) |