eric7/PipInterface/PipPackagesInputDialog.py

branch
eric7
changeset 8312
800c432b34c8
parent 8218
7c09585bd960
child 8318
962bce857696
equal deleted inserted replaced
8311:4e8b98454baa 8312:800c432b34c8
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2015 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter package specifications.
8 """
9
10 from PyQt5.QtCore import pyqtSlot
11 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
12
13 from .Ui_PipPackagesInputDialog import Ui_PipPackagesInputDialog
14
15
16 class PipPackagesInputDialog(QDialog, Ui_PipPackagesInputDialog):
17 """
18 Class implementing a dialog to enter package specifications.
19 """
20 def __init__(self, pip, title, install=True, parent=None):
21 """
22 Constructor
23
24 @param pip reference to the pip object
25 @type Pip
26 @param title dialog title
27 @type str
28 @param install flag indicating an install action
29 @type bool
30 @param parent reference to the parent widget
31 @type QWidget
32 """
33 super().__init__(parent)
34 self.setupUi(self)
35
36 self.setWindowTitle(title)
37
38 self.buttonBox.button(
39 QDialogButtonBox.StandardButton.Ok).setEnabled(False)
40
41 self.userCheckBox.setVisible(install)
42
43 msh = self.minimumSizeHint()
44 self.resize(max(self.width(), msh.width()), msh.height())
45
46 @pyqtSlot(str)
47 def on_packagesEdit_textChanged(self, txt):
48 """
49 Private slot handling entering package names.
50
51 @param txt name of the requirements file
52 @type str
53 """
54 self.buttonBox.button(
55 QDialogButtonBox.StandardButton.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