add optional default value to text dialog

This commit is contained in:
ThomasV 2014-04-03 15:36:31 +02:00
parent a194edbefb
commit 2be8c7f7ed
1 changed files with 3 additions and 1 deletions

View File

@ -57,7 +57,7 @@ def ok_cancel_buttons(dialog, ok_label=_("OK") ):
b.setDefault(True)
return hbox
def text_dialog(parent, title, label, ok_label):
def text_dialog(parent, title, label, ok_label, default=None):
dialog = QDialog(parent)
dialog.setMinimumWidth(500)
dialog.setWindowTitle(title)
@ -66,6 +66,8 @@ def text_dialog(parent, title, label, ok_label):
dialog.setLayout(l)
l.addWidget(QLabel(label))
txt = QTextEdit()
if default:
txt.setText(default)
l.addWidget(txt)
l.addLayout(ok_cancel_buttons(dialog, ok_label))
if dialog.exec_():