diff -r 02b45cd11e64 -r 2ab7d3ac8283 PipxInterface/PipxPackagesInputDialog.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PipxInterface/PipxPackagesInputDialog.py Wed Jun 26 18:40:48 2024 +0200 @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2024 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module implementing a dialog to enter package specifications. +""" + +from PyQt6.QtCore import pyqtSlot +from PyQt6.QtWidgets import QDialog, QDialogButtonBox + +from .Ui_PipxPackagesInputDialog import Ui_PipxPackagesInputDialog + + +class PipxPackagesInputDialog(QDialog, Ui_PipxPackagesInputDialog): + """ + Class implementing a dialog to enter package specifications and installation + options. + """ + + def __init__(self, title, install=True, parent=None): + """ + Constructor + + @param title dialog title + @type str + @param install flag indicating an install action + @type bool + @param parent reference to the parent widget + @type QWidget + """ + super().__init__(parent) + self.setupUi(self) + + self.setWindowTitle(title) + + self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) + + msh = self.minimumSizeHint() + self.resize(max(self.width(), msh.width()), msh.height()) + + @pyqtSlot(str) + def on_packagesEdit_textChanged(self, txt): + """ + Private slot handling entering package names. + + @param txt name of the requirements file + @type str + """ + self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(bool(txt)) + + def getData(self): + """ + Public method to get the entered data. + + @return tuple with the list of package specifications, the desired Python + interpreter version, a flag indicating to fetch a missing interpreter + from GitHub, a flag indicating to force the installation and a flag + indicating to give access to the system site-packages directory. + @rtype tuple of (list of str, str, bool, bool, bool) + """ + packages = [p.strip() for p in self.packagesEdit.text().split()] + + return ( + packages, + self.interpreterVersionEdit.text().strip(), + self.fetchMissingCheckBox.isChecked(), + self.forceCheckBox.isChecked(), + self.systemSitePackagesCheckBox.isChecked(), + )