Page 346 -
P. 346

exceptions and message boxes


                              Your Programming Toolbox


                               You’ve got Chapter 8.5 under
                               your belt. Let’s look back at what
                               you’ve learned in this chapter:                                                  CHAPTER 8.5



        Programming T ools
        * Some errors don't crash your program - they


         throw exceptions instead.
         * You can run code when there's an exception -
          this is called “catching the exception.”
          * Code that runs because of an exception is
                                                           Python T ools
           called an exception handler.
           * GUI message boxes display information and ask
                                                          block.
            * Message boxes are also known as “dialog boxes.”
                                                          * You can catch exceptions by using a try/except
            questions.                                   * “except Exception as ex" will assign the exception

             * Message boxes require the user to respond, even  message to a variable called “ex".
              if it is just to click an OK button.
                                                        formatting it as a string.
                                                        * You can display the exception error message by


                                                      “tkinter.messagebox” module.
                                                       * T o display message boxes, you need to import the
                                                      called “show...()".
                                                      * Message boxes that display information are all

                                                    “ask...()".
                                                     * Message boxes that ask questions are all called
                                                    Yes, or Retry.
                                                    * Message boxes return True if the response was OK,


                                                   * Message boxes return False if the response was No.
                                                  Cancel.
                                                  * Message boxes return None if the response was






                                                                                       you are here 4    311
   341   342   343   344   345   346   347   348   349   350   351