def file_save(self): name = QtGui.QFileDialog.getSaveFileName(self, 'Save File') file = open(name,'w') text = self.textEdit.toPlainText() file.write(text) file.close()
Here is what the above code is Doing:
1. We create a class called Main which inherits from QtGui.QMainWindow.
2. We create a method called __init__ which is the constructor of the class.
3. We create a method called initUI which is responsible for creating the GUI.
4. We create a method called file_save which is responsible for saving the file.