9 |
9 |
10 import contextlib |
10 import contextlib |
11 import json |
11 import json |
12 import os |
12 import os |
13 |
13 |
14 from PyQt6.QtCore import QCoreApplication, QObject, QProcess, pyqtSignal |
14 from PyQt6.QtCore import QCoreApplication, QObject, QProcess, pyqtSignal, pyqtSlot |
15 from PyQt6.QtWidgets import QDialog |
15 from PyQt6.QtWidgets import QDialog |
16 |
16 |
17 from eric7 import Preferences |
17 from eric7 import Preferences |
18 from eric7.EricWidgets import EricMessageBox |
18 from eric7.EricWidgets import EricMessageBox |
19 from eric7.EricWidgets.EricApplication import ericApp |
19 from eric7.EricWidgets.EricApplication import ericApp |
49 @type QObject |
49 @type QObject |
50 """ |
50 """ |
51 super().__init__(parent) |
51 super().__init__(parent) |
52 |
52 |
53 self.__ui = parent |
53 self.__ui = parent |
54 |
54 with contextlib.suppress(AttributeError): |
|
55 self.__ui.preferencesChanged.connect(self.__preferencesChanged) |
|
56 |
|
57 self.__preferencesChanged() |
|
58 |
|
59 @pyqtSlot() |
|
60 def __preferencesChanged(self): |
|
61 """ |
|
62 Private slot handling a change of configuration. |
|
63 """ |
55 envManager = ericApp().getObject("VirtualEnvManager") |
64 envManager = ericApp().getObject("VirtualEnvManager") |
56 envManager.registerType( |
65 if isCondaAvailable(): |
57 VirtualenvType( |
66 with contextlib.suppress(KeyError): |
58 name=Conda.EnvironmentType, |
67 # conda was possibly registered already |
59 visual_name=self.tr("Anaconda"), |
68 envManager.registerType( |
60 createFunc=self.createCondaVirtualEnvironment, |
69 VirtualenvType( |
61 deleteFunc=self.deleteCondaVirtualEnvironment, |
70 name=Conda.EnvironmentType, |
62 defaultExecPathFunc=self.condaDefaultExecPath, |
71 visual_name=self.tr("Anaconda"), |
63 ) |
72 createFunc=self.createCondaVirtualEnvironment, |
64 ) |
73 deleteFunc=self.deleteCondaVirtualEnvironment, |
|
74 defaultExecPathFunc=self.condaDefaultExecPath, |
|
75 ) |
|
76 ) |
|
77 else: |
|
78 envManager.unregisterType(name=Conda.EnvironmentType) |
65 |
79 |
66 ####################################################################### |
80 ####################################################################### |
67 ## environment related methods below |
81 ## environment related methods below |
68 ####################################################################### |
82 ####################################################################### |
69 |
83 |