--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PipxInterface/PipxSpecInputDialog.py Wed Jun 26 18:40:48 2024 +0200 @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2024 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module implementing a dialog to enter the data for an 'install-all' operation. +""" + +import os + +from PyQt6.QtCore import pyqtSlot +from PyQt6.QtWidgets import QDialog, QDialogButtonBox + +from eric7.EricWidgets.EricPathPicker import EricPathPickerModes + +from .Ui_PipxSpecInputDialog import Ui_PipxSpecInputDialog + + +class PipxSpecInputDialog(QDialog, Ui_PipxSpecInputDialog): + """ + Class implementing a dialog to enter the data for an 'install-all' operation. + """ + + def __init__(self, title, parent=None): + """ + Constructor + + @param title dialog title + @type str + @param parent reference to the parent widget (defaults to None) + @type QWidget (optional) + """ + super().__init__(parent) + self.setupUi(self) + + self.setWindowTitle(title) + self.specFilePicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) + + self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) + + msh = self.minimumSizeHint() + self.resize(max(self.width(), msh.width()), msh.height()) + + @pyqtSlot(str) + def on_specFilePicker_textChanged(self, txt): + """ + Private slot handling entering a file path. + + @param txt path of the spec metadata file + @type str + """ + self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( + bool(txt) and os.path.isfile(txt) + ) + + def getData(self): + """ + Public method to get the entered data. + + @return tuple with the file path of the spec metadata file, 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) + """ + return ( + self.specFilePicker.text(), + self.interpreterVersionEdit.text().strip(), + self.fetchMissingCheckBox.isChecked(), + self.forceCheckBox.isChecked(), + self.systemSitePackagesCheckBox.isChecked(), + )