ProjectDjangoTagsMenu/MultiLineInputDialog.py

Sat, 31 Dec 2022 16:27:48 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 31 Dec 2022 16:27:48 +0100
branch
eric7
changeset 69
9acb6987ce60
parent 63
85418cf03fdb
child 70
ce1c2effa0e0
permissions
-rw-r--r--

Updated copyright for 2023.

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

# Copyright (c) 2014 - 2023 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)
        dlg.setWindowTitle(title)
        if dlg.exec() == QDialog.DialogCode.Accepted:
            return dlg.getData(), True
        else:
            return "", False

eric ide

mercurial