diff -r e9e7eca7efee -r bf71ee032bb4 src/eric7/MicroPython/AddEditDevicesDialog.py --- a/src/eric7/MicroPython/AddEditDevicesDialog.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/MicroPython/AddEditDevicesDialog.py Wed Jul 13 14:55:47 2022 +0200 @@ -24,14 +24,14 @@ Class implementing a dialog to add or edit data of unknown MicroPython devices. """ - def __init__(self, vid=0, pid=0, description=0, deviceData=None, - parent=None): + + def __init__(self, vid=0, pid=0, description=0, deviceData=None, parent=None): """ Constructor - + Note: Either vid and pid and description or deviceData dictionary must be given. - + @param vid vendor ID of the device (defaults to 0) @type int (optional) @param pid product ID of the device (defaults to 0) @@ -45,18 +45,19 @@ """ super().__init__(parent) self.setupUi(self) - + # populate the device type combo box self.deviceTypeComboBox.addItem("", "") for board, desc in sorted(getSupportedDevices(), key=lambda x: x[1]): self.deviceTypeComboBox.addItem(desc, board) - + if deviceData is not None: self.vidEdit.setText("0x{0:04x}".format(deviceData["vid"])) self.pidEdit.setText("0x{0:04x}".format(deviceData["pid"])) self.descriptionEdit.setText(deviceData["description"]) self.deviceTypeComboBox.setCurrentIndex( - self.deviceTypeComboBox.findData(deviceData["type"])) + self.deviceTypeComboBox.findData(deviceData["type"]) + ) self.dataVolumeEdit.setText(deviceData["data_volume"]) self.flashVolumeEdit.setText(deviceData["flash_volume"]) else: @@ -66,54 +67,57 @@ self.deviceTypeComboBox.setCurrentText("") self.dataVolumeEdit.setText("") self.flashVolumeEdit.setText("") - + self.deviceTypeComboBox.setFocus(Qt.FocusReason.OtherFocusReason) - + msh = self.minimumSizeHint() self.resize(max(self.width(), msh.width()), msh.height()) - + @pyqtSlot(int) def on_deviceTypeComboBox_currentIndexChanged(self, index): """ Private slot to handle the selection of a device type. - + @param index index of the current item @type int """ board = self.deviceTypeComboBox.currentData() - self.buttonBox.button( - QDialogButtonBox.StandardButton.Ok).setEnabled(bool(board)) + self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( + bool(board) + ) self.reportButton.setEnabled(bool(board)) - + @pyqtSlot() def on_reportButton_clicked(self): """ Private slot to report the entered data to the eric-bugs email address. """ - body = "\r\n".join([ - "This is an unknown MicroPython device. Please add it.", - "", - "VID: {0}".format(self.vidEdit.text()), - "PID: {0}".format(self.pidEdit.text()), - "Description: {0}".format(self.descriptionEdit.text()), - "Device Type: {0}".format(self.deviceTypeComboBox.currentData()), - "Data Volume: {0}".format(self.dataVolumeEdit.text().strip()), - "Flash Volume: {0}".format(self.flashVolumeEdit.text().strip()), - ]) - + body = "\r\n".join( + [ + "This is an unknown MicroPython device. Please add it.", + "", + "VID: {0}".format(self.vidEdit.text()), + "PID: {0}".format(self.pidEdit.text()), + "Description: {0}".format(self.descriptionEdit.text()), + "Device Type: {0}".format(self.deviceTypeComboBox.currentData()), + "Data Volume: {0}".format(self.dataVolumeEdit.text().strip()), + "Flash Volume: {0}".format(self.flashVolumeEdit.text().strip()), + ] + ) + urlQuery = QUrlQuery() urlQuery.addQueryItem("subject", "Unsupported MicroPython Device") urlQuery.addQueryItem("body", body) - + url = QUrl("mailto:{0}".format(BugAddress)) url.setQuery(urlQuery) - + QDesktopServices.openUrl(url) - + def getDeviceDict(self): """ Public method to get the entered data as a dictionary. - + @return dictionary containing the entered data @rtype dict """