text: #! /usr/bin/python
  
  ## \file  example_simple.py
  #  \brief A (very simple) example of using the menu system
  #  \author Scott Barlow
  #  \date 2009
  #  \version 1.0.0
  #
  #  An example script to create a window and explore some of the features of the
  #  menu class I've created.  This script just creates a very simple menu for
  #  users that just want to see a plain and simply menu.  This could be made even
  #  more simple, but I keep some features I deem "essential" (such as
  #  non-blocking code and only updating the portion of the screen that changed).
  #
  #
  #       Copyright 2009 Scott Barlow
  #
  #       This program is free software; you can redistribute it and/or modify
  #       it under the terms of the GNU General Public License as published by
  #       the Free Software Foundation; either version 3 of the License, or
  #       (at your option) any later version.
  #
  #       This program is distributed in the hope that it will be useful,
  #       but WITHOUT ANY WARRANTY; without even the implied warranty of
  #       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  #       GNU General Public License for more details.
  #
  #       You should have received a copy of the GNU General Public License
  #       along with this program; if not, write to the Free Software
  #       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  #       MA 02110-1301, USA or see <http://www.gnu.org/licenses/>.
  #
  #
  #  Changelog
  #     V1.0.0 - Initial Release
  #     V1.0.1 - No change to this file
  #     V1.0.2 - No change to this file
  #     V1.0.3 - No change to this file
  #
  
  
  #-------------------------------------------------------------------------------
  #---[ Imports ]-----------------------------------------------------------------
  #-------------------------------------------------------------------------------
  import sys, pygame
  from menu import *
  
  
  ## ---[ main ]------------------------------------------------------------------
  #  This function runs the entire screen and contains the main while loop
  #
  def main():
     # Initialize Pygame
     pygame.init()
  
     # Create a window of 800x600 pixels
     screen = pygame.display.set_mode((800, 600))
  
     # Set the window caption
     pygame.display.set_caption("Menu Example - (c) Scott Barlow")
  
     # Create 3 diffrent menus.  One of them is only text, another one is only
     # images, and a third is -gasp- a mix of images and text buttons!  To
     # understand the input factors, see the menu file
     menu = cMenu(50, 50, 20, 5, 'vertical', 100, screen,
                 [('Start Game', 1, None),
                  ('Load Game',  2, None),
                  ('Options',    3, None),
                  ('Exit',       4, None)])
  
     # Center the menu on the draw_surface (the entire screen here)
     menu.set_center(True, True)
  
     # Center the menu on the draw_surface (the entire screen here)
     menu.set_alignment('center', 'center')
  
     # Create the state variables (make them different so that the user event is
     # triggered at the start of the "while 1" loop so that the initial display
     # does not wait for user input)
     state = 0
     prev_state = 1
  
     # rect_list is the list of pygame.Rect's that will tell pygame where to
     # update the screen (there is no point in updating the entire screen if only
     # a small portion of it changed!)
     rect_list = []
  
     # Ignore mouse motion (greatly reduces resources when not needed)
     pygame.event.set_blocked(pygame.MOUSEMOTION)
  
     # The main while loop
     while 1:
        # Check if the state has changed, if it has, then post a user event to
        # the queue to force the menu to be shown at least once
        if prev_state != state:
           pygame.event.post(pygame.event.Event(EVENT_CHANGE_STATE, key = 0))
           prev_state = state
  
        # Get the next event
        e = pygame.event.wait()
  
        # Update the menu, based on which "state" we are in - When using the menu
        # in a more complex program, definitely make the states global variables
        # so that you can refer to them by a name
        if e.type == pygame.KEYDOWN or e.type == EVENT_CHANGE_STATE:
           if state == 0:
              rect_list, state = menu.update(e, state)
           elif state == 1:
              print('Start Game!')
              state = 0
           elif state == 2:
              print('Load Game!')
              state = 0
           elif state == 3:
              print('Options!')
              state = 0
           else:
              print('Exit!')
              pygame.quit()
              sys.exit()
  
        # Quit if the user presses the exit button
        if e.type == pygame.QUIT:
           pygame.quit()
           sys.exit()
  
        # Update the screen
        pygame.display.update(rect_list)
  
  
  ## ---[ The python script starts here! ]----------------------------------------
  # Run the script
  if __name__ == "__main__":
     main()
  
  
  #---[ END OF FILE ]-------------------------------------------------------------
  