Extending PyQT4 text editor
Adding more features using PyQT4 widgets
No we will add two features to our editor. This will train our docs searching skills :nice:.Disabled "Save" button
When there is no open file, or no changes the "Save" button should be disabled. In QTDesigner in the Property Editor we can set "enabled" attribute to "False" to disable the button.
Inherits QAbstractButton.
pushButton class inherits QAbstractButton and has its methods. When we go to QAbstractButton docs we wont see any method related to "enabled", but QAbstractButton inherits QWidget, and QWidget has setEnabled() method. So here is the start.py file:
I've added the slot with signal connection:
QtCore.QObject.connect(self.ui.editor_window,QtCore.SIGNAL("textChanged()"), self.enable_save)
In the file_dialog slot when we add text to the textEdit from file the "textChanged()" signal will be emitted so we have disable the "Save" button after it:
An the "Save" button will work as planned.Save od Discard changes
When we want to open a file and we didn't saved changes to the current open file a message box should appear asking what to do about those changes - Save, Discard, Cancel. We will use QMessageBox. Go show it we need only:

Download
Download sourcesNote: to get English names on the buttons regenerate "edytor.py" class using "edytorEN.ui" and run the application using "startEN.py"
RkBlog