def _initUI(self, values): self.setWindowTitle("Task Editor") vbox = QtGui.QVBoxLayout() self._label = QtGui.QLabel("Task:") vbox.addWidget(self._label) self._edit = AutoCompleteEdit(values) vbox.addWidget(self._edit) hbox = QtGui.QHBoxLayout() okButton = QtGui.QPushButton("Ok") okButton.clicked.connect(self.accept) cancelButton = QtGui.QPushButton("Cancel") cancelButton.clicked.connect(self.reject) hbox.addStretch(1) hbox.addWidget(okButton) hbox.addWidget(cancelButton) vbox.addLayout(hbox) self.setLayout(vbox) self.resize(500, 100)
class AutoCompleteInputDialog(QtGui.QDialog): def __init__(self, values, parent=None): super(AutoCompleteInputDialog, self).__init__(parent) self._initUI(values) def _initUI(self, values): self.setWindowTitle("Task Editor") vbox = QtGui.QVBoxLayout() self._label = QtGui.QLabel("Task:") vbox.addWidget(self._label) self._edit = AutoCompleteEdit(values) vbox.addWidget(self._edit) hbox = QtGui.QHBoxLayout() okButton = QtGui.QPushButton("Ok") okButton.clicked.connect(self.accept) cancelButton = QtGui.QPushButton("Cancel") cancelButton.clicked.connect(self.reject) hbox.addStretch(1) hbox.addWidget(okButton) hbox.addWidget(cancelButton) vbox.addLayout(hbox) self.setLayout(vbox) self.resize(500, 100) def textValue(self): return self._edit.text() def setTextValue(self, text): self._edit.setText(text) def setLabelText(self, text): self._label.setText(text)