|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2014 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog for the input of multi line text. |
|
8 """ |
|
9 |
|
10 from PyQt4.QtGui import QDialog |
|
11 |
|
12 from .Ui_MultiLineInputDialog import Ui_MultiLineInputDialog |
|
13 |
|
14 |
|
15 class MultiLineInputDialog(QDialog, Ui_MultiLineInputDialog): |
|
16 """ |
|
17 Class implementing a dialog for the input of multi line text. |
|
18 """ |
|
19 def __init__(self, label, default, parent=None): |
|
20 """ |
|
21 Constructor |
|
22 |
|
23 @param label label for the entry field (string) |
|
24 @param default default value for the entry field (string) |
|
25 @param parent reference to the parent widget (QWidget) |
|
26 """ |
|
27 super(MultiLineInputDialog, self).__init__(parent) |
|
28 self.setupUi(self) |
|
29 |
|
30 def getData(self): |
|
31 """ |
|
32 Public method to retrieve the multi line text. |
|
33 |
|
34 @return multi line text (string) |
|
35 """ |
|
36 return self.multiLineEdit.toPlainText() |
|
37 |
|
38 @staticmethod |
|
39 def getText(parent, title, label, default=""): |
|
40 """ |
|
41 Static method to create the dialog and return the multi line text. |
|
42 |
|
43 @param parent reference to the parent widget (QWidget) |
|
44 @param title title of the dialog (string) |
|
45 @param label label for the entry field (string) |
|
46 @param default default value for the entry field (string) |
|
47 @return multi line text (string) and a flag indicating the acceptance |
|
48 state (boolean) |
|
49 """ |
|
50 dlg = MultiLineInputDialog(label, default, parent) |
|
51 dlg.setWindowTitle(title) |
|
52 if dlg.exec_() == QDialog.Accepted: |
|
53 return dlg.getData(), True |
|
54 else: |
|
55 return "", False |