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 """ |