ProjectDjangoTagsMenu/MultiLineInputDialog.py

Mon, 28 Oct 2024 16:51:09 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 28 Oct 2024 16:51:09 +0100
branch
eric7
changeset 72
529f1c17c93e
parent 70
ce1c2effa0e0
child 74
a25b858e18a7
permissions
-rw-r--r--

- changed to the new style header
- ensured proper parent relationship of modal dialogs
- included compiled form files

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

# Copyright (c) 2014 - 2024 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