Preferences/__init__.py

branch
maintenance
changeset 6395
613e37fabd96
parent 6319
df201b9fbad4
parent 6349
17b3c75913de
child 6455
22a6fc33ab6d
--- a/Preferences/__init__.py	Sat Jun 02 12:46:57 2018 +0200
+++ b/Preferences/__init__.py	Mon Jul 02 18:59:30 2018 +0200
@@ -31,7 +31,7 @@
 from PyQt5.QtCore import QDir, QPoint, QLocale, QSettings, QFileInfo, \
     QCoreApplication, QByteArray, QSize, QUrl, Qt, QLibraryInfo, QDateTime
 from PyQt5.QtGui import QColor, QFont, QPalette
-from PyQt5.QtWidgets import QInputDialog, QApplication
+from PyQt5.QtWidgets import QApplication
 from PyQt5.QtNetwork import QNetworkRequest
 try:
     from PyQt5.QtWebKit import QWebSettings
@@ -48,8 +48,8 @@
 from E5Network.E5Ftp import E5FtpProxyType
 
 from Globals import settingsNameOrganization, settingsNameGlobal, \
-    settingsNameRecent, isWindowsPlatform, findPythonInterpreters, \
-    getPyQt5ModulesDirectory, qVersionTuple
+    settingsNameRecent, isWindowsPlatform, getPyQt5ModulesDirectory, \
+    qVersionTuple
 
 from Project.ProjectBrowserFlags import SourcesBrowserFlag, FormsBrowserFlag, \
     ResourcesBrowserFlag, TranslationsBrowserFlag, InterfacesBrowserFlag, \
@@ -92,8 +92,8 @@
         "SuppressClientExit": False,
         "BreakAlways": False,
         "ShowExceptionInShell": True,
-        "PythonInterpreter": "",
-        "Python3Interpreter": "",
+        "Python2VirtualEnv": "",
+        "Python3VirtualEnv": "",
         "RubyInterpreter": "",
         "DebugClientType": "standard",
         # supported "standard", "custom"
@@ -1797,34 +1797,27 @@
             prefClass.settings.value(
                 "Debugger/" + key, prefClass.debuggerDefaults[key]))
     elif key in ["PythonInterpreter", "Python3Interpreter"]:
-        interpreter = \
-            prefClass.settings.value(
-                "Debugger/" + key, prefClass.debuggerDefaults[key])
+        # This code is here to ensure backward compatibility.
+        if key == "PythonInterpreter":
+            newKey = "Python2VirtualEnv"
+        else:
+            newKey = "Python3VirtualEnv"
+        venvName = prefClass.settings.value(
+            "Debugger/" + newKey, prefClass.debuggerDefaults[newKey])
+        if venvName:
+            try:
+                from E5Gui.E5Application import e5App
+                virtualenvManager = e5App().getObject("VirtualEnvManager")
+            except KeyError:
+                from VirtualEnv.VirtualenvManager import VirtualenvManager
+                virtualenvManager = VirtualenvManager()
+            interpreter = virtualenvManager.getVirtualenvInterpreter(venvName)
+        else:
+            interpreter = ""
         if not interpreter:
             pyVersion = 2 if key == "PythonInterpreter" else 3
             if sys.version_info[0] == pyVersion:
                 return sys.executable
-
-            interpreters = findPythonInterpreters(pyVersion)
-            if interpreters:
-                if len(interpreters) == 1:
-                    interpreter = interpreters[0]
-                else:
-                    selection, ok = QInputDialog.getItem(
-                        None,
-                        QCoreApplication.translate(
-                            "Preferences",
-                            "Select Python{0} Interpreter").format(pyVersion),
-                        QCoreApplication.translate(
-                            "Preferences",
-                            "Select the Python{0} interpreter to be used:")
-                        .format(pyVersion),
-                        interpreters,
-                        0, False)
-                    if ok and selection != "":
-                        interpreter = selection
-                if interpreter:
-                    setDebugger(key, interpreter)
         return interpreter
     elif key in ["DebugClientType", "DebugClientType3"]:
         debugClientType = prefClass.settings.value(

eric ide

mercurial