eric6/MicroPython/MicroPythonWidget.py

Tue, 13 Apr 2021 18:02:59 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 13 Apr 2021 18:02:59 +0200
changeset 8234
fcb6b4b96274
parent 8218
7c09585bd960
child 8259
2bbec88047dd
permissions
-rw-r--r--

Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator) (batch 2).

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

eric ide

mercurial