Python Forum
Error message box and quit app
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error message box and quit app
#1
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) 
Reply
#2
import sys st start of script
after line 10 add sys.exit(-1)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  keep gui open if I use "quit" flash77 2 906 Aug-24-2023, 01:27 PM
Last Post: deanhystad
  [PyQt] error message the_wolf_dz 4 2,041 Oct-24-2022, 07:24 PM
Last Post: deanhystad
  [Tkinter] How to make message box error stay on top of window scratchmyhead 1 8,288 May-10-2020, 10:21 PM
Last Post: scratchmyhead
  [PyQt] No reaction and no error message when clicking button Atalanttore 4 4,826 Nov-23-2018, 01:48 PM
Last Post: Atalanttore
  [PyQt] error message in pyqt pro red_man_008 8 7,362 Aug-13-2017, 08:50 PM
Last Post: red_man_008

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020