--- a/src/eric7/Preferences/ConfigurationPages/MicroPythonPage.py Mon Apr 03 10:51:10 2023 +0200 +++ b/src/eric7/Preferences/ConfigurationPages/MicroPythonPage.py Mon Apr 03 11:36:16 2023 +0200 @@ -7,14 +7,17 @@ Module implementing the MicroPython configuration page. """ +import os + from PyQt6.QtCore import pyqtSlot from PyQt6.QtWidgets import QLineEdit from eric7 import Preferences from eric7.EricGui import EricPixmapCache +from eric7.EricWidgets.EricApplication import ericApp from eric7.EricWidgets.EricPathPicker import EricPathPickerModes from eric7.MicroPython.MicroPythonWidget import AnsiColorSchemes -from eric7.SystemUtilities import FileSystemUtilities, OSUtilities +from eric7.SystemUtilities import FileSystemUtilities, OSUtilities, PythonUtilities from .ConfigurationPageBase import ConfigurationPageBase from .Ui_MicroPythonPage import Ui_MicroPythonPage @@ -350,6 +353,33 @@ self.apShowPasswordButton.setIcon(EricPixmapCache.getIcon("showPassword")) self.apShowPasswordButton.setToolTip(self.tr("Press to show the password")) + @pyqtSlot() + def on_mpyCrossInstallButton_clicked(self): + """ + Private slot to install the 'mpy-cross' compiler. + """ + pip = ericApp().getObject("Pip") + pip.installPackages( + ["mpy-cross"], interpreter=PythonUtilities.getPythonExecutable() + ) + + mpycrossPath = os.path.join( + PythonUtilities.getPythonScriptsDirectory(), "mpy-cross" + ) + if OSUtilities.isWindowsPlatform(): + mpycrossPath += ".exe" + self.mpyCrossPicker.setText(mpycrossPath) + + @pyqtSlot(str) + def on_mpyCrossPicker_textChanged(self, mpycrossPath): + """ + Private slot to handle a change of the selected 'mpy-cross' compiler. + + @param mpycrossPath entered path of the 'mpy-cross' compiler + @type str + """ + self.mpyCrossInstallButton.setEnabled(not bool(mpycrossPath)) + def create(dlg): """