Plugins/UiExtensionPlugins/PipInterface/PipPackagesInputDialog.py

changeset 6342
c79ecba9cde7
parent 6327
a1716d9210f4
child 6619
1d34365c082c
equal deleted inserted replaced
6341:a00e63f6d766 6342:c79ecba9cde7
17 17
18 class PipPackagesInputDialog(QDialog, Ui_PipPackagesInputDialog): 18 class PipPackagesInputDialog(QDialog, Ui_PipPackagesInputDialog):
19 """ 19 """
20 Class implementing a dialog to enter package specifications. 20 Class implementing a dialog to enter package specifications.
21 """ 21 """
22 def __init__(self, plugin, title, install=True, parent=None): 22 def __init__(self, pip, title, install=True, parent=None):
23 """ 23 """
24 Constructor 24 Constructor
25 25
26 @param plugin reference to the plugin object 26 @param pip reference to the pip object
27 @type ToolPipPlugin 27 @type Pip
28 @param title dialog title 28 @param title dialog title
29 @type str 29 @type str
30 @param install flag indicating an install action 30 @param install flag indicating an install action
31 @type bool 31 @type bool
32 @param parent reference to the parent widget 32 @param parent reference to the parent widget
37 37
38 self.setWindowTitle(title) 38 self.setWindowTitle(title)
39 39
40 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) 40 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
41 41
42 self.__default = self.tr("<Default>") 42 self.venvComboBox.addItem(pip.getDefaultEnvironmentString())
43 pipExecutables = sorted(plugin.getPreferences("PipExecutables")) 43 self.venvComboBox.addItems(pip.getVirtualenvNames())
44 self.pipComboBox.addItem(self.__default)
45 self.pipComboBox.addItems(pipExecutables)
46 44
47 self.userCheckBox.setVisible(install) 45 self.userCheckBox.setVisible(install)
48 46
49 msh = self.minimumSizeHint() 47 msh = self.minimumSizeHint()
50 self.resize(max(self.width(), msh.width()), msh.height()) 48 self.resize(max(self.width(), msh.width()), msh.height())
52 @pyqtSlot(str) 50 @pyqtSlot(str)
53 def on_packagesEdit_textChanged(self, txt): 51 def on_packagesEdit_textChanged(self, txt):
54 """ 52 """
55 Private slot handling entering package names. 53 Private slot handling entering package names.
56 54
57 @param txt name of the requirements file (string) 55 @param txt name of the requirements file
56 @type str
58 """ 57 """
59 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(bool(txt)) 58 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(bool(txt))
60 59
61 def getData(self): 60 def getData(self):
62 """ 61 """
63 Public method to get the entered data. 62 Public method to get the entered data.
64 63
65 @return tuple with the pip command, the list of package specifications 64 @return tuple with the environment name, the list of package
66 and a flag indicating to install to the user install directory 65 specifications and a flag indicating to install to the user
66 install directory
67 @rtype tuple of (str, list of str, bool) 67 @rtype tuple of (str, list of str, bool)
68 """ 68 """
69 command = self.pipComboBox.currentText()
70 if command == self.__default:
71 command = ""
72 packages = [p.strip() for p in self.packagesEdit.text().split()] 69 packages = [p.strip() for p in self.packagesEdit.text().split()]
73 70
74 return command, packages, self.userCheckBox.isChecked() 71 return (
72 self.venvComboBox.currentText(),
73 packages,
74 self.userCheckBox.isChecked()
75 )

eric ide

mercurial