I have a button that writes output to a file. And checks if the file with that filename already exists. It is supposed to ask the user to override or not? But it is not working. If the user says No, then the program will still override the file.
This is the code to pop up the MessageBox:
if os.path.exists(self.filename.get()):
tkMessageBox.showinfo('INFO', 'File already exists, want to override?.')
You need to use a dialog that has yes/no or ok/cancel buttons, and you need to capture the return value of that dialog to know what the user clicked on. From that you can then decide whether to write to the file or not.
For example:
effbot.org has a nice little writeup on standard dialogs