ProjectDjangoTagsMenu/MultiLineInputDialog.py

Mon, 10 Feb 2014 19:21:55 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 10 Feb 2014 19:21:55 +0100
changeset 10
ef5694c0bf3a
parent 9
1b11bf54b3b2
child 23
070a6c65c8a9
permissions
-rw-r--r--

Implemented the 'internatinalization' menu and some Python2 compatibility changes.

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

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

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

from __future__ import unicode_literals    # __IGNORE_WARNING__

from PyQt4.QtGui 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 (string)
        @param default default value for the entry field (string)
        @param parent reference to the parent widget (QWidget)
        """
        super(MultiLineInputDialog, self).__init__(parent)
        self.setupUi(self)
    
    def getData(self):
        """
        Public method to retrieve the multi line text.
        
        @return multi line text (string)
        """
        return self.multiLineEdit.toPlainText()
    
    @staticmethod
    def getText(parent, title, label, default=""):
        """
        Static method to create the dialog and return the multi line text.
        
        @param parent reference to the parent widget (QWidget)
        @param title title of the dialog (string)
        @param label label for the entry field (string)
        @param default default value for the entry field (string)
        @return multi line text (string) and a flag indicating the acceptance
            state (boolean)
        """
        dlg = MultiLineInputDialog(label, default, parent)
        dlg.setWindowTitle(title)
        if dlg.exec_() == QDialog.Accepted:
            return dlg.getData(), True
        else:
            return "", False

eric ide

mercurial