def __init__(self, editor, parent=None): super(HighlightedTextEditDialog, self).__init__(parent) self.editor = editor self.textEdit = HighlightedTextEdit() self.textEdit.setCode(editor.getCode()) self.textEdit.installEventFilter(self) okButton = QtGui.QPushButton("&OK") okButton.clicked.connect(self.updateText) cancelButton = QtGui.QPushButton("&Cancel") cancelButton.clicked.connect(self.reject) buttonLayout = QtGui.QHBoxLayout() buttonLayout.addStretch(1) buttonLayout.addWidget(okButton) buttonLayout.addWidget(cancelButton) layout = QtGui.QVBoxLayout() layout.addWidget(self.textEdit) layout.addLayout(buttonLayout) self.setLayout(layout)
def createWidget(self, parent): widget = HighlightedTextEdit(parent) # We install an event filter on the text editor to prevent the # contents from being modified outside the custom editor dialog. widget.installEventFilter(self) return widget
def __init__(self, editor, parent=None): QtGui.QDialog.__init__(self, parent) self.editor = editor self.textEdit = HighlightedTextEdit() self.textEdit.setCode(editor.getCode()) self.textEdit.installEventFilter(self) okButton = QtGui.QPushButton("&OK") cancelButton = QtGui.QPushButton("&Cancel") self.connect(okButton, QtCore.SIGNAL("clicked()"), self.updateText) self.connect(cancelButton, QtCore.SIGNAL("clicked()"), self, QtCore.SLOT("reject()")) buttonLayout = QtGui.QHBoxLayout() buttonLayout.addStretch(1) buttonLayout.addWidget(okButton) buttonLayout.addWidget(cancelButton) layout = QtGui.QVBoxLayout() layout.addWidget(self.textEdit) layout.addLayout(buttonLayout) self.setLayout(layout)