Error message box and quit app - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: Error message box and quit app (/thread-26943.html) |
Error message box and quit app - Kumarkv - May-19-2020 Hi, I am doing a callback on OptionMenu. as per the below code when the condition if source == destination then i would like to generate an error message box and don't proceed for further processing. I did root.destroy() but its creating an empty tk window and the processing won't stop. Please guide me. def callback(self,*args): source = self.frm.pathe1.get() dest = self.frm.pathe2.get() ext = self.frm.extoption.get() print("User selected input path: ",source) print("User selected destination path: ", dest) print("User selected extension type: ", ext) if source == dest: messagebox.showinfo("Title","Destination path can not be same as Input path") root.destroy() pattern = str("*." + self.frm.extoption.get()) dest = dest + "/" + ext print("Files will be copied to: ", dest) if os.path.isdir(dest) == True: shutil.rmtree(dest) p = App1.include_patterns(pattern) shutil.copytree(source,dest,ignore=p) messagebox.showinfo("Files move based on extension","Desired extension files copied to: " + dest) RE: Error message box and quit app - Larz60+ - May-19-2020 import sys st start of scriptafter line 10 add sys.exit(-1)
|