Tue, 10 Dec 2024 15:46:34 +0100
Updated copyright for 2025.
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 | |
11090
f5f5f5803935
Updated copyright for 2025.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10690
diff
changeset
|
3 | # Copyright (c) 2015 - 2025 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 | |
8318
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
10 | from PyQt6.QtCore import pyqtSlot |
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
11 | from PyQt6.QtWidgets import QDialog, QDialogButtonBox |
6011
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | 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
|
14 | |
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 | 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
|
17 | """ |
6047
39586a2de99d
Fixed some forgotten source code documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6011
diff
changeset
|
18 | 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
|
19 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
20 | |
10690
fab36645aa7d
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
21 | def __init__(self, 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 |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
24 | |
6327
a1716d9210f4
pip Interface: started to add support for the '--user' option.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6301
diff
changeset
|
25 | @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
|
26 | @type str |
a1716d9210f4
pip Interface: started to add support for the '--user' option.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6301
diff
changeset
|
27 | @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
|
28 | @type bool |
a1716d9210f4
pip Interface: started to add support for the '--user' option.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6301
diff
changeset
|
29 | @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
|
30 | @type QWidget |
6011
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | """ |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
32 | super().__init__(parent) |
6011
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | self.setupUi(self) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
34 | |
6011
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | self.setWindowTitle(title) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
36 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
37 | self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
38 | |
6327
a1716d9210f4
pip Interface: started to add support for the '--user' option.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6301
diff
changeset
|
39 | self.userCheckBox.setVisible(install) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
40 | |
6011
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | msh = self.minimumSizeHint() |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | self.resize(max(self.width(), msh.width()), msh.height()) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
43 | |
6011
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | @pyqtSlot(str) |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | 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
|
46 | """ |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | Private slot handling entering package names. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
48 | |
6342
c79ecba9cde7
pip Interface: changed to use the new VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6327
diff
changeset
|
49 | @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
|
50 | @type str |
6011
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
52 | self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(bool(txt)) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
53 | |
6011
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | def getData(self): |
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 | Public method to get the entered data. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
57 | |
6795
6e2ed2aac325
PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6782
diff
changeset
|
58 | @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
|
59 | 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
|
60 | @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
|
61 | """ |
e6af0dcfbb35
Added the pip interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | packages = [p.strip() for p in self.packagesEdit.text().split()] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
63 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
64 | return (packages, self.userCheckBox.isChecked()) |