235 self.menuButton.setShowMenuInside(True) |
235 self.menuButton.setShowMenuInside(True) |
236 self.menuButton.setMenu(self.__superMenu) |
236 self.menuButton.setMenu(self.__superMenu) |
237 |
237 |
238 self.deviceIconLabel.setPixmap(Devices.getDeviceIcon("", False)) |
238 self.deviceIconLabel.setPixmap(Devices.getDeviceIcon("", False)) |
239 |
239 |
240 self.openButton.setIcon(EricPixmapCache.getIcon("open")) |
|
241 self.saveButton.setIcon(EricPixmapCache.getIcon("fileSaveAs")) |
|
242 |
|
243 self.checkButton.setIcon(EricPixmapCache.getIcon("question")) |
240 self.checkButton.setIcon(EricPixmapCache.getIcon("question")) |
244 self.runButton.setIcon(EricPixmapCache.getIcon("start")) |
241 self.runButton.setIcon(EricPixmapCache.getIcon("start")) |
245 self.replButton.setIcon(EricPixmapCache.getIcon("terminal")) |
242 self.replButton.setIcon(EricPixmapCache.getIcon("terminal")) |
246 self.filesButton.setIcon(EricPixmapCache.getIcon("filemanager")) |
243 self.filesButton.setIcon(EricPixmapCache.getIcon("filemanager")) |
247 self.chartButton.setIcon(EricPixmapCache.getIcon("chart")) |
244 self.chartButton.setIcon(EricPixmapCache.getIcon("chart")) |
533 |
530 |
534 @keyparam kwargs keyword arguments containg the enabled states (keys |
531 @keyparam kwargs keyword arguments containg the enabled states (keys |
535 are 'run', 'repl', 'files', 'chart', 'open', 'save' |
532 are 'run', 'repl', 'files', 'chart', 'open', 'save' |
536 @type dict |
533 @type dict |
537 """ |
534 """ |
538 if "open" in kwargs: |
|
539 self.openButton.setEnabled(kwargs["open"] and self.__connected) |
|
540 if "save" in kwargs: |
|
541 self.saveButton.setEnabled(kwargs["save"] and self.__connected) |
|
542 if "run" in kwargs: |
535 if "run" in kwargs: |
543 self.runButton.setEnabled(kwargs["run"] and self.__connected) |
536 self.runButton.setEnabled(kwargs["run"] and self.__connected) |
544 if "repl" in kwargs: |
537 if "repl" in kwargs: |
545 self.replButton.setEnabled(kwargs["repl"] and self.__linkConnected) |
538 self.replButton.setEnabled(kwargs["repl"] and self.__linkConnected) |
546 if "files" in kwargs: |
539 if "files" in kwargs: |
719 self.on_filesButton_clicked(False) |
712 self.on_filesButton_clicked(False) |
720 if self.chartButton.isChecked(): |
713 if self.chartButton.isChecked(): |
721 self.on_chartButton_clicked(False) |
714 self.on_chartButton_clicked(False) |
722 else: |
715 else: |
723 with EricOverrideCursor(): |
716 with EricOverrideCursor(): |
724 self.__connectToDevice() |
717 self.__connectToDevice(withAutostart=True) |
725 |
718 |
726 @pyqtSlot() |
719 @pyqtSlot() |
727 def __clear(self): |
720 def __clear(self): |
728 """ |
721 """ |
729 Private slot to clear the REPL pane. |
722 Private slot to clear the REPL pane. |
1128 if self.__device: |
1121 if self.__device: |
1129 return self.__device.getWorkspace() |
1122 return self.__device.getWorkspace() |
1130 else: |
1123 else: |
1131 return "" |
1124 return "" |
1132 |
1125 |
1133 def __connectToDevice(self): |
1126 def __connectToDevice(self, withAutostart=False): |
1134 """ |
1127 """ |
1135 Private method to connect to the selected device. |
1128 Private method to connect to the selected device. |
|
1129 |
|
1130 @param withAutostart flag indicating to start the repl and file manager |
|
1131 automatically |
|
1132 @type bool |
1136 """ |
1133 """ |
1137 from .ConnectionSelectionDialog import ConnectionSelectionDialog |
1134 from .ConnectionSelectionDialog import ConnectionSelectionDialog |
1138 |
1135 |
1139 port = self.getCurrentPort() |
1136 port = self.getCurrentPort() |
1140 if not port: |
1137 if not port: |
1188 """ port <b>{0}</b>.</p>""" |
1185 """ port <b>{0}</b>.</p>""" |
1189 ).format(port), |
1186 ).format(port), |
1190 ) |
1187 ) |
1191 |
1188 |
1192 self.__device.setButtons() |
1189 self.__device.setButtons() |
|
1190 if withAutostart: |
|
1191 self.on_replButton_clicked( |
|
1192 self.replButton.isEnabled() and self.__linkConnected |
|
1193 ) |
|
1194 self.on_filesButton_clicked( |
|
1195 self.filesButton.isEnabled() and self.__connected |
|
1196 ) |
1193 |
1197 |
1194 def __disconnectFromDevice(self): |
1198 def __disconnectFromDevice(self): |
1195 """ |
1199 """ |
1196 Private method to disconnect from the device. |
1200 Private method to disconnect from the device. |
1197 """ |
1201 """ |
1244 if not self.replButton.isChecked(): |
1248 if not self.replButton.isChecked(): |
1245 # activate on the REPL |
1249 # activate on the REPL |
1246 self.on_replButton_clicked(True) |
1250 self.on_replButton_clicked(True) |
1247 if self.replButton.isChecked(): |
1251 if self.replButton.isChecked(): |
1248 self.__device.runScript(script) |
1252 self.__device.runScript(script) |
1249 |
|
1250 @pyqtSlot() |
|
1251 def on_openButton_clicked(self): |
|
1252 """ |
|
1253 Private slot to open a file of the connected device. |
|
1254 """ |
|
1255 if not self.__device: |
|
1256 self.__showNoDeviceMessage() |
|
1257 return |
|
1258 |
|
1259 workspace = self.getDeviceWorkspace() |
|
1260 if workspace: |
|
1261 fileName = EricFileDialog.getOpenFileName( |
|
1262 self, |
|
1263 self.tr("Open Python File"), |
|
1264 workspace, |
|
1265 self.tr("Python3 Files (*.py);;All Files (*)"), |
|
1266 ) |
|
1267 if fileName: |
|
1268 ericApp().getObject("ViewManager").openSourceFile(fileName) |
|
1269 |
|
1270 @pyqtSlot() |
|
1271 def on_saveButton_clicked(self): |
|
1272 """ |
|
1273 Private slot to save the current editor to the connected device. |
|
1274 """ |
|
1275 if not self.__device: |
|
1276 self.__showNoDeviceMessage() |
|
1277 return |
|
1278 |
|
1279 aw = ericApp().getObject("ViewManager").activeWindow() |
|
1280 if aw: |
|
1281 workspace = self.getDeviceWorkspace() |
|
1282 if workspace: |
|
1283 aw.saveFileAs(workspace) |
|
1284 |
1253 |
1285 @pyqtSlot(bool) |
1254 @pyqtSlot(bool) |
1286 def on_chartButton_clicked(self, checked): |
1255 def on_chartButton_clicked(self, checked): |
1287 """ |
1256 """ |
1288 Private slot to open a chart view to plot data received from the |
1257 Private slot to open a chart view to plot data received from the |