src/eric7/Preferences/ConfigurationPages/MicroPythonPage.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
--- a/src/eric7/Preferences/ConfigurationPages/MicroPythonPage.py	Wed Jul 13 11:16:20 2022 +0200
+++ b/src/eric7/Preferences/ConfigurationPages/MicroPythonPage.py	Wed Jul 13 14:55:47 2022 +0200
@@ -22,218 +22,221 @@
     """
     Class implementing the MicroPython configuration page.
     """
+
     def __init__(self, parent=None):
         """
         Constructor
-        
+
         @param parent reference to the parent widget
         @type QWidget
         """
         super().__init__()
         self.setupUi(self)
         self.setObjectName("MicroPythonPage")
-        
+
         self.workspacePicker.setMode(EricPathPickerModes.DIRECTORY_MODE)
-        
+
         self.colorSchemeComboBox.addItems(sorted(AnsiColorSchemes.keys()))
-        
+
         # populate the chart theme combobox
         try:
             from PyQt6.QtCharts import QChart
-            
+
+            self.chartThemeComboBox.addItem(self.tr("Automatic"), -1)
             self.chartThemeComboBox.addItem(
-                self.tr("Automatic"), -1)
+                self.tr("Light"), QChart.ChartTheme.ChartThemeLight
+            )
             self.chartThemeComboBox.addItem(
-                self.tr("Light"),
-                QChart.ChartTheme.ChartThemeLight)
+                self.tr("Dark"), QChart.ChartTheme.ChartThemeDark
+            )
             self.chartThemeComboBox.addItem(
-                self.tr("Dark"),
-                QChart.ChartTheme.ChartThemeDark)
-            self.chartThemeComboBox.addItem(
-                self.tr("Blue Cerulean"),
-                QChart.ChartTheme.ChartThemeBlueCerulean)
+                self.tr("Blue Cerulean"), QChart.ChartTheme.ChartThemeBlueCerulean
+            )
             self.chartThemeComboBox.addItem(
-                self.tr("Brown Sand"),
-                QChart.ChartTheme.ChartThemeBrownSand)
+                self.tr("Brown Sand"), QChart.ChartTheme.ChartThemeBrownSand
+            )
             self.chartThemeComboBox.addItem(
-                self.tr("Blue NCS"),
-                QChart.ChartTheme.ChartThemeBlueNcs)
+                self.tr("Blue NCS"), QChart.ChartTheme.ChartThemeBlueNcs
+            )
             self.chartThemeComboBox.addItem(
-                self.tr("High Contrast"),
-                QChart.ChartTheme.ChartThemeHighContrast)
+                self.tr("High Contrast"), QChart.ChartTheme.ChartThemeHighContrast
+            )
             self.chartThemeComboBox.addItem(
-                self.tr("Blue Icy"),
-                QChart.ChartTheme.ChartThemeBlueIcy)
+                self.tr("Blue Icy"), QChart.ChartTheme.ChartThemeBlueIcy
+            )
             self.chartThemeComboBox.addItem(
-                self.tr("Qt"),
-                QChart.ChartTheme.ChartThemeQt)
+                self.tr("Qt"), QChart.ChartTheme.ChartThemeQt
+            )
         except ImportError:
             self.chartThemeComboBox.setEnabled(False)
-        
+
         self.mpyCrossPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE)
         self.mpyCrossPicker.setFilters(self.tr("All Files (*)"))
-        
+
         self.dfuUtilPathPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE)
         self.dfuUtilPathPicker.setFilters(self.tr("All Files (*)"))
-        
+
         # set initial values
         # workspace
         self.workspacePicker.setText(
             Utilities.toNativeSeparators(
-                Preferences.getMicroPython("MpyWorkspace") or
-                Utilities.getHomeDir()))
-        
+                Preferences.getMicroPython("MpyWorkspace") or Utilities.getHomeDir()
+            )
+        )
+
         # serial link parameters
         self.timeoutSpinBox.setValue(
-            Preferences.getMicroPython("SerialTimeout") // 1000)
+            Preferences.getMicroPython("SerialTimeout") // 1000
+        )
         # converted to seconds
         self.syncTimeCheckBox.setChecked(
-            Preferences.getMicroPython("SyncTimeAfterConnect"))
-        
+            Preferences.getMicroPython("SyncTimeAfterConnect")
+        )
+
         # REPL Pane
         self.colorSchemeComboBox.setCurrentIndex(
-            self.colorSchemeComboBox.findText(
-                Preferences.getMicroPython("ColorScheme")))
-        self.replWrapCheckBox.setChecked(
-            Preferences.getMicroPython("ReplLineWrap"))
-        
+            self.colorSchemeComboBox.findText(Preferences.getMicroPython("ColorScheme"))
+        )
+        self.replWrapCheckBox.setChecked(Preferences.getMicroPython("ReplLineWrap"))
+
         # Chart Pane
         index = self.chartThemeComboBox.findData(
-            Preferences.getMicroPython("ChartColorTheme"))
+            Preferences.getMicroPython("ChartColorTheme")
+        )
         if index < 0:
             index = 0
         self.chartThemeComboBox.setCurrentIndex(index)
-        
+
         # MPY Cross Compiler
-        self.mpyCrossPicker.setText(
-            Preferences.getMicroPython("MpyCrossCompiler"))
-        
+        self.mpyCrossPicker.setText(Preferences.getMicroPython("MpyCrossCompiler"))
+
         # PyBoard specifics
-        self.dfuUtilPathPicker.setText(
-            Preferences.getMicroPython("DfuUtilPath"))
-        
+        self.dfuUtilPathPicker.setText(Preferences.getMicroPython("DfuUtilPath"))
+
         # MicroPython URLs
         self.micropythonFirmwareUrlLineEdit.setText(
-            Preferences.getMicroPython("MicroPythonFirmwareUrl"))
+            Preferences.getMicroPython("MicroPythonFirmwareUrl")
+        )
         self.micropythonDocuUrlLineEdit.setText(
-            Preferences.getMicroPython("MicroPythonDocuUrl"))
-        
+            Preferences.getMicroPython("MicroPythonDocuUrl")
+        )
+
         # CircuitPython URLs
         self.circuitpythonFirmwareUrlLineEdit.setText(
-            Preferences.getMicroPython("CircuitPythonFirmwareUrl"))
+            Preferences.getMicroPython("CircuitPythonFirmwareUrl")
+        )
         self.circuitpythonLibrariesUrlLineEdit.setText(
-            Preferences.getMicroPython("CircuitPythonLibrariesUrl"))
+            Preferences.getMicroPython("CircuitPythonLibrariesUrl")
+        )
         self.circuitpythonDocuUrlLineEdit.setText(
-            Preferences.getMicroPython("CircuitPythonDocuUrl"))
-        
+            Preferences.getMicroPython("CircuitPythonDocuUrl")
+        )
+
         # BBC micro:bit URLs
         self.microbitFirmwareUrlLineEdit.setText(
-            Preferences.getMicroPython("MicrobitFirmwareUrl"))
+            Preferences.getMicroPython("MicrobitFirmwareUrl")
+        )
         self.microbitV1MicroPythonUrlLineEdit.setText(
-            Preferences.getMicroPython("MicrobitMicroPythonUrl"))
+            Preferences.getMicroPython("MicrobitMicroPythonUrl")
+        )
         self.microbitV2MicroPythonUrlLineEdit.setText(
-            Preferences.getMicroPython("MicrobitV2MicroPythonUrl"))
+            Preferences.getMicroPython("MicrobitV2MicroPythonUrl")
+        )
         self.microbitDocuUrlLineEdit.setText(
-            Preferences.getMicroPython("MicrobitDocuUrl"))
-        
+            Preferences.getMicroPython("MicrobitDocuUrl")
+        )
+
         # Calliope mini URLs
         self.calliopeFirmwareUrlLineEdit.setText(
-            Preferences.getMicroPython("CalliopeDAPLinkUrl"))
+            Preferences.getMicroPython("CalliopeDAPLinkUrl")
+        )
         self.calliopeMicroPythonUrlLineEdit.setText(
-            Preferences.getMicroPython("CalliopeMicroPythonUrl"))
+            Preferences.getMicroPython("CalliopeMicroPythonUrl")
+        )
         self.calliopeDocuUrlLineEdit.setText(
-            Preferences.getMicroPython("CalliopeDocuUrl"))
-    
+            Preferences.getMicroPython("CalliopeDocuUrl")
+        )
+
     def save(self):
         """
         Public slot to save the MicroPython configuration.
         """
         # workspace
-        Preferences.setMicroPython(
-            "MpyWorkspace",
-            self.workspacePicker.text())
-        
+        Preferences.setMicroPython("MpyWorkspace", self.workspacePicker.text())
+
         # serial link parameters
-        Preferences.setMicroPython(
-            "SerialTimeout",
-            self.timeoutSpinBox.value() * 1000)
+        Preferences.setMicroPython("SerialTimeout", self.timeoutSpinBox.value() * 1000)
         # converted to milliseconds
         Preferences.setMicroPython(
-            "SyncTimeAfterConnect",
-            self.syncTimeCheckBox.isChecked())
-        
+            "SyncTimeAfterConnect", self.syncTimeCheckBox.isChecked()
+        )
+
         # REPL Pane
         Preferences.setMicroPython(
-            "ColorScheme",
-            self.colorSchemeComboBox.currentText())
-        Preferences.setMicroPython(
-            "ReplLineWrap",
-            self.replWrapCheckBox.isChecked())
-        
+            "ColorScheme", self.colorSchemeComboBox.currentText()
+        )
+        Preferences.setMicroPython("ReplLineWrap", self.replWrapCheckBox.isChecked())
+
         # Chart Pane
         Preferences.setMicroPython(
-            "ChartColorTheme",
-            self.chartThemeComboBox.currentData())
-        
+            "ChartColorTheme", self.chartThemeComboBox.currentData()
+        )
+
         # MPY Cross Compiler
-        Preferences.setMicroPython(
-            "MpyCrossCompiler",
-            self.mpyCrossPicker.text())
-        
+        Preferences.setMicroPython("MpyCrossCompiler", self.mpyCrossPicker.text())
+
         # PyBoard specifics
-        Preferences.setMicroPython(
-            "DfuUtilPath",
-            self.dfuUtilPathPicker.text())
-        
+        Preferences.setMicroPython("DfuUtilPath", self.dfuUtilPathPicker.text())
+
         # MicroPython URLs
         Preferences.setMicroPython(
-            "MicroPythonFirmwareUrl",
-            self.micropythonFirmwareUrlLineEdit.text())
+            "MicroPythonFirmwareUrl", self.micropythonFirmwareUrlLineEdit.text()
+        )
         Preferences.setMicroPython(
-            "MicroPythonDocuUrl",
-            self.micropythonDocuUrlLineEdit.text())
-        
+            "MicroPythonDocuUrl", self.micropythonDocuUrlLineEdit.text()
+        )
+
         # CircuitPython URLs
         Preferences.setMicroPython(
-            "CircuitPythonFirmwareUrl",
-            self.circuitpythonFirmwareUrlLineEdit.text())
+            "CircuitPythonFirmwareUrl", self.circuitpythonFirmwareUrlLineEdit.text()
+        )
         Preferences.setMicroPython(
-            "CircuitPythonLibrariesUrl",
-            self.circuitpythonLibrariesUrlLineEdit.text())
+            "CircuitPythonLibrariesUrl", self.circuitpythonLibrariesUrlLineEdit.text()
+        )
         Preferences.setMicroPython(
-            "CircuitPythonDocuUrl",
-            self.circuitpythonDocuUrlLineEdit.text())
-        
+            "CircuitPythonDocuUrl", self.circuitpythonDocuUrlLineEdit.text()
+        )
+
         # BBC micro:bit URLs
         Preferences.setMicroPython(
-            "MicrobitFirmwareUrl",
-            self.microbitFirmwareUrlLineEdit.text())
+            "MicrobitFirmwareUrl", self.microbitFirmwareUrlLineEdit.text()
+        )
         Preferences.setMicroPython(
-            "MicrobitMicroPythonUrl",
-            self.microbitV1MicroPythonUrlLineEdit.text())
+            "MicrobitMicroPythonUrl", self.microbitV1MicroPythonUrlLineEdit.text()
+        )
         Preferences.setMicroPython(
-            "MicrobitV2MicroPythonUrl",
-            self.microbitV2MicroPythonUrlLineEdit.text())
+            "MicrobitV2MicroPythonUrl", self.microbitV2MicroPythonUrlLineEdit.text()
+        )
         Preferences.setMicroPython(
-            "MicrobitDocuUrl",
-            self.microbitDocuUrlLineEdit.text())
-        
+            "MicrobitDocuUrl", self.microbitDocuUrlLineEdit.text()
+        )
+
         # Calliope mini URLs
         Preferences.setMicroPython(
-            "CalliopeDAPLinkUrl",
-            self.calliopeFirmwareUrlLineEdit.text())
+            "CalliopeDAPLinkUrl", self.calliopeFirmwareUrlLineEdit.text()
+        )
         Preferences.setMicroPython(
-            "CalliopeMicroPythonUrl",
-            self.calliopeMicroPythonUrlLineEdit.text())
+            "CalliopeMicroPythonUrl", self.calliopeMicroPythonUrlLineEdit.text()
+        )
         Preferences.setMicroPython(
-            "CalliopeDocuUrl",
-            self.calliopeDocuUrlLineEdit.text())
+            "CalliopeDocuUrl", self.calliopeDocuUrlLineEdit.text()
+        )
 
 
 def create(dlg):
     """
     Module function to create the configuration page.
-    
+
     @param dlg reference to the configuration dialog
     @return reference to the instantiated page (ConfigurationPageBase)
     """

eric ide

mercurial