VirtualEnv/VirtualenvInterpreterSelectionDialog.py

changeset 6337
c6af560e0039
child 6349
17b3c75913de
equal deleted inserted replaced
6336:a04ac8bd014b 6337:c6af560e0039
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2018 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter the interpreter for a virtual
8 environment.
9 """
10
11 from __future__ import unicode_literals
12
13 import os
14
15 from PyQt5.QtCore import pyqtSlot
16 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
17
18 from E5Gui.E5PathPicker import E5PathPickerModes
19
20 from .Ui_VirtualenvInterpreterSelectionDialog import \
21 Ui_VirtualenvInterpreterSelectionDialog
22
23
24 class VirtualenvInterpreterSelectionDialog(
25 QDialog, Ui_VirtualenvInterpreterSelectionDialog):
26 """
27 Class implementing a dialog to enter the interpreter for a virtual
28 environment.
29 """
30 def __init__(self, venvName, venvDirectory, parent=None):
31 """
32 Constructor
33
34 @param venvName name for the virtual environment
35 @type str
36 @param venvDirectory directory of the virtual environment
37 @type str
38 @param parent reference to the parent widget
39 @type QWidget
40 """
41 super(VirtualenvInterpreterSelectionDialog, self).__init__(parent)
42 self.setupUi(self)
43
44 self.pythonExecPicker.setMode(E5PathPickerModes.OpenFileMode)
45 self.pythonExecPicker.setWindowTitle(
46 self.tr("Python Interpreter"))
47
48 self.nameEdit.setText(venvName)
49 self.pythonExecPicker.setText(venvDirectory)
50
51 def __updateOK(self):
52 """
53 Private method to update the enabled status of the OK button.
54 """
55 interpreterPath = self.pythonExecPicker.text()
56 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(
57 bool(interpreterPath) and
58 os.path.isfile(interpreterPath) and
59 os.access(interpreterPath, os.X_OK)
60 )
61
62 @pyqtSlot(str)
63 def on_pythonExecPicker_textChanged(self, txt):
64 """
65 Private slot to handle changes of the entered Python interpreter path.
66
67 @param txt entered Python interpreter path
68 @type str
69 """
70 self.__updateOK()
71
72 def getData(self):
73 """
74 Public method to get the entered data.
75
76 @return path of the selected Python interpreter
77 @rtype str
78 """
79 return self.pythonExecPicker.text()

eric ide

mercurial