eric6/VirtualEnv/VirtualenvManager.py

branch
maintenance
changeset 8043
0acf98cd089a
parent 7924
8a96736d465e
parent 7960
e8fc383322f7
child 8176
31965986ecd1
--- a/eric6/VirtualEnv/VirtualenvManager.py	Sun Jan 17 13:53:08 2021 +0100
+++ b/eric6/VirtualEnv/VirtualenvManager.py	Mon Feb 01 10:38:16 2021 +0100
@@ -58,6 +58,9 @@
         """
         Private slot to load the virtual environments.
         """
+        self.__virtualEnvironmentsBaseDir = Preferences.Prefs.settings.value(
+            "PyVenv/VirtualEnvironmentsBaseDir", "")
+        
         venvString = Preferences.Prefs.settings.value(
             "PyVenv/VirtualEnvironments", "{}")     # __IGNORE_WARNING_M613__
         environments = json.loads(venvString)
@@ -127,6 +130,10 @@
         Private slot to save the virtual environments.
         """
         Preferences.Prefs.settings.setValue(
+            "PyVenv/VirtualEnvironmentsBaseDir",
+            self.__virtualEnvironmentsBaseDir)
+        
+        Preferences.Prefs.settings.setValue(
             "PyVenv/VirtualEnvironments",
             json.dumps(self.__virtualEnvironments)
         )
@@ -138,7 +145,7 @@
         
         Default is an environment with the key '<default>' or the first one
         having an interpreter matching sys.executable (i.e. the one used to
-        execute eric6 with)
+        execute eric with)
         
         @return tuple containing the environment name and a dictionary
             containing a copy of the default virtual environment
@@ -164,15 +171,21 @@
         return ("", {})
     
     @pyqtSlot()
-    def createVirtualEnv(self):
+    def createVirtualEnv(self, baseDir=""):
         """
         Public slot to create a new virtual environment.
+        
+        @param baseDir base directory for the virtual environments
+        @type str
         """
         from .VirtualenvConfigurationDialog import (
             VirtualenvConfigurationDialog
         )
         
-        dlg = VirtualenvConfigurationDialog()
+        if not baseDir:
+            baseDir = self.__virtualEnvironmentsBaseDir
+        
+        dlg = VirtualenvConfigurationDialog(baseDir=baseDir)
         if dlg.exec() == QDialog.Accepted:
             resultDict = dlg.getData()
             
@@ -602,3 +615,22 @@
             return self.__virtualEnvironments[venvName]["exec_path"]
         else:
             return ""
+    
+    def setVirtualEnvironmentsBaseDir(self, baseDir):
+        """
+        Public method to set the base directory for the virtual environments.
+        
+        @param baseDir base directory for the virtual environments
+        @type str
+        """
+        self.__virtualEnvironmentsBaseDir = baseDir
+        self.__saveSettings()
+    
+    def getVirtualEnvironmentsBaseDir(self):
+        """
+        Public method to set the base directory for the virtual environments.
+        
+        @return base directory for the virtual environments
+        @rtype str
+        """
+        return self.__virtualEnvironmentsBaseDir

eric ide

mercurial