Wed, 01 Jan 2020 11:57:23 +0100
Updated copyright for 2020.
6011
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
7360
9190402e4505
Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
3 | # Copyright (c) 2015 - 2020 Detlev Offenbach <detlev@die-offenbachs.de> |
6011
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a dialog to enter package specifications. |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | from PyQt5.QtCore import pyqtSlot |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | from .Ui_PipPackagesInputDialog import Ui_PipPackagesInputDialog |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | class PipPackagesInputDialog(QDialog, Ui_PipPackagesInputDialog): |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | """ |
6047
39586a2de99d
Fixed some forgotten source code documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6011
diff
changeset
|
19 | Class implementing a dialog to enter package specifications. |
6011
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | """ |
6342
c79ecba9cde7
pip Interface: changed to use the new VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6327
diff
changeset
|
21 | def __init__(self, pip, title, install=True, parent=None): |
6011
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | """ |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | Constructor |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | |
6342
c79ecba9cde7
pip Interface: changed to use the new VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6327
diff
changeset
|
25 | @param pip reference to the pip object |
c79ecba9cde7
pip Interface: changed to use the new VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6327
diff
changeset
|
26 | @type Pip |
6327
a1716d9210f4
pip Interface: started to add support for the '--user' option.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6301
diff
changeset
|
27 | @param title dialog title |
a1716d9210f4
pip Interface: started to add support for the '--user' option.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6301
diff
changeset
|
28 | @type str |
a1716d9210f4
pip Interface: started to add support for the '--user' option.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6301
diff
changeset
|
29 | @param install flag indicating an install action |
a1716d9210f4
pip Interface: started to add support for the '--user' option.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6301
diff
changeset
|
30 | @type bool |
a1716d9210f4
pip Interface: started to add support for the '--user' option.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6301
diff
changeset
|
31 | @param parent reference to the parent widget |
a1716d9210f4
pip Interface: started to add support for the '--user' option.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6301
diff
changeset
|
32 | @type QWidget |
6011
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | """ |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | super(PipPackagesInputDialog, self).__init__(parent) |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | self.setupUi(self) |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | self.setWindowTitle(title) |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | |
6327
a1716d9210f4
pip Interface: started to add support for the '--user' option.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6301
diff
changeset
|
41 | self.userCheckBox.setVisible(install) |
a1716d9210f4
pip Interface: started to add support for the '--user' option.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6301
diff
changeset
|
42 | |
6011
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | msh = self.minimumSizeHint() |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | self.resize(max(self.width(), msh.width()), msh.height()) |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | @pyqtSlot(str) |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | def on_packagesEdit_textChanged(self, txt): |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | """ |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | Private slot handling entering package names. |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | |
6342
c79ecba9cde7
pip Interface: changed to use the new VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6327
diff
changeset
|
51 | @param txt name of the requirements file |
c79ecba9cde7
pip Interface: changed to use the new VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6327
diff
changeset
|
52 | @type str |
6011
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | """ |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(bool(txt)) |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | def getData(self): |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | """ |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | Public method to get the entered data. |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | |
6795
6e2ed2aac325
PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6782
diff
changeset
|
60 | @return tuple with the list of package specifications and a flag |
6e2ed2aac325
PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6782
diff
changeset
|
61 | indicating to install to the user install directory |
6e2ed2aac325
PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6782
diff
changeset
|
62 | @rtype tuple of (list of str, bool) |
6011
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | """ |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | packages = [p.strip() for p in self.packagesEdit.text().split()] |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | |
6342
c79ecba9cde7
pip Interface: changed to use the new VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6327
diff
changeset
|
66 | return ( |
c79ecba9cde7
pip Interface: changed to use the new VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6327
diff
changeset
|
67 | packages, |
c79ecba9cde7
pip Interface: changed to use the new VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6327
diff
changeset
|
68 | self.userCheckBox.isChecked() |
c79ecba9cde7
pip Interface: changed to use the new VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6327
diff
changeset
|
69 | ) |