Package pytsonui :: Module dialogs
[hide private]
[frames] | no frames]

Source Code for Module pytsonui.dialogs

 1  from PythonQt.QtGui import (QDialog, QVBoxLayout, QHBoxLayout, QLabel, 
 2                              QLineEdit, QDialogButtonBox) 
3 4 5 -class MultiInputDialog(QDialog):
6 - def __init__(self, title, label1, label2, parent=None):
7 super().__init__(parent) 8 self.setWindowTitle(title) 9 self.lay = QVBoxLayout(self) 10 11 self.lay1 = QHBoxLayout() 12 self.label1 = QLabel(label1, self) 13 self.lay1.addWidget(self.label1) 14 self.input1 = QLineEdit(self) 15 self.lay1.addWidget(self.input1) 16 self.lay.addLayout(self.lay1) 17 18 self.lay2 = QHBoxLayout() 19 self.label2 = QLabel(label2, self) 20 self.lay2.addWidget(self.label2) 21 self.input2 = QLineEdit(self) 22 self.lay2.addWidget(self.input2) 23 self.lay.addLayout(self.lay2) 24 25 bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, 26 self) 27 bbox.connect("accepted()", self.accept) 28 bbox.connect("rejected()", self.reject) 29 self.lay.addWidget(bbox)
30
31 - def cleanup(self):
32 self.lay1.delete() 33 self.lay2.delete()
34 35 @staticmethod
36 - def getTexts(title, label1, label2, text1="", text2="", parent=None):
37 dlg = MultiInputDialog(title, label1, label2, parent) 38 39 dlg.label1.setText(label1) 40 dlg.input1.setText(text1) 41 dlg.label2.setText(label2) 42 dlg.input2.setText(text2) 43 44 if dlg.exec_() == QDialog.Accepted: 45 ret1 = dlg.input1.text 46 ret2 = dlg.input2.text 47 48 dlg.cleanup() 49 dlg.delete() 50 51 return (True, ret1, ret2) 52 else: 53 return (False, "", "")
54