Page 342 -
P. 342

exceptions and message boxes






                                                The folks at Head-Ex want your program to display this message
                                                box if there’s a problem saving a record to the
                                                deliveries.txt file:















               Complete the missing lines in this section of your program to create the message box.
               Hint: You need to include a newline in the message box text.


                            from tkinter import *



                            def save_data():
                                try:
                                    fileD = open("deliveries.txt", "a")
                                    fileD.write("Depot:\n")
                                    fileD.write("%s\n" % depot.get())
                                    fileD.write("Description:\n")
                                    fileD.write("%s\n" % description.get())
                                    fileD.write("Address:\n")
                                    fileD.write("%s\n" % address.get("1.0", END))
                                    depot.set("")
                                    description.delete(0, END)
                                    description.delete(0, END)
                                    address.delete("1.0", END)
                                except Exception as ex:










                                                                                       you are here 4    307
   337   338   339   340   341   342   343   344   345   346   347