ProjectDjangoTagsMenu/MultiLineInputDialog.py

Tue, 10 Dec 2024 15:48:58 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 10 Dec 2024 15:48:58 +0100
branch
eric7
changeset 74
a25b858e18a7
parent 72
529f1c17c93e
permissions
-rw-r--r--

Updated copyright for 2025.

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

# Copyright (c) 2014 - 2025 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing a dialog for the input of multi line text.
"""

from PyQt6.QtWidgets import QDialog

from .Ui_MultiLineInputDialog import Ui_MultiLineInputDialog


class MultiLineInputDialog(QDialog, Ui_MultiLineInputDialog):
    """
    Class implementing a dialog for the input of multi line text.
    """

    def __init__(self, label, default, parent=None):
        """
        Constructor

        @param label label for the entry field
        @type str
        @param default default value for the entry field
        @type str
        @param parent reference to the parent widget
        @type QWidget
        """
        super().__init__(parent)
        self.setupUi(self)

    def getData(self):
        """
        Public method to retrieve the multi line text.

        @return multi line text
        @rtype str
        """
        return self.multiLineEdit.toPlainText()

    @staticmethod
    def getText(parent, title, label, default=""):
        """
        Public static method to create the dialog and return the multi line
        text.

        @param parent reference to the parent widget
        @type QWidget
        @param title title of the dialog
        @type str
        @param label label for the entry field
        @type str
        @param default default value for the entry field
        @type str
        @return multi line text and a flag indicating the acceptance state
        @rtype tuple of (str, bool)
        """
        dlg = MultiLineInputDialog(label, default, parent=parent)
        dlg.setWindowTitle(title)
        if dlg.exec() == QDialog.DialogCode.Accepted:
            return dlg.getData(), True
        else:
            return "", False

eric ide

mercurial