src/eric7/MicroPython/ConnectionSelectionDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9473
3f23dbf37dbe
--- a/src/eric7/MicroPython/ConnectionSelectionDialog.py	Wed Jul 13 11:16:20 2022 +0200
+++ b/src/eric7/MicroPython/ConnectionSelectionDialog.py	Wed Jul 13 14:55:47 2022 +0200
@@ -21,13 +21,14 @@
     Class implementing a dialog to select the port to connect to and the type
     of the attached device.
     """
+
     PortNameRole = Qt.ItemDataRole.UserRole
     VidPidRole = Qt.ItemDataRole.UserRole + 1
-    
+
     def __init__(self, ports, currentPort, currentType, parent=None):
         """
         Constructor
-        
+
         @param ports list of detected ports
         @type list of str
         @param currentPort port most recently selected
@@ -39,75 +40,73 @@
         """
         super().__init__(parent)
         self.setupUi(self)
-        
+
         for index, (vid, pid, description, portName) in enumerate(
             sorted(ports, key=lambda x: x[3])
         ):
             self.portNameComboBox.addItem(
-                self.tr("{0} - {1}", "description - port name")
-                .format(description, portName))
-            self.portNameComboBox.setItemData(
-                index, portName, self.PortNameRole)
-            self.portNameComboBox.setItemData(
-                index, (vid, pid), self.VidPidRole)
-        
+                self.tr("{0} - {1}", "description - port name").format(
+                    description, portName
+                )
+            )
+            self.portNameComboBox.setItemData(index, portName, self.PortNameRole)
+            self.portNameComboBox.setItemData(index, (vid, pid), self.VidPidRole)
+
         self.deviceTypeComboBox.addItem("", "")
         for board, description in sorted(
-            MicroPythonDevices.getSupportedDevices(),
-            key=lambda x: x[1]
+            MicroPythonDevices.getSupportedDevices(), key=lambda x: x[1]
         ):
             self.deviceTypeComboBox.addItem(description, board)
-        
+
         if self.portNameComboBox.currentText():
             # some ports were found; use the previously selected type as
             # default
-            portIndex = self.portNameComboBox.findData(
-                currentPort, self.PortNameRole)
+            portIndex = self.portNameComboBox.findData(currentPort, self.PortNameRole)
             typeIndex = self.deviceTypeComboBox.findData(currentType)
         else:
             portIndex = 0
             typeIndex = 0
         self.portNameComboBox.setCurrentIndex(portIndex)
         self.deviceTypeComboBox.setCurrentIndex(typeIndex)
-        
+
         self.__updateOK()
-        
+
         msh = self.minimumSizeHint()
         self.resize(max(self.width(), msh.width()), msh.height())
-    
+
     def __updateOK(self):
         """
         Private method to update the status of the OK button.
         """
         self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(
-            bool(self.portNameComboBox.currentData(self.PortNameRole)) and
-            bool(self.deviceTypeComboBox.currentData())
+            bool(self.portNameComboBox.currentData(self.PortNameRole))
+            and bool(self.deviceTypeComboBox.currentData())
         )
-    
+
     @pyqtSlot(str)
     def on_portNameComboBox_currentTextChanged(self, txt):
         """
         Private slot to handle the selection of a port name.
-        
+
         @param txt selected port
         @type str
         """
         self.__updateOK()
-    
+
     @pyqtSlot(str)
     def on_deviceTypeComboBox_currentTextChanged(self, txt):
         """
         Private slot to handle the selection of a device type.
-        
+
         @param txt selected device description
         @type str
         """
         self.__updateOK()
-    
+
     def getData(self):
         """
         Public method to get the entered data.
-        
+
         @return tuple containing the VID, PID and name of the selected port
             and the selected device type
         @rtype tuple of (int, int, str, str)

eric ide

mercurial