eric7/VirtualEnv/VirtualenvInterpreterSelectionDialog.py

branch
eric7
changeset 8986
665d14b3c01a
parent 8980
f49ab2441e1f
child 9144
135240382a3e
equal deleted inserted replaced
8985:30e9e592732d 8986:665d14b3c01a
17 17
18 from .Ui_VirtualenvInterpreterSelectionDialog import ( 18 from .Ui_VirtualenvInterpreterSelectionDialog import (
19 Ui_VirtualenvInterpreterSelectionDialog 19 Ui_VirtualenvInterpreterSelectionDialog
20 ) 20 )
21 21
22 import Globals
22 23
23 # TODO: add code to autodetect a Python interpreter 24
24 class VirtualenvInterpreterSelectionDialog( 25 class VirtualenvInterpreterSelectionDialog(
25 QDialog, Ui_VirtualenvInterpreterSelectionDialog): 26 QDialog, Ui_VirtualenvInterpreterSelectionDialog):
26 """ 27 """
27 Class implementing a dialog to enter the interpreter for a virtual 28 Class implementing a dialog to enter the interpreter for a virtual
28 environment. 29 environment.
44 self.pythonExecPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) 45 self.pythonExecPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE)
45 self.pythonExecPicker.setWindowTitle( 46 self.pythonExecPicker.setWindowTitle(
46 self.tr("Python Interpreter")) 47 self.tr("Python Interpreter"))
47 48
48 self.nameEdit.setText(venvName) 49 self.nameEdit.setText(venvName)
49 self.pythonExecPicker.setText(venvDirectory) 50
51 if venvDirectory:
52 # try to determine a Python interpreter name
53 if Globals.isWindowsPlatform():
54 candidates = (
55 os.path.join(venvDirectory, "Scripts", "python.exe"),
56 os.path.join(venvDirectory, "python.exe"),
57 )
58 else:
59 candidates = (
60 os.path.join(venvDirectory, "bin", "python3"),
61 )
62 for py in candidates:
63 if os.path.exists(py):
64 self.pythonExecPicker.setText(py)
65 break
66 else:
67 self.pythonExecPicker.setText(venvDirectory)
68 else:
69 self.pythonExecPicker.setText(venvDirectory)
50 70
51 def __updateOK(self): 71 def __updateOK(self):
52 """ 72 """
53 Private method to update the enabled status of the OK button. 73 Private method to update the enabled status of the OK button.
54 """ 74 """

eric ide

mercurial