eric6/MicroPython/MicrobitDevices.py

branch
micropython
changeset 7100
c4d9c28ebcd8
parent 7082
ec199ef0cfc6
child 7114
f416440c8be1
equal deleted inserted replaced
7099:89f11ae6bec3 7100:c4d9c28ebcd8
27 @type MicroPythonReplWidget 27 @type MicroPythonReplWidget
28 @param parent reference to the parent object 28 @param parent reference to the parent object
29 @type QObject 29 @type QObject
30 """ 30 """
31 super(MicrobitDevice, self).__init__(microPythonWidget, parent) 31 super(MicrobitDevice, self).__init__(microPythonWidget, parent)
32
33 self.__replActive = False
34 self.__fileManagerActive = False
35 self.__plotterActive = False
36 32
37 def setButtons(self): 33 def setButtons(self):
38 """ 34 """
39 Public method to enable the supported action buttons. 35 Public method to enable the supported action buttons.
40 """ 36 """
58 54
59 @return tuple containing a flag indicating it is safe to start a REPL 55 @return tuple containing a flag indicating it is safe to start a REPL
60 and a reason why it cannot. 56 and a reason why it cannot.
61 @rtype tuple of (bool, str) 57 @rtype tuple of (bool, str)
62 """ 58 """
63 if self.__fileManagerActive: 59 return True, ""
64 return False, self.tr("The REPL and the file manager use the same"
65 " USB serial connection. Only one can be"
66 " active at any time. Toggle the file"
67 " manager off and try again.")
68 else:
69 return True, ""
70
71 def setRepl(self, on):
72 """
73 Public method to set the REPL status and dependent status.
74
75 @param on flag indicating the active status
76 @type bool
77 """
78 self.__replActive = on
79 self.microPython.setActionButtons(files=not on)
80 60
81 def canStartPlotter(self): 61 def canStartPlotter(self):
82 """ 62 """
83 Public method to determine, if a Plotter can be started. 63 Public method to determine, if a Plotter can be started.
84 64
85 @return tuple containing a flag indicating it is safe to start a 65 @return tuple containing a flag indicating it is safe to start a
86 Plotter and a reason why it cannot. 66 Plotter and a reason why it cannot.
87 @rtype tuple of (bool, str) 67 @rtype tuple of (bool, str)
88 """ 68 """
89 if self.__fileManagerActive: 69 return True, ""
90 return False, self.tr("The Plotter and the file manager use the"
91 " same USB serial connection. Only one can"
92 " be active at any time. Toggle the file"
93 " manager off and try again.")
94 else:
95 return True, ""
96
97 def setPlotter(self, on):
98 """
99 Public method to set the Plotter status and dependent status.
100
101 @param on flag indicating the active status
102 @type bool
103 """
104 self.__plotterActive = on
105 self.microPython.setActionButtons(files=not on)
106 70
107 def canStartFileManager(self): 71 def canStartFileManager(self):
108 """ 72 """
109 Public method to determine, if a File Manager can be started. 73 Public method to determine, if a File Manager can be started.
110 74
111 @return tuple containing a flag indicating it is safe to start a 75 @return tuple containing a flag indicating it is safe to start a
112 File Manager and a reason why it cannot. 76 File Manager and a reason why it cannot.
113 @rtype tuple of (bool, str) 77 @rtype tuple of (bool, str)
114 """ 78 """
115 if self.__replActive or self.__plotterActive: 79 return True, ""
116 return False, self.tr("The file manager and the REPL/plotter use"
117 " the same USB serial connection. Only one"
118 " can be active at any time. Disconnect the"
119 " REPL/plotter and try again.")
120 else:
121 return True, ""
122
123 def setFileManager(self, on):
124 """
125 Public method to set the File Manager status and dependent status.
126
127 @param on flag indicating the active status
128 @type bool
129 """
130 self.__fileManagerActive = on
131 self.microPython.setActionButtons(
132 run=not on, repl=not on, chart=HAS_QTCHART and not on)
133 80
134 @pyqtSlot() 81 @pyqtSlot()
135 def handleDataFlood(self): 82 def handleDataFlood(self):
136 """ 83 """
137 Public slot handling a data floof from the device. 84 Public slot handling a data floof from the device.

eric ide

mercurial