Plugins/UiExtensionPlugins/PipInterface/PipPackagesInputDialog.py

changeset 6805
10fefa6f331a
parent 6797
d9e56b0aa7ac
parent 6804
dc20bde4af90
child 6806
d306647cb82d
equal deleted inserted replaced
6797:d9e56b0aa7ac 6805:10fefa6f331a
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2015 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter package specifications.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.QtCore import pyqtSlot
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
14
15 from .Ui_PipPackagesInputDialog import Ui_PipPackagesInputDialog
16
17
18 class PipPackagesInputDialog(QDialog, Ui_PipPackagesInputDialog):
19 """
20 Class implementing a dialog to enter package specifications.
21 """
22 def __init__(self, pip, title, install=True, parent=None):
23 """
24 Constructor
25
26 @param pip reference to the pip object
27 @type Pip
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
34 """
35 super(PipPackagesInputDialog, self).__init__(parent)
36 self.setupUi(self)
37
38 self.setWindowTitle(title)
39
40 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
41
42 self.venvComboBox.addItem(pip.getDefaultEnvironmentString())
43 projectVenv = pip.getProjectEnvironmentString()
44 if projectVenv:
45 self.venvComboBox.addItem(projectVenv)
46 self.venvComboBox.addItems(pip.getVirtualenvNames())
47
48 self.userCheckBox.setVisible(install)
49
50 msh = self.minimumSizeHint()
51 self.resize(max(self.width(), msh.width()), msh.height())
52
53 @pyqtSlot(str)
54 def on_packagesEdit_textChanged(self, txt):
55 """
56 Private slot handling entering package names.
57
58 @param txt name of the requirements file
59 @type str
60 """
61 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(bool(txt))
62
63 def getData(self):
64 """
65 Public method to get the entered data.
66
67 @return tuple with the environment name, the list of package
68 specifications and a flag indicating to install to the user
69 install directory
70 @rtype tuple of (str, list of str, bool)
71 """
72 packages = [p.strip() for p in self.packagesEdit.text().split()]
73
74 return (
75 self.venvComboBox.currentText(),
76 packages,
77 self.userCheckBox.isChecked()
78 )

eric ide

mercurial