PipxInterface/PipxPackagesInputDialog.py

Sun, 29 Dec 2024 14:56:04 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 29 Dec 2024 14:56:04 +0100
changeset 121
8deb7d8d9b86
parent 104
45c88e73e3dd
permissions
-rw-r--r--

Prepared a new release.

# -*- coding: utf-8 -*-

# Copyright (c) 2024 - 2025 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, parent=None):
        """
        Constructor

        @param title dialog title
        @type str
        @param parent reference to the parent widget
        @type QWidget
        """
        super().__init__(parent)
        self.setupUi(self)

        self.setWindowTitle(title)

        self.fetchMissingCheckBox.setChecked(True)

        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)
        """
        return (
            [p.strip() for p in self.packagesEdit.text().split()],
            self.interpreterVersionEdit.text().strip(),
            self.fetchMissingCheckBox.isChecked(),
            self.forceCheckBox.isChecked(),
            self.systemSitePackagesCheckBox.isChecked(),
        )

eric ide

mercurial