Python Forum

Full Version: Error message box and quit app
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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) 
import sys st start of script
after line 10 add sys.exit(-1)