eric6/PipInterface/PipPackagesInputDialog.py

changeset 6942
2602857055c5
parent 6795
6e2ed2aac325
child 7229
53054eb5b15a
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
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.userCheckBox.setVisible(install)
43
44 msh = self.minimumSizeHint()
45 self.resize(max(self.width(), msh.width()), msh.height())
46
47 @pyqtSlot(str)
48 def on_packagesEdit_textChanged(self, txt):
49 """
50 Private slot handling entering package names.
51
52 @param txt name of the requirements file
53 @type str
54 """
55 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(bool(txt))
56
57 def getData(self):
58 """
59 Public method to get the entered data.
60
61 @return tuple with the list of package specifications and a flag
62 indicating to install to the user install directory
63 @rtype tuple of (list of str, bool)
64 """
65 packages = [p.strip() for p in self.packagesEdit.text().split()]
66
67 return (
68 packages,
69 self.userCheckBox.isChecked()
70 )

eric ide

mercurial