Corrected some shortcomings in the conda interface. eric7

Thu, 24 Apr 2025 12:58:23 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 24 Apr 2025 12:58:23 +0200
branch
eric7
changeset 11233
295366a93bbf
parent 11232
08f867dd2abe
child 11234
438e91847a5a

Corrected some shortcomings in the conda interface.

src/eric7/CondaInterface/Conda.py file | annotate | diff | comparison | revisions
src/eric7/CondaInterface/CondaPackagesWidget.py file | annotate | diff | comparison | revisions
src/eric7/Documentation/Help/source.qch file | annotate | diff | comparison | revisions
src/eric7/Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
src/eric7/Documentation/Source/eric7.CondaInterface.Conda.html file | annotate | diff | comparison | revisions
--- a/src/eric7/CondaInterface/Conda.py	Wed Apr 23 18:13:44 2025 +0200
+++ b/src/eric7/CondaInterface/Conda.py	Thu Apr 24 12:58:23 2025 +0200
@@ -11,7 +11,7 @@
 import json
 import os
 
-from PyQt6.QtCore import QCoreApplication, QObject, QProcess, pyqtSignal
+from PyQt6.QtCore import QCoreApplication, QObject, QProcess, pyqtSignal, pyqtSlot
 from PyQt6.QtWidgets import QDialog
 
 from eric7 import Preferences
@@ -51,17 +51,31 @@
         super().__init__(parent)
 
         self.__ui = parent
+        with contextlib.suppress(AttributeError):
+            self.__ui.preferencesChanged.connect(self.__preferencesChanged)
 
+        self.__preferencesChanged()
+
+    @pyqtSlot()
+    def __preferencesChanged(self):
+        """
+        Private slot handling a change of configuration.
+        """
         envManager = ericApp().getObject("VirtualEnvManager")
-        envManager.registerType(
-            VirtualenvType(
-                name=Conda.EnvironmentType,
-                visual_name=self.tr("Anaconda"),
-                createFunc=self.createCondaVirtualEnvironment,
-                deleteFunc=self.deleteCondaVirtualEnvironment,
-                defaultExecPathFunc=self.condaDefaultExecPath,
-            )
-        )
+        if isCondaAvailable():
+            with contextlib.suppress(KeyError):
+                # conda was possibly registered already
+                envManager.registerType(
+                    VirtualenvType(
+                        name=Conda.EnvironmentType,
+                        visual_name=self.tr("Anaconda"),
+                        createFunc=self.createCondaVirtualEnvironment,
+                        deleteFunc=self.deleteCondaVirtualEnvironment,
+                        defaultExecPathFunc=self.condaDefaultExecPath,
+                    )
+                )
+        else:
+            envManager.unregisterType(name=Conda.EnvironmentType)
 
     #######################################################################
     ## environment related methods below
--- a/src/eric7/CondaInterface/CondaPackagesWidget.py	Wed Apr 23 18:13:44 2025 +0200
+++ b/src/eric7/CondaInterface/CondaPackagesWidget.py	Thu Apr 24 12:58:23 2025 +0200
@@ -111,6 +111,7 @@
         self.__updateActionButtons()
 
         self.searchWidget.hide()
+        self.baseWidget.show()
 
         self.__conda.condaEnvironmentCreated.connect(self.on_refreshButton_clicked)
         self.__conda.condaEnvironmentRemoved.connect(self.on_refreshButton_clicked)
@@ -766,4 +767,4 @@
             self.__initCondaInterface()
 
             self.notAvailableWidget.hide()
-            self.baseWidget.show()
+            self.availableWidget.show()
Binary file src/eric7/Documentation/Help/source.qch has changed
--- a/src/eric7/Documentation/Help/source.qhp	Wed Apr 23 18:13:44 2025 +0200
+++ b/src/eric7/Documentation/Help/source.qhp	Thu Apr 24 12:58:23 2025 +0200
@@ -3526,6 +3526,7 @@
       <keyword name="Conda" id="Conda" ref="eric7.CondaInterface.Conda.html#Conda" />
       <keyword name="Conda (Constructor)" id="Conda (Constructor)" ref="eric7.CondaInterface.Conda.html#Conda.__init__" />
       <keyword name="Conda (Module)" id="Conda (Module)" ref="eric7.CondaInterface.Conda.html" />
+      <keyword name="Conda.__preferencesChanged" id="Conda.__preferencesChanged" ref="eric7.CondaInterface.Conda.html#Conda.__preferencesChanged" />
       <keyword name="Conda.cleanConda" id="Conda.cleanConda" ref="eric7.CondaInterface.Conda.html#Conda.cleanConda" />
       <keyword name="Conda.condaDefaultExecPath" id="Conda.condaDefaultExecPath" ref="eric7.CondaInterface.Conda.html#Conda.condaDefaultExecPath" />
       <keyword name="Conda.createCondaEnvironment" id="Conda.createCondaEnvironment" ref="eric7.CondaInterface.Conda.html#Conda.createCondaEnvironment" />
--- a/src/eric7/Documentation/Source/eric7.CondaInterface.Conda.html	Wed Apr 23 18:13:44 2025 +0200
+++ b/src/eric7/Documentation/Source/eric7.CondaInterface.Conda.html	Thu Apr 24 12:58:23 2025 +0200
@@ -71,6 +71,10 @@
 <td>Constructor</td>
 </tr>
 <tr>
+<td><a href="#Conda.__preferencesChanged">__preferencesChanged</a></td>
+<td>Private slot handling a change of configuration.</td>
+</tr>
+<tr>
 <td><a href="#Conda.cleanConda">cleanConda</a></td>
 <td>Public method to update conda itself.</td>
 </tr>
@@ -164,6 +168,13 @@
 parent
 </dd>
 </dl>
+<a NAME="Conda.__preferencesChanged" ID="Conda.__preferencesChanged"></a>
+<h4>Conda.__preferencesChanged</h4>
+<b>__preferencesChanged</b>(<i></i>)
+<p>
+        Private slot handling a change of configuration.
+</p>
+
 <a NAME="Conda.cleanConda" ID="Conda.cleanConda"></a>
 <h4>Conda.cleanConda</h4>
 <b>cleanConda</b>(<i>cleanAction</i>)

eric ide

mercurial