ProjectDjangoTagsMenu/MultiLineInputDialog.py

Wed, 21 Sep 2022 16:38:40 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 21 Sep 2022 16:38:40 +0200
branch
eric7
changeset 63
85418cf03fdb
parent 60
85d3931419d3
child 69
9acb6987ce60
permissions
-rw-r--r--

Reformatted source code with 'Black'.

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

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