13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
14 |
14 |
15 from .Ui_PipPackagesInputDialog import Ui_PipPackagesInputDialog |
15 from .Ui_PipPackagesInputDialog import Ui_PipPackagesInputDialog |
16 |
16 |
17 |
17 |
18 # TODO: add checkbox to select an installation into 'user site' |
|
19 class PipPackagesInputDialog(QDialog, Ui_PipPackagesInputDialog): |
18 class PipPackagesInputDialog(QDialog, Ui_PipPackagesInputDialog): |
20 """ |
19 """ |
21 Class implementing a dialog to enter package specifications. |
20 Class implementing a dialog to enter package specifications. |
22 """ |
21 """ |
23 def __init__(self, plugin, title, parent=None): |
22 def __init__(self, plugin, title, install=True, parent=None): |
24 """ |
23 """ |
25 Constructor |
24 Constructor |
26 |
25 |
27 @param plugin reference to the plugin object (ToolPipPlugin) |
26 @param plugin reference to the plugin object |
28 @param title dialog title (string) |
27 @type ToolPipPlugin |
29 @param parent reference to the parent widget (QWidget) |
28 @param title dialog title |
|
29 @type str |
|
30 @param install flag indicating an install action |
|
31 @type bool |
|
32 @param parent reference to the parent widget |
|
33 @type QWidget |
30 """ |
34 """ |
31 super(PipPackagesInputDialog, self).__init__(parent) |
35 super(PipPackagesInputDialog, self).__init__(parent) |
32 self.setupUi(self) |
36 self.setupUi(self) |
33 |
37 |
34 self.setWindowTitle(title) |
38 self.setWindowTitle(title) |
37 |
41 |
38 self.__default = self.tr("<Default>") |
42 self.__default = self.tr("<Default>") |
39 pipExecutables = sorted(plugin.getPreferences("PipExecutables")) |
43 pipExecutables = sorted(plugin.getPreferences("PipExecutables")) |
40 self.pipComboBox.addItem(self.__default) |
44 self.pipComboBox.addItem(self.__default) |
41 self.pipComboBox.addItems(pipExecutables) |
45 self.pipComboBox.addItems(pipExecutables) |
|
46 |
|
47 self.userCheckBox.setVisible(install) |
42 |
48 |
43 msh = self.minimumSizeHint() |
49 msh = self.minimumSizeHint() |
44 self.resize(max(self.width(), msh.width()), msh.height()) |
50 self.resize(max(self.width(), msh.width()), msh.height()) |
45 |
51 |
46 @pyqtSlot(str) |
52 @pyqtSlot(str) |
54 |
60 |
55 def getData(self): |
61 def getData(self): |
56 """ |
62 """ |
57 Public method to get the entered data. |
63 Public method to get the entered data. |
58 |
64 |
59 @return tuple with the pip command (string) and the list of |
65 @return tuple with the pip command, the list of package specifications |
60 package specifications (list of string) |
66 and a flag indicating to install to the user install directory |
|
67 @rtype tuple of (str, list of str, bool) |
61 """ |
68 """ |
62 command = self.pipComboBox.currentText() |
69 command = self.pipComboBox.currentText() |
63 if command == self.__default: |
70 if command == self.__default: |
64 command = "" |
71 command = "" |
65 packages = [p.strip() for p in self.packagesEdit.text().split()] |
72 packages = [p.strip() for p in self.packagesEdit.text().split()] |
66 |
73 |
67 return command, packages |
74 return command, packages, self.userCheckBox.isChecked() |