Click here to Skip to main content
15,868,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm making a text editor with PyQt5 and I get a weird error from the save dialog. When I close the application, it scans for any unsaved changes and if there are it will bring up the 'save or discard changes' dialog. It works fine, but I get a weird error saying TypeError: closeEvent() missing 1 required positional argument: 'event'. Here's my code for the save and discard changes dialog:
Python
def closeEvent(self, event):
    if self.text == self.textEdit.toPlainText():
        messageBox = QMessageBox()
        title = "Quit Application?"
        message = "Save changes to this file?\n\nWould you like to save changes, or discard them?"

        reply = messageBox.question(self, title, message, messageBox.Yes | messageBox.No | messageBox.Cancel)
        if reply == messageBox.Yes:
            return_value = self.Save_File()
            if return_value == messageBox.Cancel:
                event.ignore()
        elif reply == messageBox.No:
            event.accept()
        else:
            event.ignore()

How can I stop the error?

What I have tried:

I've tried searching for this, but I got no answers
Posted
Comments
Richard MacCutchan 30-Sep-21 4:12am    
Where does the error message occur (i.e. on which line)?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900