def _build_multi_line_editor(self, modify_callback, current_name): w = QPlainTextEdit() p = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum) w.setSizePolicy(p) w.setPlainText(self._v) """ def changed(): nv = w.toPlainText() self._v = nv modify_callback(current_name, self, w) w.focusOutEvent.connect(changed) """ org = w.focusOutEvent def stub(event): org(event) nv = w.toPlainText() self._v = nv modify_callback(current_name, self, w) w.focusOutEvent = stub return w
def focusOutEvent(self, event): self.editingFinished.emit() QPlainTextEdit.focusOutEvent(self, event)