
xMZc           @   s@  d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l Z e j d d f k r d  d l m Z m Z m	 Z	 m
 Z
 m Z m Z d  d l m Z m Z m Z m Z m Z m Z m Z d  d l m Z d  d l m Z n@ d  d l m Z m Z m	 Z	 m
 Z
 m Z d  d l Z d  d l Z d	 f  d
     YZ d f  d     YZ d S(   iNi   i    (   t   Canvast   Labelt   Menut
   PhotoImaget   Tkt   TclError(   t   BOTTOMt   LEFTt   RIGHTt   TOPt   Wt   NWt   SW(   t
   filedialog(   t
   messagebox(   R   R    R   R   R   t   DrawingPanelc           B   s{  e  Z d  Z e d    Z e d    Z e d    Z d d d d  Z d   Z d   Z	 d	   Z
 d
 d  Z d d  Z d   Z d   Z d   Z d d  Z d d d  Z d d  Z d d  Z d d  Z d   Z d   Z d d  Z d d  Z d d d  Z d d  Z d d  Z d   Z d d   Z d d d!  Z e d"    Z  d#   Z! e d$    Z" d%   Z# e d&    Z$ d'   Z% e d(    Z& d)   Z' e d*    Z( d+   Z) e d,    Z* d-   Z+ e d.    Z, d/   Z- e d0    Z. d1   Z/ e d2    Z0 d3   Z1 d4   Z2 d5   Z3 e d6    Z4 d7   Z5 e d8    Z6 d9   Z7 e d:    Z8 d;   Z9 e d<    Z: d=   Z; e d>    Z< d?   Z= e d@    Z> dA   Z? e dB    Z@ dC   ZA e dD    ZB dE   ZC e dF    ZD dG   ZE dH   ZF dI   ZG e dJ    ZH dK   ZI e dL    ZJ dM   ZK dN dO  ZL dP dQ  ZM dR dS  ZN dT   ZO dU   ZP dV   ZQ e  jR dW    Z  dX   ZS e$ jR dY    Z$ dZ   ZT e& jR d[    Z& d\   ZU e( jR d]    Z( d^   ZV e* jR d_    Z* d`   ZW e, jR da    Z, db   ZX e. jR dc    Z. dd   ZY e0 jR de    Z0 df   ZZ eH jR dg    ZH dh   Z[ e4 jR di    Z4 dj   Z\ dk   Z] e6 jR dl    Z6 dm   Z^ e: jR dn    Z: do   Z_ e8 jR dp    Z8 dq   Z` eJ jR dr    ZJ ea ds  Zb e< jR dt    Z< du   Zc eB jR dv    ZB dw   Zd eD jR dx    ZD dy   Ze dz   Zf d{   Zg RS(|   s  
    A DrawingPanel object represents a simple interface for creating
    graphical windows in Python for drawing shapes, lines, images, and colors.
    The DrawingPanel also supports getting and setting the RGB values of individual
    pixels, which makes it useful for learning about various looping and 2D list-
    processing algorithms.

    See PyDoc comments for individual functions below for more information.

    This library is based on Python's Tkinter GUI system.
    In particular, the drawing surface used by DrawingPanel is a Tkinter Canvas object,
    and many of our functions are wrappers around Tkinter Canvas functions.
    
    The DrawingPanel supports properties like color, background, width, height, etc.
    that can be accessed/modified either using traditional methods like get_color and set_background,
    or as properties named color or background.
    
    @author: Marty Stepp, Stanford University
    @author: Allison Obourn, University of Arizona
    @author: Stuart Reges, University of Washington

    @version: 2018/02/28
    
    @copyright: Marty Stepp, Allison Obourn, Stuart Reges; for individual, educational, non-commercial, private use only; all other rights reserved.

    @see: http://effbot.org/tkinterbook/canvas.htm
    c         C   s   |  S(   sn   
        Converts between a single 0-based client coordinate and a 1-based Tkinter canvas coordinate.
        (    (   t   coord(    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   __adjust_coordinatep   s    c          G   s   d } |  d k s$ t |   d k r- t  n& t |  d t  rM |  d } n |  } | d k rc | St g  | D] } | | ^ qm  Sd S(   s|   
        Converts between a list/tuple of 0-based client coordinates and one of 1-based Tkinter canvas coordinates.
        i    N(   t   Nonet   lent
   ValueErrort
   isinstancet   tuple(   t   coordst   ADJUST_AMOUNTt   coords_to_useR   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   __adjust_coordinatesx   s    	c         C   s   |  S(   sj   
        Converts between a single 1-based client mouse coordinate and a 0-based code coordinate.
        (    (   R   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   __adjust_mouse_coordinate   s    i  t   whitec            s  d   _  d   _ d   _ t   _ t |     _   j j     j | |  d   _	 d   _
   j j d  d#   _ g    _ t     _ t   j d | d | d d d d d	 d
   _ |   j d <  j j d t    j j d   f d      j j d   f d      j j d   f d      j j d   f d    t   j d d d t d t   _   j j d t d t  t   j  } t | d d } | j d d d   j  | j   | j d d d   j j  | j  d d d |  t | d d } | j d d  d   j!  | j  d d! d |    j j" d |    j j#     j j$     j%     j j&   t' t( d"  s  j)   n  d# S($   s.  
        Constructs a panel of a given width, height, and optional background color.
        
        Parameters:
        @param width: (optional) width of the DrawingPanel central canvas area in pixels (default 500)
        @param height: (optional) height of the DrawingPanel central canvas area in pixels (default 500)
        @param background: (optional) background color of the DrawingPanel canvas area (default "white")
        @param options: (optional) keyword arguments to pass directly to Tk window constructor (see Tkinter documentation)
        i    i   t   blackR   t   widtht   heightt   bdt   highlightthicknesst   relieft   ridget   bgt   sides   <Motion>c            s     j  |   S(   N(   t#   _DrawingPanel__callback_mouse_moved(   t   event(   t   self(    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   <lambda>   s    s   <Key>c            s     j  |   S(   N(   t#   _DrawingPanel__callback_key_pressed(   R'   (   R(   (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR)      s    s   <Escape>c            s
     j    S(   N(   t   close(   R'   (   R(   (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR)      s    s   <Control-s>c            s
     j    S(   N(   t   save_as_dialog(   R'   (   R(   (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR)      s    t   textt    t   anchort   justifyt   tearofft   labels
   Save As...t   commandt   Exitt   Filet   menus   About...t   Helpt   ps1N(*   t   _xt   _yt   _stroket   Truet
   _resizableR   t   _windowt   withdrawt   set_sizet   _fillt   _outlinet   titleR   t   _fontt   _imagest   dictt
   _image_mapR    t   _canvast   packR	   t   bindR   R   R   t   status_labelR   R   t   add_commandR,   t   add_separatort   quitt   add_cascadet   aboutt   configt   update_idletaskst   updatet   centert	   deiconifyt   hasattrt   syst$   _DrawingPanel__install_mainloop_hack(   R(   R   R   t
   backgroundt   optionst   menubart   filemenut   helpmenu(    (   R(   sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   __init__   sL    								0$

c         C   s   d } |  j  | d  d S(   s)   
        Shows an About message.
        s*  DrawingPanel

Graphical library class to support Building Java Programs textbook

written by: Marty Stepp, Stanford University; Allison Obourn, University of Arizona; Stuart Reges, University of Washington

Version: 2018/02/28

please visit our web site at:

http://www.buildingpythonprograms.com/
s   About DrawingPanelN(   t   message(   R(   t   msg(    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyRP      s    c         C   s   d S(   s   
        Private function that is called when keys are pressed.
        Not to be called by students.
        @see: http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm
        @see: http://www.tcl.tk/man/tcl8.4/TkCmd/keysyms.htm
        N(    (   R(   R'   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   __callback_key_pressed   s    c         C   sq   t  j t | j   } t  j t | j   } d | | f } |  j | |  } | d | 7} |  j |  d S(   sp   
        Private function that is called when the mouse is moved.
        Not to be called by students.
        s   (x=%d, y=%d)s   , r=%d, g=%d, b=%dN(   R   t&   _DrawingPanel__adjust_mouse_coordinatet   intt   xt   yt   get_pixel_color_rgbt
   set_status(   R(   R'   Rd   Re   t   new_textt   rgb(    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   __callback_mouse_moved   s    t   pressc         C   sM   | j    d k r d } n | j    d k r6 d } n  |  j j | |  d S(   s  
        Attaches the given function to be called when keyboard events occur in this DrawingPanel window.
        @param function: The function to be called; should accept an event as a parameter.
        @param event_type: (optional) What type of mouse event to respond to. The default is key presses,
        but you can pass any of "press" or "release".
        @see: http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm
        Rk   s   <Key>t   releaseN(   t   lowerR>   RJ   (   R(   t   functiont
   event_type(    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   add_key_listener   s
    		t   clickc         C   sg  | j    d k r d } n5| j    d k r6 d } n| j    d k rQ d } n | j    d k rl d } n | j    d	 k r d
 } n | j    d k r d } n | j    d k r d } n | j    d k r d } nx | j    d k r d } n] | j    d k rd } nB | j    d k rPd } |  j j d |  |  j j d |  d S|  j j | |  d S(   s  
        Attaches the given function to be called when mouse events occur in this DrawingPanel window.
        @param function: The function to be called; should accept an event as a parameter.
        @param event_type: (optional) What type of mouse event to respond to. The default is clicks, but you can pass
        any of "click", "doubleclick", "drag", "enter", "exit", "middleclick", "move", "press", "release", "rightclick", or "wheel".
        @see: http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm
        Rq   s
   <Button-1>t   doubleclicks   <Double-Button-1>t   drags   <B1-Motion>t   enters   <Enter>t   exits   <Leave>t   middleclicks
   <Button-2>t   moves   <Motion>Rk   Rl   s   <ButtonRelease>t
   rightclicks
   <Button-3>t   wheels   <MouseWheel>s   <4>s   <5>N(   Rm   R>   RJ   (   R(   Rn   Ro   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   add_mouse_listener	  s4    										c         C   s   |  j  j   } |  j  j   } |  j  j   } |  j  j   } | | d } | | d } | d k r | d k r |  j | |  n  d S(   s   
        Centers the DrawingPanel window's location on the screen.
        If the DrawingPanel's size is larger than the screen size in either dimension, does not move it.
        i   i    N(   R>   t   winfo_screenwidtht   winfo_screenheightt   winfo_widtht   winfo_heightt   set_location(   R(   t   screenwidtht   screenheightt   mywidtht   myheightt   myxt   myy(    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyRT   ,  s    c      
   C   sg   |  j  j d d |  j d |  j d d |  j  d d |  j  d g  |  _ t   |  _ |  j d  d S(   sZ   
        Erases all shapes from the panel and fills it with its background color.
        i    i   t   outlineR$   t   fillt    N(   RH   t   create_rectanglet   _widtht   _heightRE   RF   RG   Rg   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   clear:  s
    &	c         C   s   |  j  j   d S(   s   
        Closes the DrawingPanel window so it is no longer visible.
        Once it is closed, it cannot be drawn on or shown on screen again during the current run of your program.
        N(   R>   t   destroy(   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR+   D  s    R   c   
      K   s   d | k r1 |  j  d k r1 t |  j   | d <n  |  j | |  j d |  } t j |  t j | |  \ } } d | k r | | d <n  d | k r | | d <n  d | k r d | d <n  | | | | | | f }	 |  j j	 |	 |  d S(	   s  
        Draws an outlined arc (a partial oval).
        The resulting arc begins at 'start_angle' and extends for 'extent' degrees.
        Angles are interpreted such that 0 degrees is at the 3 o'clock position.
        A positive value indicates a counter-clockwise rotation while a negative value indicates a clockwise rotation.
        
        If you want to draw a pie-slice style arc rather than just the outer line, pass an option of style="pieslice".
        
        @param x: left x coordinate of bounding box of arc's oval
        @param y: top y coordinate of bounding box of arc's oval
        @param w: width of bounding box of arc's oval
        @param h: height of bounding box of arc's oval
        @param start_angle: starting angle in degrees, where 0 is at "3 o'clock" position
        @param extent: degrees that the arc should extend from its start, where positive numbers are counter-clockwise and negative values are clockwise
        @param color: (optional) color to use for outline of shape (if absent, uses panel's default color as set via set_color)
        @see: http://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.create_arc-method
        R   i   R   t   startt   extentt   stylet   arcN(
   R;   t   strt&   _DrawingPanel__pick_color_with_defaultRB   t   Colort   normalize_all_colorsR   t!   _DrawingPanel__adjust_coordinatesRH   t
   create_arc(
   R(   Rd   Re   t   wt   ht   start_angleR   t   colorRZ   t   bounding_box(    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   draw_arcK  s     i    c   	      K   s   t  j |  } t  j |  } t d |  } |  j j |  | d k rp | d k rp | j   } | j   } n | j   } | j   } |  j j | | d | | d d | | } | |  j	 | <d S(   sB  
        Draws an image from a file with its top-left corner at the given (x, y) pixel.
        Due to tkinter limitations, can recognize PNG and GIF but not JPG. Sorry.  :-(

        @param filename: path to image file
        @type filename: str
        @param x: top-left x-coordinate at which to place the image
        @param y: top-left y-coordinate at which to place the image
        @param w: (optional) width at which to draw the image (not yet supported)
        @param h: (optional) height at which to draw the image (not yet supported)
        @param options: (optional) keyword arguments to pass directly to Tk create_image function (see Tkinter documentation)
        @todo: support resizing of images (does not work yet)
        @see: http://effbot.org/tkinterbook/canvas.htm#canvas.Canvas.create_image-method
        t   filei    i   t   imageN(
   R   t    _DrawingPanel__adjust_coordinateR   RE   t   appendR   R   RH   t   create_imageRG   (	   R(   t   filenameRd   Re   R   R   RZ   R   t	   result_id(    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt
   draw_imagej  s    .c         K   s   d | k r1 |  j  d k r1 t |  j   | d <n  t j | | | |  \ } } } } |  j | |  j d |  } |  j j | | | | |  d S(   se  
        Draws a line between the two given points (x1, y1) and (x2, y2).

        @param x1: starting point's x-coordinate
        @param y1: starting point's y-coordinate
        @param x2: ending point's x-coordinate
        @param y2: ending point's y-coordinate
        @param color: (optional) color with which to draw line (if absent, uses panel's default color as set via set_color)
        @param options: (optional) keyword arguments to pass directly to Tk create_line function (see Tkinter documentation)
        @see: http://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.create_line-method
        R   i   R   N(   R;   R   R   R   R   RB   RH   t   create_line(   R(   t   x1t   y1t   x2t   y2R   RZ   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt	   draw_line  s
     $c         K   s   d | k r1 |  j  d k r1 t |  j   | d <n  |  j | |  j d |  } t j |  t j | |  \ } } |  j j	 | | | | | | |  d S(   s  
        Draws an oval the given size with its top-left corner at the given (x, y) pixel.
        You can pass the outline color as a last positional parameter, or it can be a keyword parameter (in options),
        or if none is passed at all, we will fall back to the panel's default outline color.
        The polygon will not be filled unless a 'fill' named parameter is passed.
        
        @param x: left x coordinate of bounding box of oval
        @param y: top y coordinate of bounding box of oval
        @param w: width of bounding box of oval
        @param h: height of bounding box of oval
        @param color: (optional) color to use for outline of shape (if absent, uses panel's default color as set via set_color)
        @param options: (optional) keyword arguments to pass directly to Tk create_oval function (see Tkinter documentation)
        @see: http://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.create_oval-method
        R   i   R   N(
   R;   R   R   RB   R   R   R   R   RH   t   create_oval(   R(   Rd   Re   R   R   R   RZ   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt	   draw_oval  s     c         K   sy   d | k r d | d <n  |  j  | |  j d |  } t j |  t j | |  \ } } |  j j | | | | |  d S(   s	  
        Changes the color at the given (x, y) pixel.
        Equivalent to drawing a 1x1 rectangle.
        
        @param x: x coordinate
        @param y: y coordinate
        @param color: (optional) color to use for pixel (if absent, uses panel's default color as set via set_color)
        @param options: (optional) keyword arguments to pass directly to Tk create_rectangle function (see Tkinter documentation)
        @see: http://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.create_rectangle-method
        R   i   R   N(   R   RB   R   R   R   R   RH   R   (   R(   Rd   Re   R   RZ   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt
   draw_pixel  s    c         O   s  t  |  d k r d St | d t  r6 | d } n  t | d t  rr g  | D] } | D] } | ^ qZ qP } n  t  |  d d k r t j | d  r t j | d  | d <| d  } q n  t  |  d d k r t d   n  t j	 |  } d | k r'|  j
 d k r't |  j
  | d <n  |  j d |  j d |  } xt t d t  |  d d  D]V } | | } | | d }	 | | d }
 | | d	 } |  j | |	 |
 | | |  q_Wd S(
   s  
        Draws a group of lines between the given coordinates passed as individual x/y coordinate parameters or (x,y) tuples.
        
        You can pass the outline color as a last positional parameter, or it can be a keyword parameter (in options),
        or if none is passed at all, we will fall back to the panel's default outline color.
        The difference between draw_polyline and draw_polygon is that the polygon will connect its last line point
        back to the start point; the polygon can also be filled, while a polyline cannot.
        
        example: panel.draw_polyline(x1, y1, x2, y2, x3, y3)
        example: panel.draw_polyline(x1, y1, x2, y2, x3, y3, x4, y4, "red")
        example: panel.draw_polyline(p1, p2, p3)
        
        @param coords: x, y coordinate pairs of arbitrary number
        @param options: (optional) keyword arguments to pass directly to Tk create_line function (see Tkinter documentation)
        @see: http://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.create_line-method
        i    Ni   iR   s$   must pass even number of coordinatesR   i   i   (   R   R   t   listR   R   t   is_valid_colort   to_hexR   R   R   R;   R   R   R   RB   t   rangeR   (   R(   R   RZ   t   tt   xyt   adjusted_coordsR   t   iR   R   R   R   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   draw_polyline  s,    ) #
c         O   s  t  |  d k r d St | d t  r6 | d } n  t | d t  rr g  | D] } | D] } | ^ qZ qP } n  |  j } t  |  d d k r t j | d  r t j | d  } | d  } q n  t  |  d d k r t d   n  d | k r|  j	 d k rt
 |  j	  | d <n  d | k r| d | d	 k sQ| d | d k rl| | d | d f 7} n  | | d <|  j | |  d St j |  } |  j d | d
 |  t j |  |  j d |  j   d |  |  j j | |  d S(   s  
        Draws an outlined polygon between the given coordinates passed as individual x/y coordinate parameters or (x,y) tuples.
        You can pass the outline color as a last positional parameter, or it can be a keyword parameter (in options),
        or if none is passed at all, we will fall back to the panel's default outline color.
        The polygon will not be filled unless a 'fill' named parameter is passed.

        example: panel.draw_polygon(x1, y1, x2, y2, x3, y3)
        example: panel.draw_polygon(x1, y1, x2, y2, x3, y3, x4, y4, "red")
        example: panel.draw_polygon(p1, p2, p3)

        @param coords: x, y coordinate pairs of arbitrary number
        @param options: (optional) keyword arguments to pass directly to Tk create_polygon and/or create_line function (see Tkinter documentation)
        @see: http://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.create_polygon-method
        i    Ni   is$   must pass even number of coordinatesR   i   R   iR   (   R   R   R   R   RB   R   R   R   R   R;   R   R   R   R   R   R   R   t   get_backgroundRH   t   create_polygon(   R(   R   RZ   R   R   t   outline_colorR   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   draw_polygon  s4    )	 (
c         K   s   d | k r1 |  j  d k r1 t |  j   | d <n  |  j | |  j d |  } t j |  t j | |  \ } } |  j j	 | | | | | | |  d S(   s  
        Draws a rectangle of the given size with its top-left corner at the given (x, y) pixel.
        Equivalent to draw_rectangle.
        
        @param x: left x coordinate of bounding box of rectangle
        @param y: top y coordinate of bounding box of rectangle
        @param w: width of bounding box of rectangle
        @param h: height of bounding box of rectangle
        @param color: (optional) color to use for outline of shape (if absent, uses panel's default color as set via set_color)
        @param options: (optional) keyword arguments to pass directly to Tk create_rectangle function (see Tkinter documentation)
        @see: http://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.create_rectangle-method
        R   i   R   N(
   R;   R   R   RB   R   R   R   R   RH   R   (   R(   Rd   Re   R   R   R   RZ   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt	   draw_rect  s     c         K   s    |  j  | | | | | |  d S(   s  
        Draws a rectangle of the given size with its top-left corner at the given (x, y) pixel.
        Equivalent to draw_rect.
        
        @param x: left x coordinate of bounding box of rectangle
        @param y: top y coordinate of bounding box of rectangle
        @param w: width of bounding box of rectangle
        @param h: height of bounding box of rectangle
        @param color: (optional) color to use for outline of shape (if absent, uses panel's default color as set via set_color)
        @param options: (optional) keyword arguments to pass directly to Tk create_rectangle function (see Tkinter documentation)
        @see: http://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.create_rectangle-method
        N(   R   (   R(   Rd   Re   R   R   R   RZ   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   draw_rectangle0  s    c         K   s   t  j | |  \ } } |  j | |  j d |  } | d k sK | d k rW |  j } n  d | k rp t | d <n  d | k r t | d <n  |  j j	 | | d | d | | d S(   s  
        Draws a text string with its top-left corner at the given (x, y) pixel.

        @param x: left x coordinate of start of text
        @param y: top y coordinate of start of text
        @param color: (optional) color to use for outline of shape (if absent, uses panel's default color as set via set_color)
        @param font: (optional) font face to use to render text, in "family size style" format, such as "Times New Roman 16 bold italic"
        @param options: (optional) keyword arguments to pass directly to Tk create_text function (see Tkinter documentation)
        @see: http://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.create_text-method
        R   R   R0   R/   R-   t   fontN(
   R   R   R   RB   R   RD   R   R   RH   t   create_text(   R(   R-   Rd   Re   R   R   RZ   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   draw_string?  s    c   
      K   s  d | k r1 |  j  d k r1 t |  j   | d <n  |  j | |  j d |  } |  j d	 | d |  t j |  t j | |  \ } } d | k r | | d <n  d | k r | | d <n  d | k r d | d <n  | | | | | | f }	 |  j	 j
 |	 |  d	 S(
   s  
        Draws a filled arc (a partial oval).
        The resulting arc begins at 'start_angle' and extends for 'extent' degrees.
        Angles are interpreted such that 0 degrees is at the 3 o'clock position.
        A positive value indicates a counter-clockwise rotation while a negative value indicates a clockwise rotation.
        You can pass the outline color as a named 'outline' parameter, else the fill color will be used as the outline color.
        
        @param x: left x coordinate of bounding box of arc's oval
        @param y: top y coordinate of bounding box of arc's oval
        @param w: width of bounding box of arc's oval
        @param h: height of bounding box of arc's oval
        @param start_angle: starting angle in degrees, where 0 is at "3 o'clock" position
        @param extent: degrees that the arc should extend from its start, where positive numbers are counter-clockwise and negative values are clockwise
        @param color: (optional) color to use for fill of shape (if absent, uses panel's default fill color as set via set_fill_color)
        @see: http://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.create_arc-method
        R   i   R   R   R   R   R   t   piesliceN(   R;   R   R   RA   R   R   R   R   R   RH   R   (
   R(   Rd   Re   R   R   R   R   R   RZ   R   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   fill_arcT  s     c         K   s   t  j | |  \ } } |  j | |  j d |  } d | k rp d | k rp |  j d k rp t |  j  | d <n  |  j d | d |  |  j j | | | | | | |  d S(   s  
        Draws a filled oval of the given size with its top-left corner at the given (x, y) pixel.
        You can pass the fill color as a fifth positional parameter, or it can be a keyword parameter (in options),
        or if none is passed at all, we will fall back to the panel's default fill color.
        You can pass the outline color as a named 'outline' parameter, else the fill color will be used as the outline color.
        
        @param x: left x coordinate of bounding box of oval
        @param y: top y coordinate of bounding box of oval
        @param w: width of bounding box of oval
        @param h: height of bounding box of oval
        @param color: (optional) color to use for fill of shape (if absent, uses panel's default color as set via set_fill_color)
        @param options: (optional) keyword arguments to pass directly to Tk create_oval function (see Tkinter documentation)
        @see: http://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.create_oval-method
        R   R   R   i   N(	   R   R   R   RA   R;   R   R   RH   R   (   R(   Rd   Re   R   R   R   RZ   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt	   fill_ovals  s    ' c         O   sw  t  |  d k r d St | d t  r6 | d } n  t | d t  rr g  | D] } | D] } | ^ qZ qP } n  d | k r d | k r |  j d k r t |  j  | d <n  d } t  |  d d k r	t j | d  r	t j | d  } | d	 <| d  } q	n  t  |  d d k r.t	 d
   n  t
 j |  } |  j d | d	 |  t j |  |  j j | |  d S(   s  
        Draws a filled polygon between the given coordinates passed as individual x/y coordinate parameters or (x,y) tuples.
        You can pass the 'fill' as a last positional parameter, or it can be a keyword parameter (in options),
        or if none is passed at all, we will fall back to the panel's default fill color.
        You can pass the outline color as a named 'outline' parameter, else the fill color will be used as the outline color.
        
        example: panel.fill_polygon(x1, y1, x2, y2, x3, y3)
        example: panel.fill_polygon(x1, y1, x2, y2, x3, y3, x4, y4, "red")
        example: panel.fill_polygon(p1, p2, p3)

        @param coords: x, y coordinate pairs of arbitrary number
        @param options: (optional) keyword arguments to pass directly to Tk create_polygon function (see Tkinter documentation)
        @see: http://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.create_polygon-method
        i    NR   R   i   R   i   iR   s$   must pass even number of coordinates(   R   R   R   R   R;   R   R   R   R   R   R   R   R   R   R   RH   R   (   R(   R   RZ   R   R   t
   fill_colorR   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   fill_polygon  s&    )' c         K   s   t  j | |  \ } } |  j | |  j d |  } d | k rp d | k rp |  j d k rp t |  j  | d <n  |  j d | d |  |  j j | | | | | | |  d S(   s5  
        Draws a filled rectangle of the given size with its top-left corner at the given (x, y) pixel.
        You can pass the fill color as a fifth positional parameter, or it can be a keyword parameter (in options),
        or if none is passed at all, we will fall back to the panel's default fill color.
        You can pass the outline color as a named 'outline' parameter, else the fill color will be used as the outline color.
        Equivalent to fill_rectangle.
        
        @param x: left x coordinate of bounding box of rectangle
        @param y: top y coordinate of bounding box of rectangle
        @param w: width of bounding box of rectangle
        @param h: height of bounding box of rectangle
        @param color: (optional) color to use to fill shape (if absent, uses panel's default color as set via set_fill_color)
        @param options: (optional) keyword arguments to pass directly to Tk create_rectangle function (see Tkinter documentation)
        @see: http://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.create_rectangle-method
        R   R   R   i   N(	   R   R   R   RA   R;   R   R   RH   R   (   R(   Rd   Re   R   R   R   RZ   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt	   fill_rect  s    ' c         K   s#   |  j  | | | | | | |  d S(   s  
        Draws a filled rectangle of the given size with its top-left corner at the given (x, y) pixel.
        Equivalent to fill_rect.
        
        @param x: left x coordinate of bounding box of rectangle
        @param y: top y coordinate of bounding box of rectangle
        @param w: width of bounding box of rectangle
        @param h: height of bounding box of rectangle
        @param color: (optional) color to use to fill shape (if absent, uses panel's default color as set via set_fill_color)
        @param options: (optional) keyword arguments to pass directly to Tk create_rectangle function (see Tkinter documentation)
        @see: http://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.create_rectangle-method
        N(   R   (   R(   Rd   Re   R   R   R   R   RZ   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   fill_rectangle  s    c         C   s   |  j  d S(   sU   
        The panel's background color. Default is white.
        @rtype: str
        R$   (   RH   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyRY     s    c         C   s   |  j  d S(   s   
        Returns the panel's background color. Default is white.
        @return: color as hex string such as "#ff00cc"
        @rtype: str
        R$   (   RH   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR     s    c         C   s   t  j |  j d  S(   s}   
        The panel's background color as an RGB tuple such as (255, 0, 192). Default is white.
        @rtype: tuple
        R$   (   R   t   to_rgbRH   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   background_rgb  s    c         C   s   t  j |  j d  S(   s   
        Returns the panel's background color as an RGB tuple. Default is white.
        @return: color as a 3-element rgb tuple such as (255, 0, 192)
        @rtype: tuple
        R$   (   R   R   RH   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   get_background_rgb  s    c         C   s   |  j  S(   s   
        The default color used to outline drawn shapes.
        This color will be used unless you explicitly pass a color to the drawing function to draw a particular shape.
        Equivalent to foreground.
        @rtype: str
        (   RB   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR     s    c         C   s   |  j  S(   s   
        Returns the default color used to outline drawn shapes.
        This color will be used unless you explicitly pass a color to the drawing function to draw a particular shape.
        Equivalent to get_foreground.
        @rtype: str
        (   RB   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt	   get_color  s    c         C   s   |  j  S(   s   
        The default color used to fill in shapes.
        This color will be used unless you explicitly pass a color to the filling function to draw a particular shape.
        @rtype: str
        (   RA   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR     s    c         C   s   |  j  S(   s   
        Returns the default color used to fill in shapes.
        This color will be used unless you explicitly pass a color to the filling function to draw a particular shape.
        @rtype: str
        (   RA   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   get_fill_color  s    c         C   s   |  j  S(   s2  
        The font used for drawn strings.
        Pass a string in "FONTNAME SIZE STYLE" format, with the last two tokens optional,
        such as "Helvetica" or "Consolas 14" or "Times New Roman 16 bold".
        @rtype: str
        @see: http://effbot.org/tkinterbook/tkinter-widget-styling.htm
        (   RD   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR   "  s    	c         C   s   |  j  S(   s  
        Returns the font used for drawn strings.
        Pass a string in "FONTNAME SIZE STYLE" format, with the last two tokens optional,
        such as "Helvetica" or "Consolas 14" or "Times New Roman 16 bold".
        @return: font as a "family size style" string such as "Times New Roman 16 bold italic"
        @rtype: str
        @see: http://effbot.org/tkinterbook/tkinter-widget-styling.htm
        (   RD   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   get_font-  s    	c         C   s   |  j  S(   s   
        The default color used to outline drawn shapes.
        This color will be used unless you explicitly pass a color to the drawing function to draw a particular shape.
        Equivalent to color.
        @rtype: str
        (   RB   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt
   foreground8  s    c         C   s   |  j  S(   s   
        Returns the default color used to outline drawn shapes.
        This color will be used unless you explicitly pass a color to the drawing function to draw a particular shape.
        Equivalent to get_color.
        @rtype: str
        (   RB   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   get_foregroundB  s    c         C   s   |  j  S(   sL   
        The height of the panel's canvas area.
        @rtype: int
        (   R   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR   K  s    c         C   s   |  j  S(   s   
        Returns the height of the panel's canvas area.
        @return: height in pixels as an int
        @rtype: int
        (   R   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt
   get_heightS  s    c         C   s   |  j  |  j f S(   sn   
        A 2-element tuple containing the panel's window's top-left x/y corner.
        @rtype: tuple
        (   R9   R:   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   location[  s    c         C   s   |  j  |  j f S(   sv   
        Returns a 2-element tuple containing the panel's window's top-left x/y corner.
        @rtype: tuple
        (   R9   R:   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   get_locationc  s    c         C   s   |  j  S(   s   
        The default color used to outline drawn shapes.
        This color will be used unless you explicitly pass a color to the drawing function to draw a particular shape.
        Equivalent to color.
        @rtype: str
        (   RB   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR   j  s    c         C   s   |  j  S(   s   
        Returns the default color used to outline drawn shapes.
        This color will be used unless you explicitly pass a color to the drawing function to draw a particular shape.
        Equivalent to get_color.
        @rtype: str
        (   RB   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   get_outline_colort  s    c         C   sO  t  j |  } t  j |  } |  j j | | | |  } d } t |  d k r| d } | |  j k rN|  j | } |  j j |  } t | t | d  | j	   d  } t | t | d  | j
   d  } | d k r| | j	   k  r| d k r| | j
   k  r| j | |  } t j | d | d | d  } qq|  j j | d  }	 |	 d k r|  j j | d  }	 n  |	 d k r|  j j | d  }	 n  |	 d k r|	 } qn  | d k r|  j d	 } n  |  j j |  }
 |
 rKt |
 d d
  } t |
 d d
  } t |
 d d
  } t j | | |  } n  | S(   s  
        Returns the RGB color of the given (x, y) pixel on the canvas as a string such as "#ff00ff".
        NOTE: This function currently fails when there are text strings drawn onto the canvas.
        It interprets every pixel in the bounding box of the text string to be the text string's color.
        
        @param x: x coordinate of pixel
        @param y: y coordinate of pixel
        @rtype: str
        i    ii   i   R   R   R   R   R$   i   N(   R   R   RH   t   find_overlappingR   R   RG   R   Rc   R   R   t   getR   R   t   itemcgett	   winfo_rgb(   R(   Rd   Re   t   idst   resultt   indext   imgR   Ri   R   t   tempt   rt   gt   b(    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   get_pixel_color}  s<    

((<'c         C   s   t  j |  j | |   S(   s   
        Returns the RGB color of the given (x, y) pixel on the canvas as a 3-tuple of three integers from 0-255
        representing the Red, Green, and Blue components.
        
        @param x: x coordinate of pixel
        @param y: y coordinate of pixel
        @rtype: str
        (   R   R   R   (   R(   Rd   Re   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyRf     s    	c         C   s   |  j  |  j f S(   sm   
        A 2-element tuple of the width and height of the panel's canvas area.
        @rtype: tuple
        (   R   R   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   size  s    c         C   s   |  j  |  j f S(   s   
        Returns a 2-element tuple of the width and height of the panel's canvas area.
        @return: 2-element tuple such as (400, 300)
        @rtype: tuple
        (   R   R   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   get_size  s    c         C   s   |  j  S(   s   
        The width that will be used to draw lines on future shapes.
        Equivalent to stroke_width.
        @rtype: int
        (   R;   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   stroke  s    c         C   s   |  j  S(   s   
        Returns the width that will be used to draw lines on future shapes.
        Equivalent to get_stroke_width.
        @return: stroke width (default 1)
        @rtype: int
        (   R;   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt
   get_stroke  s    c         C   s   |  j  j   S(   s@   
        The window title bar text.
        @rtype: str
        (   R>   RC   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyRC     s    c         C   s   |  j  j   S(   so   
        Returns the window title bar text.
        @return: window title bar text
        @rtype: str
        (   R>   RC   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt	   get_title  s    c         C   s   |  j  S(   s   
        The width that will be used to draw lines on future shapes.
        Equivalent to stroke.
        @rtype: int
        (   R;   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   stroke_width  s    c         C   s   |  j  S(   s   
        Returns the width that will be used to draw lines on future shapes.
        Equivalent to get_stroke.
        @return: stroke width (default 1)
        @rtype: int
        (   R;   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   get_stroke_width  s    c         C   s   |  j  S(   sK   
        The width of the panel's canvas area.
        @rtype: int
        (   R   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR     s    c         C   s   |  j  S(   sS   
        Returns the width of the panel's canvas area.
        @rtype: int
        (   R   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt	   get_width   s    c         C   s   |  j  S(   sa   
        The underlying Tkinter window being displayed on the screen.
        @rtype: Tk
        (   R>   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   window  s    c         C   s   |  j  S(   si   
        Returns the underlying Tkinter window being displayed on the screen.
        @rtype: Tk
        (   R>   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt
   get_window  s    c         C   s   |  j  j   |  j  j   f S(   s   
        A 2-element tuple of the width and height of the panel's entire window including borders and status bar.
        @rtype: tuple
        (   R>   R}   R~   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   window_size  s    c         C   s   |  j  j   |  j  j   f S(   s   
        Returns a 2-element tuple of the width and height of the panel's entire window including borders and status bar.
        @return: 2-element tuple such as (410, 318)
        @rtype: tuple
        (   R>   R}   R~   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   get_window_size  s    c         C   s   |  j  S(   sQ   
        The panel's window's left x pixel position.
        @rtype: int
        (   R9   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyRd   &  s    c         C   s   |  j  S(   sY   
        Returns the panel's window's left x pixel position.
        @rtype: int
        (   R9   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   get_x.  s    c         C   s   |  j  S(   sP   
        The panel's window's top y pixel position.
        @rtype: int
        (   R:   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyRe   5  s    c         C   s   |  j  S(   sX   
        Returns the panel's window's top y pixel position.
        @rtype: int
        (   R:   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   get_y=  s    c         C   s   |  j  t  d S(   sO   
        Sets the DrawingPanel window to be not visible on the screen.
        N(   t   set_visiblet   False(   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   hideD  s    c            se   t  j  j j  y: d d l      f d   } |   j j    j _ Wn t k
 r` n Xd S(   si   
        Private function that sets up a 'main loop' hack.
        Not to be called by students.
        iNc            s       f d   } | S(   Nc             s&    j  j      j _  |  |   S(   N(   R>   t   mainloopt   runt   flush_stdout(   t   at   kw(   t   idlelibt	   orig_funcR(   (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   newfuncX  s    (    (   R   R   (   R   R(   (   R   sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   mainloop_wrapW  s    (   t   atexitt   registerR>   R   t   idlelib.runR   R   t   ImportError(   R(   R   (    (   R   R(   sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   __install_mainloop_hackJ  s    c         C   s   |  j  S(   sm   
        Whether the DrawingPanel window is able to be resized; initially True.
        @rtype: bool
        (   R=   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt	   resizablea  s    c         C   s   |  j  S(   s   
        Returns whether the DrawingPanel window is able to be resized; initially True.
        @return: True if the DrawingPanel window is able to be resized, otherwise False
        @rtype: bool
        (   R=   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   is_resizablei  s    c         C   s0   y d |  j  j   k SWn t k
 r+ t SXd S(   s   
        Whether the DrawingPanel window is visible on the screen.
        If the DrawingPanel has been closed or hidden, returns False.
        @rtype: bool
        t   normalN(   R>   t   stateR   R   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   visibleq  s    c         C   s0   y d |  j  j   k SWn t k
 r+ t SXd S(   s	  
        Returns whether the DrawingPanel window is visible on the screen.
        If the DrawingPanel has been closed or hidden, returns False.
        @return: True if the DrawingPanel window is visible on the screen, otherwise False
        @rtype: bool
        R  N(   R>   R  R   R   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt
   is_visible}  s    t   Messagec         C   s6   t  j d k r" t j | |  n t j | |  d S(   sB   
        Pops up a message box displaying the given text.
        i   i    N(   i   i    (   RW   t   version_infoR   t   showinfot   tkMessageBox(   R(   R-   RC   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR_     s    t   Errorc         C   s6   t  j d k r" t j | |  n t j | |  d S(   sI   
        Pops up an error message box displaying the given text.
        i   i    N(   i   i    (   RW   R  R   t	   showerrorR	  (   R(   R-   RC   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   message_error  s    t   Questionc         C   s3   t  j d k r t j | |  St j | |  Sd S(   s   
        Pops up a question message box displaying the given text with Yes/No buttons.
        If user presses Yes, returns True; if No, returns False.
        i   i    N(   i   i    (   RW   R  R   t   askyesnoR	  (   R(   R-   RC   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   message_yes_no  s    c         C   s   | d k s | d k rO t } | | k r= | | } t } n  | sO | } qO n  | d k pd | d k s t j |  } | | | <n  | S(   s  
        Private helper function to help us allow for explicitly passed or implicit default colors.
        Chooses a color based on the given value, default, and what option key to store it as.
        If the given color is None/empty and default is present, uses that default.
        If a non-empty color or default is found, places this into options[key] for each key in keys.
        Not to be called by students.
        R   N(   R   R   R<   R   R   (   R(   R   t   defaultt   keyRZ   t   found(    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   __pick_color_with_default  s    
	c   	      C   s6  | j    j d  r1 |  j j d | d d  n| j    j d  r&t | d  } |  j   } |  j   } | j d  | j t |  d t |  d	  | j d
  xj t	 |  D]\ } xF t	 |  D]8 } |  j
 | |  } t j |  } | j d |  q W| j d	  q W| j   n t d   d S(   s  
        Saves the drawing panel to the given output file.
        Formats supported: .ppm, .ps
        NOTE: This function currently fails when there are text strings drawn onto the canvas.
        It interprets every pixel in the bounding box of the text string to be the text string's color.
        
        @param filename: path to file to save into (must be .ps or .ppm format)
        
        @todo: use PIL library to save if lib is present
        s   .psR   t	   colormodeR   s   .ppmR   s   P3
R.   s   
s   255
s   %3d %3d %3d sB   Unable to save file in this format. Supported formats: *.ppm, *.psN(   Rm   t   endswithRH   t
   postscriptt   openR   R   t   writeR   R   R   R   R   R+   R   (	   R(   R   t   fR   R   Re   Rd   t   pxRi   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   save  s"    %c         C   sc  d } d d d d d d  f } t  j   } yR t j d! k r] t j d | d | d |  } n t j d | d | d |  } Wn t k
 r d SX| d k s | d k s t	 | t
  r d S| } | j d  } | d k  r | j d  } n  | d k r| | d } n  y& |  j |  |  j d | d  Wn) t k
 r^} |  j t
 |  d  n Xd S("   s   
        Pops up a file choosing dialog to allow the user to save the drawing panel's
        canvas output to a file.
        s	   Save files	   PPM filess   *.ppms   PS filess   *.pss	   PNG filess   *.pngs	   JPG filess   *.jpg,*.jpegs	   GIF filess   *.gifs	   All filess   *.*i   i    t
   initialdirRC   t	   filetypesNR   t   /s   \i   s	   Saved to t   .s   Error saving file(   s	   PPM filess   *.ppm(   s   PS filess   *.ps(   s	   PNG filess   *.png(   s	   JPG filess   *.jpg,*.jpeg(   s	   GIF filess   *.gif(   s	   All filess   *.*(   i   i    (   t   ost   getcwdRW   R  R   t   asksaveasfilenamet   tkFileDialogR   R   R   R   t   rfindR  Rg   R   R  (   R(   RC   t
   file_typest   current_dirt	   file_pathR   t   slasht   ve(    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR,     s6    	!"(c         C   s   t  j |  |  j d <d S(   s   
        Sets the panel's background color to be the given color, as a string such as "yellow" or "black" or "yellow" or "#ff00cc"
        R$   N(   R   R   RH   (   R(   t   value(    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyRY     s    c         G   s   t  j |   |  j d <d S(   s  
        Sets the panel's background color to be the given color.
        color -- the color to set, as a string such as "yellow" or "black"
        @param args: either a color string such as "yellow" or "#ff00cc", or a 3-element RGB tuple such as (255, 0, 192)
        R$   N(   R   R   RH   (   R(   t   args(    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   set_background  s    c         C   s   t  j |  } | |  _ d S(   s   
        Sets the color used to outline future drawn shapes.
        The color passed must be a color string like "purple" or a hex string like "#ff00ff".
        @see: http://wiki.tcl.tk/16166
        N(   R   R   RB   (   R(   R*  R   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR     s    c         G   s   t  j |   } | |  _ d S(   se  
        Sets the color used to outline future drawn shapes.
        The color passed can be a color string like "purple" or a hex string like "#ff00ff" or an RGB tuple like (255, 0, 255).
        @param args: either a color string such as "yellow" or "#ff00cc", or a 3-element RGB tuple such as (255, 0, 192)
        @see: http://wiki.tcl.tk/16166
        N(   R   R   RB   (   R(   R+  R   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt	   set_color%  s    c         C   s   t  j |  } | |  _ d S(   s   
        Sets the color used to fill in future drawn shapes.
        The color passed must be a color string like "purple" or a hex string like "#ff00ff".
        N(   R   R   RA   (   R(   R*  R   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR   /  s    c         G   s   t  j |   } | |  _ d S(   s>  
        Sets the color used to fill in future drawn shapes.
        The color passed can be a color string like "purple" or a hex string like "#ff00ff" or an RGB tuple like (255, 0, 255).
        @param args: either a color string such as "yellow" or "#ff00cc", or a 3-element RGB tuple such as (255, 0, 192)
        N(   R   R   RA   (   R(   R+  R   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   set_fill_color8  s    c         C   s   | |  _  d S(   s*  
        Sets the font used for future drawn strings.
        Pass a string in "FONTNAME SIZE STYLE" format, with the last two tokens optional,
        such as "Helvetica" or "Consolas 14" or "Times New Roman 16 bold".
        @see: http://effbot.org/tkinterbook/tkinter-widget-styling.htm
        N(   RD   (   R(   R*  (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR   A  s    c         C   s   | |  _  d S(   s  
        Sets the font used for future drawn strings.
        Pass a string in "FONTNAME SIZE STYLE" format, with the last two tokens optional,
        such as "Helvetica" or "Consolas 14" or "Times New Roman 16 bold".
        @param font: a font string in "FONTNAME SIZE STYLE" format, with the last two tokens optional, such as "Helvetica" or "Consolas 14" or "Times New Roman 16 bold".
        @see: http://effbot.org/tkinterbook/tkinter-widget-styling.htm
        N(   RD   (   R(   R   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   set_fontK  s    c         C   s   |  j  |  d S(   s   
        Sets the color used to outline and fill future drawn shapes.
        The color passed must be a color string like "purple" or a hex string like "#ff00ff".
        Equivalent to setting color.
        N(   R-  (   R(   R*  (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR   U  s    c         G   s   |  j  |   d S(   sh  
        Sets the color used to outline and fill future drawn shapes.
        The color passed can be a color string like "purple" or a hex string like "#ff00ff" or an RGB tuple like (255, 0, 255).
        Equivalent to set_color.
        @param args: either a color string such as "yellow" or "#ff00cc", or a 3-element RGB tuple such as (255, 0, 192)
        N(   R-  (   R(   R+  (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   set_foreground^  s    c         C   s   |  j  |  j |  d S(   sD   
        Sets the panel's canvas height to the given value.
        N(   R@   R   (   R(   R   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR   g  s    c         C   s   |  j  |  j |  d S(   sy   
        Sets the panel's canvas height to the given value.
        @param h: desired height of window in pixels
        N(   R@   R   (   R(   R   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt
   set_heightn  s    c         C   sX   |  j    \ } } | d |  _ | d |  _ |  j j d | | | d | d f  d S(   s   
        Sets the window's location such that its top-left corner is at the given x/y pixel position.
        Pass a 2-integer-element tuple as the new value.
        i    i   s   %dx%d+%d+%dN(   R   R9   R:   R>   t   geometry(   R(   R   t   wwt   wh(    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR   u  s    c         C   sH   |  j    \ } } | |  _ | |  _ |  j j d | | | | f  d S(   s   
        Sets the window's location such that its top-left corner is at the given x/y pixel position.
        @param x: desired x coordinate of top-left corner of window
        @param y: desired y coordinate of top-left corner of window
        s   %dx%d+%d+%dN(   R   R9   R:   R>   R2  (   R(   Rd   Re   R3  R4  (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR     s    		c         C   s   t  j |  } | |  _ d S(   s   
        Sets the color used to outline future drawn shapes.
        Equivalent to setting color.
        Pass either a color string such as "yellow" or "#ff00cc"
        N(   R   R   RB   (   R(   R*  R   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR     s    c         G   s   t  j |   } | |  _ d S(   s   
        Sets the color used to outline future drawn shapes.
        Equivalent to set_color.
        @param args: either a color string such as "yellow" or "#ff00cc", or a 3-element RGB tuple such as (255, 0, 192)
        N(   R   R   RB   (   R(   R+  R   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   set_outline_color  s    c         C   s    | |  _  |  j j | |  d S(   s]   
        Sets whether the DrawingPanel window is able to be resized; initially True.
        N(   R=   R>   R   (   R(   R*  (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR     s    	c         C   s    | |  _  |  j j | |  d S(   s   
        Sets whether the DrawingPanel window is able to be resized; initially True.
        @param resizable: True if window should be resizable; False if not
        N(   R=   R>   R   (   R(   R   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   set_resizable  s    	c         C   s   | d |  _  | d |  _ |  j j d |  j  |  j |  j |  j f  t |  d  r |  j j d | d d | d  |  j j	 d t
  n  t |  d  r |  j j	 d t d	 t  n  |  j j   d
 S(   sk   
        Sets the window's size such that its canvas will be the given width and height in pixels.
        i    i   s   %dx%d+%d+%dt   canvasR   R   R%   RK   t   expandN(   R   R   R>   R2  R9   R:   RV   RH   RQ   RI   R	   RK   R   R<   RS   (   R(   R4  (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR     s    ,!c         C   s   | |  _  | |  _ |  j j d |  j  |  j |  j |  j f  t |  d  r| |  j j d | d |  |  j j	 d t
  n  t |  d  r |  j j	 d t d t  n  |  j j   d S(	   s   
        Sets the window's size such that its canvas will be the given width and height.
        @param width: desired canvas width in pixels
        @param height: desired canvas height in pixels
        s   %dx%d+%d+%dR7  R   R   R%   RK   R8  N(   R   R   R>   R2  R9   R:   RV   RH   RQ   RI   R	   RK   R   R<   RS   (   R(   R   R   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR@     s    		,c         C   s0   |  j  j d | d t d t  |  j j   d S(   sQ   
        Sets the text to show in the window's southern status bar area.
        R-   R/   R0   N(   RK   RQ   R
   R   R>   RS   (   R(   R-   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyRg     s    c         C   s   | |  _  d S(   s~   
        Sets the width that will be used to draw lines on future shapes.
        Equivalent to setting stroke_width.
        N(   R;   (   R(   R   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR     s    c         C   s   | |  _  d S(   sz   
        Sets the width that will be used to draw lines on future shapes.
        Equivalent to set_stroke_width.
        N(   R;   (   R(   R   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt
   set_stroke  s    c         C   s   | |  _  d S(   st   
        Sets the width that will be used to draw lines on future shapes.
        Equivalent to set_stroke.
        N(   R;   (   R(   R   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR     s    c         C   s   | |  _  d S(   st   
        Sets the width that will be used to draw lines on future shapes.
        Equivalent to set_stroke.
        N(   R;   (   R(   R   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   set_stroke_width  s    c         C   s   |  j  j |  d S(   sE   
        Sets the title to display at the top of the window.
        N(   R>   RC   (   R(   R-   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyRC     s    c         C   s   |  j  j |  d S(   sE   
        Sets the title to display at the top of the window.
        N(   R>   RC   (   R(   R-   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt	   set_title  s    c         C   so   yW | r3 |  j    r3 |  j j   |  j j   n# | rV |  j    rV |  j j   n  Wn t k
 rj n Xd S(   sW   
        Sets whether the DrawingPanel window should be visible on the screen.
        N(   R  R>   RS   RU   R?   R   (   R(   R*  (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR     s    c         C   so   yW | r3 |  j    r3 |  j j   |  j j   n# | rV |  j    rV |  j j   n  Wn t k
 rj n Xd S(   sW   
        Sets whether the DrawingPanel window should be visible on the screen.
        N(   R  R>   RS   RU   R?   R   (   R(   R*  (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR     s    c         C   s   |  j  | |  j  d S(   sC   
        Sets the panel's canvas width to the given value.
        N(   R@   R   (   R(   R*  (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR     s    c         C   s   |  j  | |  j  d S(   sC   
        Sets the panel's canvas width to the given value.
        N(   R@   R   (   R(   R   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt	   set_width"  s    c         C   s   |  j  | |  j  d S(   sU   
        Sets the panel's window's left x pixel position to the given value.
        N(   R   R:   (   R(   R*  (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyRd   (  s    c         C   s   |  j  | |  j  d S(   s   
        Sets the panel's window's left x pixel position to the given value.
        @param x: desired x position of top-left corner of window
        N(   R   R:   (   R(   Rd   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   set_x/  s    c         C   s   |  j  |  j |  d S(   sT   
        Sets the panel's window's top y pixel position to the given value.
        N(   R   R9   (   R(   R*  (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyRe   6  s    c         C   s   |  j  |  j |  d S(   s   
        Sets the panel's window's top y pixel position to the given value.
        @param y: desired y position of top-left corner of window
        N(   R   R9   (   R(   Re   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   set_y=  s    c         C   s   |  j  t  d S(   sK   
        Sets the DrawingPanel window to be visible on the screen.
        N(   R   R<   (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   showD  s    c         C   sW   | d k r d Sy/ |  j  j   t j | d  |  j  j   Wn t k
 rR n Xd S(   s   
        Causes the DrawingPanel to pause for the given number of milliseconds.
        Useful for creating simple animations.
        @param ms: number of milliseconds to pause
        i    Ng     @@(   R>   RS   t   timet   sleept	   Exception(   R(   t   ms(    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyRA  J  s    (h   t   __name__t
   __module__t   __doc__t   staticmethodR   R   Rb   R^   RP   R*   R&   Rp   Rz   RT   R   R+   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   t   propertyRY   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   Rf   R   R   R   R   RC   R   R   R   R   R   R   R   R   R   Rd   R   Re   R   R   RX   R   R  R  R  R_   R  R  R   R  R,   t   setterR,  R-  R.  R/  R0  R1  R   R5  R6  R@   Rg   R9  R:  R;  R<   R   R<  R=  R>  R?  RA  (    (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR   S   s   ?			#		
	"	*	/	'		
					
				
			,																				
		)	*	
	
			
	
					
												R   c           B   s&'  e  Z d  Z d   Z d   Z e d    Z e d    Z e d    Z e d    Z	 e d    Z
 e d    Z e d	    Z e d
    Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z  d Z! d Z" d  Z# d! Z$ d" Z% d# Z& d$ Z' d% Z( d& Z) d' Z* d( Z+ d) Z, d* Z- d+ Z. d, Z/ d- Z0 d. Z1 d/ Z2 d0 Z3 d1 Z4 d2 Z5 d3 Z6 d4 Z7 d5 Z8 d6 Z9 d7 Z: d8 Z; d9 Z< d: Z= d; Z> d< Z? d= Z@ d> ZA d? ZB d@ ZC dA ZD dB ZE dC ZF dD ZG dE ZH dF ZI dG ZJ dH ZK dI ZL dJ ZM dK ZN dL ZO dM ZP dN ZQ dO ZR dP ZS dQ ZT dR ZU dS ZV dT ZW dU ZX dV ZY dW ZZ dX Z[ dY Z\ dZ Z] d[ Z^ d\ Z_ d] Z` d^ Za d_ Zb d` Zc da Zd db Ze dc Zf dd Zg de Zh df Zi dg Zj dh Zk di Zl dj Zm dk Zn dl Zo dm Zp dn Zq do Zr dp Zs dq Zt dr Zu ds Zv dt Zw du Zx dv Zy dw Zz dx Z{ dy Z| dz Z} d{ Z~ d| Z d} Z d~ Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Zd Zd ZdZdZdZdZdZdZ	dZ
dZd	Zd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"d Z#d!Z$d"Z%d#Z&d$Z'd%Z(d&Z)d'Z*d(Z+d)Z,d*Z-d+Z.d,Z/d-Z0d.Z1d/Z2d0Z3d1Z4d2Z5d3Z6d4Z7d5Z8d6Z9d7Z:d8Z;d9Z<d:Z=d;Z>d<Z?d=Z@d>ZAd?ZBd@ZCdAZDdBZEdCZFdDZGdEZHdFZIdGZJdHZKdIZLdJZMdKZNdLZOdMZPdNZQdOZRdPZSdQZTdRZUdSZVdTZWdUZXdVZYdWZZdXZ[dYZ\dZZ]d[Z^d\Z_d]Z`d^Zad_Zbd`ZcdaZddbZedcZfddZgdeZhdfZidgZjdhZkdiZldjZmdkZndlZodmZpdnZqdoZrdpZsdqZtdrZudsZvdtZwduZxdvZydwZzdxZ{dyZ|dzZ}d{Z~d|Zd}Zd~ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZdZd ZdZdZdZdZdZdZ	dZ
dZd	Zd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"d Z#d!Z$d"Z%d#Z&d$Z'd%Z(d&Z)d'Z*d(Z+d)Z,d*Z-d+Z.d,Z/d-Z0d.Z1d/Z2d0Z3d1Z4d2Z5d3Z6d4Z7d5Z8d6Z9d7Z:d8Z;d9Z<d:Z=d;Z>d<Z?d=Z@d>ZAd?ZBd@ZCdAZDdBZEdCZFdDZGdEZHdFZIdGZJdHZKdIZLdJZMdKZNdLZOdMZPdNZQdOZRdPZSdQZTdRZUdSZVdTZWdUZXdVZYdWZZdXZ[dYZ\dZZ]d[Z^d\Z_d]Z`d^Zad_Zbd`ZcdaZddbZedcZfddZgdeZhdfZidgZjdhZkdiZldjZmdkZndlZodmZpdnZqdoZrdpZsdqZtdrZudsZvdtZwduZxdvZydwZzdxZ{dyZ|dzZ}d{Z~d|Zd}Zd~ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZidd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd  6dd! 6dd" 6dd# 6dd$ 6d d% 6dd& 6dd' 6dd( 6dd) 6dd* 6dd+ 6dd, 6dd- 6d	d. 6d
d/ 6dd0 6dd1 6dd2 6dd3 6dd4 6dd5 6dd6 6dd7 6dd8 6dd9 6dd: 6dd; 6dd< 6dd= 6dd> 6dd? 6dd@ 6ddA 6ddB 6ddC 6ddD 6d dE 6d!dF 6d"dG 6d#dH 6d$dI 6d%dJ 6d&dK 6d'dL 6d(dM 6d)dN 6d*dO 6d+dP 6d,dQ 6d-dR 6d.dS 6d/dT 6d0dU 6d1dV 6d2dW 6d3dX 6d4dY 6d5dZ 6d6d[ 6d7d\ 6d8d] 6d9d^ 6d:d_ 6d;d` 6d<da 6d=db 6d>dc 6d?dd 6d@de 6dAdf 6dBdg 6dCdh 6dDdi 6dEdj 6dFdk 6dGdl 6dHdm 6dIdn 6dJdo 6dKdp 6dLdq 6dMdr 6dNds 6dOdt 6dPdu 6dQdv 6dRdw 6dSdx 6dTdy 6dUdz 6dVd{ 6dWd| 6dXd} 6dYd~ 6dZd 6d[d 6d\d 6d]d 6d^d 6d_d 6d`d 6dad 6dbd 6dcd 6ddd 6ded 6dfd 6dgd 6dhd 6did 6djd 6dkd 6dld 6dmd 6dnd 6dod 6dpd 6dqd 6drd 6dsd 6dtd 6dud 6dvd 6dwd 6dxd 6dyd 6dzd 6d{d 6d|d 6d}d 6d~d 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd 6dd6dd6dd6dd6dd6dd6dd6dd6dd	6dd
6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd 6dd!6dd"6dd#6dd$6d d%6dd&6dd'6dd(6dd)6dd*6dd+6dd,6dd-6d	d.6d
d/6dd06dd16dd26dd36dd46dd56dd66dd76dd86dd96dd:6dd;6dd<6dd=6dd>6dd?6dd@6ddA6ddB6ddC6ddD6d dE6d!dF6d"dG6d#dH6d$dI6d%dJ6d&dK6d'dL6d(dM6d)dN6d*dO6d+dP6d,dQ6d-dR6d.dS6d/dT6d0dU6d1dV6d2dW6d3dX6d4dY6d5dZ6d6d[6d7d\6d8d]6d9d^6d:d_6d;d`6d<da6d=db6d>dc6d?dd6d@de6dAdf6dBdg6dCdh6dDdi6dEdj6dFdk6dGdl6dHdm6dIdn6dJdo6dKdp6dLdq6dMdr6dNds6dOdt6dPdu6dQdv6dRdw6dSdx6dTdy6dUdz6dVd{6dWd|6dXd}6dYd~6dZd6d[d6d\d6d]d6d^d6d_d6d`d6dad6dbd6dcd6ddd6ded6dfd6dgd6dhd6did6djd6dkd6dld6dmd6dnd6dod6dpd6dqd6drd6dsd6dtd6dud6dvd6dwd6dxd6dyd6dzd6d{d6d|d6d}d6d~d6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd 6dd6dd6dd6dd6dd6dd6dd6dd6dd	6dd
6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd 6dd!6dd"6dd#6dd$6d d%6dd&6dd'6dd(6dd)6dd*6dd+6dd,6dd-6d	d.6d
d/6dd06dd16dd26dd36dd46dd56dd66dd76dd86dd96dd:6dd;6dd<6dd=6dd>6dd?6dd@6ddA6ddB6ddC6ddD6d dE6d!dF6d"dG6d#dH6d$dI6d%dJ6d&dK6d'dL6d(dM6d)dN6d*dO6d+dP6d,dQ6d-dR6d.dS6d/dT6d0dU6d1dV6d2dW6d3dX6d4dY6d5dZ6d6d[6d7d\6d8d]6d9d^6d:d_6d;d`6d<da6d=db6d>dc6d?dd6d@de6dAdf6dBdg6dCdh6dDdi6dEdj6dFdk6dGdl6dHdm6dIdn6dJdo6dKdp6dLdq6dMdr6dNds6dOdt6dPdu6dQdv6dRdw6dSdx6dTdy6dUdz6dVd{6dWd|6dXd}6dYd~6dZd6d[d6d\d6d]d6d^d6d_d6d`d6dad6dbd6dcd6ddd6ded6dfd6dgd6dhd6did6djd6dkd6dld6dmd6dnd6dod6dpd6dqd6drd6dsd6dtd6dud6dvd6dwd6dxd6dyd6dzd6d{d6d|d6d}d6d~d6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6Zd  ej  D Z d  ej  D Zd  ej  D Zd  ej  D ZRS(  sY  
    A class to deal with colors.
    A color can be specified in four ways by the client:
    1) as a Color constant like Color.RED or Color.LIGHT_SKY_BLUE
    2) as a name like "red" or "light sky blue"
    3) as a six-character hex string like "#ff00cc"
    4) as a three-integer tuple like (255, 0, 198) where each int is in range 0-255
    c         G   s   t  j |   |  _ d S(   s%   
        Constructs a color.
        N(   R   t   to_namet
   hex_string(   R(   R+  (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR^   b  s    c         C   s   |  j  S(   s@   
        Returns a string representation of this color.
        (   RK  (   R(   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   __str__h  s    c         C   s7   |  t  k p6 t  j |   p6 t  j |   p6 t  j |   S(   s   
        Returns True if the color passed is a valid color in any form, such as
        a Color object, a hex string such as "#ff00cc", a color name such as "red" or "light sky blue",
        or RGB color expressed as a 3-element tuple or list.
        (   R   t   is_hext   is_namet   is_rgb(   R   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR   n  s    c         C   so   t  |  t  rg |  j   }  |  d d k r/ t Sx1 t d t |    D] } |  | d k rE t SqE Wt St Sd S(   sa   
        Returns True if the color passed is a valid hex color string such as "#ff00cc".
        i    t   #i   t   0123456789abcdefN(   R   R   Rm   R   R   R   R<   (   R   R   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyRM  w  s    c         C   s"   t  |  t  o! |  j   t j k S(   sk   
        Returns True if the color passed is a valid color name such as "red" or "light sky blue".
        (   R   R   Rm   R   t   NAME_TO_RGB_LC(   R   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyRN    s    c         C   s   |  d k r t St |  t  s. t |  t  r t |   d k rD t Sd |  d k o_ d k n o d |  d k o d k n o d |  d k o d k SSt Sd S(   so   
        Returns True if the color passed is a valid RGB color expressed as a 3-element tuple or list.
        i   i    i   i   i   N(   R   R   R   R   R   R   (   R   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyRO    s    \c          G   sn  t  |   d k r t  n  |  d d k r/ d St |  d t  rP t |  d  St  |   d k r t j |   rT|  \ } } } d t |  t |  t |  f Sn t |  d t  rt j |  d  r |  d S|  d j	   t j
 k rt j
 |  d j	   St d t |  d    n5 t |  d t  rTt  |  d  d k rTd |  d St d t |     d S(   s  
        Converts a color into a hex color string such as "#ff00ff".
        Accepts a Color in any format, such as a Color object, a color name, a hex string, or tuple of three RGB integers from 0-255.
        If an invalid color is passed, raises a ValueError.
        i    i   s   #%02x%02x%02xs   invalid color: N(   R   R   R   R   R   R   RO  Rc   RM  Rm   t   NAME_TO_HEX_LCR   (   R+  R   R   R   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR     s&    	&)c          G   s1   t  j |    } | t  j k r) t  j | S| Sd S(   si  
        Converts a color into a color name string such as "red" or "light sky blue".
        Accepts a Color in any format, such as a Color object, a color name, a hex string, or tuple of three RGB integers from 0-255.
        If an invalid color is passed, or one that does not correspond to a color name, returns the hex string version of the color.
        N(   R   R   t   HEX_TO_NAME(   R+  RK  (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyRJ    s    c          G   sv   t  j |    } t |  j d d  } t | d d !d  } t | d d !d  } t | d d !d  } | | | f S(   s>  
        Converts a color into an RGB tuple such as (255, 0, 128).
        Accepts a Color in any format, such as a Color object, a color name, a hex string, or tuple of three RGB integers from 0-255.
        If an invalid color is passed, or one that does not correspond to a color name, raises a ValueError.
        RP  R   i    i   i   i   i   (   R   R   R   t   replaceRc   (   R+  RK  R   R   R   (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR     s    c         C   sJ   d d d g } x4 | D], } | |  k r t  j |  |  |  | <q q Wd S(   s   
        Makes sure that any color values in the given dict are in normalized hex string form,
        not tuples or color names.
        Not to be called by students.
        R   R   R   N(   R   R   (   RZ   t   keysR  (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR     s    s
   alice bluet	   AliceBlues   antique whitet   AntiqueWhitet   AntiqueWhite1t   AntiqueWhite2t   AntiqueWhite3t   AntiqueWhite4t
   aquamarinet   aquamarine1t   aquamarine2t   aquamarine3t   aquamarine4t   azuret   azure1t   azure2t   azure3t   azure4t   beiget   bisquet   bisque1t   bisque2t   bisque3t   bisque4R   s   blanched almondt   BlanchedAlmondt   blues   blue violett   blue1t   blue2t   blue3t   blue4t
   BlueViolett   brownt   brown1t   brown2t   brown3t   brown4t	   burlywoodt
   burlywood1t
   burlywood2t
   burlywood3t
   burlywood4s
   cadet bluet	   CadetBluet
   CadetBlue1t
   CadetBlue2t
   CadetBlue3t
   CadetBlue4t
   chartreuset   chartreuse1t   chartreuse2t   chartreuse3t   chartreuse4t	   chocolatet
   chocolate1t
   chocolate2t
   chocolate3t
   chocolate4t   coralt   coral1t   coral2t   coral3t   coral4s   cornflower bluet   CornflowerBluet   cornsilkt	   cornsilk1t	   cornsilk2t	   cornsilk3t	   cornsilk4t   cyant   cyan1t   cyan2t   cyan3t   cyan4s	   dark blues	   dark cyans   dark goldenrods	   dark grays
   dark greens	   dark greys
   dark khakis   dark magentas   dark olive greens   dark oranges   dark orchids   dark reds   dark salmons   dark sea greens   dark slate blues   dark slate grays   dark slate greys   dark turquoises   dark violett   DarkBluet   DarkCyant   DarkGoldenrodt   DarkGoldenrod1t   DarkGoldenrod2t   DarkGoldenrod3t   DarkGoldenrod4t   DarkGrayt	   DarkGreent   DarkGreyt	   DarkKhakit   DarkMagentat   DarkOliveGreent   DarkOliveGreen1t   DarkOliveGreen2t   DarkOliveGreen3t   DarkOliveGreen4t
   DarkOranget   DarkOrange1t   DarkOrange2t   DarkOrange3t   DarkOrange4t
   DarkOrchidt   DarkOrchid1t   DarkOrchid2t   DarkOrchid3t   DarkOrchid4t   DarkRedt
   DarkSalmont   DarkSeaGreent   DarkSeaGreen1t   DarkSeaGreen2t   DarkSeaGreen3t   DarkSeaGreen4t   DarkSlateBluet   DarkSlateGrayt   DarkSlateGray1t   DarkSlateGray2t   DarkSlateGray3t   DarkSlateGray4t   DarkSlateGreyt   DarkTurquoiset
   DarkViolets	   deep pinks   deep sky bluet   DeepPinkt	   DeepPink1t	   DeepPink2t	   DeepPink3t	   DeepPink4t   DeepSkyBluet   DeepSkyBlue1t   DeepSkyBlue2t   DeepSkyBlue3t   DeepSkyBlue4s   dim grays   dim greyt   DimGrayt   DimGreys   dodger bluet
   DodgerBluet   DodgerBlue1t   DodgerBlue2t   DodgerBlue3t   DodgerBlue4t	   firebrickt
   firebrick1t
   firebrick2t
   firebrick3t
   firebrick4s   floral whitet   FloralWhites   forest greent   ForestGreent	   gainsboros   ghost whitet
   GhostWhitet   goldt   gold1t   gold2t   gold3t   gold4t	   goldenrodt
   goldenrod1t
   goldenrod2t
   goldenrod3t
   goldenrod4t   grayt   gray0t   gray1t   gray2t   gray3t   gray4t   gray5t   gray6t   gray7t   gray8t   gray9t   gray10t   gray11t   gray12t   gray13t   gray14t   gray15t   gray16t   gray17t   gray18t   gray19t   gray20t   gray21t   gray22t   gray23t   gray24t   gray25t   gray26t   gray27t   gray28t   gray29t   gray30t   gray31t   gray32t   gray33t   gray34t   gray35t   gray36t   gray37t   gray38t   gray39t   gray40t   gray41t   gray42t   gray43t   gray44t   gray45t   gray46t   gray47t   gray48t   gray49t   gray50t   gray51t   gray52t   gray53t   gray54t   gray55t   gray56t   gray57t   gray58t   gray59t   gray60t   gray61t   gray62t   gray63t   gray64t   gray65t   gray66t   gray67t   gray68t   gray69t   gray70t   gray71t   gray72t   gray73t   gray74t   gray75t   gray76t   gray77t   gray78t   gray79t   gray80t   gray81t   gray82t   gray83t   gray84t   gray85t   gray86t   gray87t   gray88t   gray89t   gray90t   gray91t   gray92t   gray93t   gray94t   gray95t   gray96t   gray97t   gray98t   gray99t   gray100t   greens   green yellowt   green1t   green2t   green3t   green4t   GreenYellowt   greyt   grey0t   grey1t   grey2t   grey3t   grey4t   grey5t   grey6t   grey7t   grey8t   grey9t   grey10t   grey11t   grey12t   grey13t   grey14t   grey15t   grey16t   grey17t   grey18t   grey19t   grey20t   grey21t   grey22t   grey23t   grey24t   grey25t   grey26t   grey27t   grey28t   grey29t   grey30t   grey31t   grey32t   grey33t   grey34t   grey35t   grey36t   grey37t   grey38t   grey39t   grey40t   grey41t   grey42t   grey43t   grey44t   grey45t   grey46t   grey47t   grey48t   grey49t   grey50t   grey51t   grey52t   grey53t   grey54t   grey55t   grey56t   grey57t   grey58t   grey59t   grey60t   grey61t   grey62t   grey63t   grey64t   grey65t   grey66t   grey67t   grey68t   grey69t   grey70t   grey71t   grey72t   grey73t   grey74t   grey75t   grey76t   grey77t   grey78t   grey79t   grey80t   grey81t   grey82t   grey83t   grey84t   grey85t   grey86t   grey87t   grey88t   grey89t   grey90t   grey91t   grey92t   grey93t   grey94t   grey95t   grey96t   grey97t   grey98t   grey99t   grey100t   honeydewt	   honeydew1t	   honeydew2t	   honeydew3t	   honeydew4s   hot pinkt   HotPinkt   HotPink1t   HotPink2t   HotPink3t   HotPink4s
   indian redt	   IndianRedt
   IndianRed1t
   IndianRed2t
   IndianRed3t
   IndianRed4t   ivoryt   ivory1t   ivory2t   ivory3t   ivory4t   khakit   khaki1t   khaki2t   khaki3t   khaki4t   lavenders   lavender blusht   LavenderBlusht   LavenderBlush1t   LavenderBlush2t   LavenderBlush3t   LavenderBlush4s
   lawn greent	   LawnGreens   lemon chiffont   LemonChiffont   LemonChiffon1t   LemonChiffon2t   LemonChiffon3t   LemonChiffon4s
   light blues   light corals
   light cyans   light goldenrods   light goldenrod yellows
   light grays   light greens
   light greys
   light pinks   light salmons   light sea greens   light sky blues   light slate blues   light slate grays   light slate greys   light steel blues   light yellowt	   LightBluet
   LightBlue1t
   LightBlue2t
   LightBlue3t
   LightBlue4t
   LightCoralt	   LightCyant
   LightCyan1t
   LightCyan2t
   LightCyan3t
   LightCyan4t   LightGoldenrodt   LightGoldenrod1t   LightGoldenrod2t   LightGoldenrod3t   LightGoldenrod4t   LightGoldenrodYellowt	   LightGrayt
   LightGreent	   LightGreyt	   LightPinkt
   LightPink1t
   LightPink2t
   LightPink3t
   LightPink4t   LightSalmont   LightSalmon1t   LightSalmon2t   LightSalmon3t   LightSalmon4t   LightSeaGreent   LightSkyBluet   LightSkyBlue1t   LightSkyBlue2t   LightSkyBlue3t   LightSkyBlue4t   LightSlateBluet   LightSlateGrayt   LightSlateGreyt   LightSteelBluet   LightSteelBlue1t   LightSteelBlue2t   LightSteelBlue3t   LightSteelBlue4t   LightYellowt   LightYellow1t   LightYellow2t   LightYellow3t   LightYellow4s
   lime greent	   LimeGreent   linent   magentat   magenta1t   magenta2t   magenta3t   magenta4t   maroont   maroon1t   maroon2t   maroon3t   maroon4s   medium aquamarines   medium blues   medium orchids   medium purples   medium sea greens   medium slate blues   medium spring greens   medium turquoises   medium violet redt   MediumAquamarinet
   MediumBluet   MediumOrchidt   MediumOrchid1t   MediumOrchid2t   MediumOrchid3t   MediumOrchid4t   MediumPurplet   MediumPurple1t   MediumPurple2t   MediumPurple3t   MediumPurple4t   MediumSeaGreent   MediumSlateBluet   MediumSpringGreent   MediumTurquoiset   MediumVioletReds   midnight bluet   MidnightBlues
   mint creamt	   MintCreams
   misty roset	   MistyRoset
   MistyRose1t
   MistyRose2t
   MistyRose3t
   MistyRose4t   moccasins   navajo whitet   NavajoWhitet   NavajoWhite1t   NavajoWhite2t   NavajoWhite3t   NavajoWhite4t   navys	   navy bluet   NavyBlues   old lacet   OldLaces
   olive drabt	   OliveDrabt
   OliveDrab1t
   OliveDrab2t
   OliveDrab3t
   OliveDrab4t   oranges
   orange redt   orange1t   orange2t   orange3t   orange4t	   OrangeRedt
   OrangeRed1t
   OrangeRed2t
   OrangeRed3t
   OrangeRed4t   orchidt   orchid1t   orchid2t   orchid3t   orchid4s   pale goldenrods
   pale greens   pale turquoises   pale violet redt   PaleGoldenrodt	   PaleGreent
   PaleGreen1t
   PaleGreen2t
   PaleGreen3t
   PaleGreen4t   PaleTurquoiset   PaleTurquoise1t   PaleTurquoise2t   PaleTurquoise3t   PaleTurquoise4t   PaleVioletRedt   PaleVioletRed1t   PaleVioletRed2t   PaleVioletRed3t   PaleVioletRed4s   papaya whipt
   PapayaWhips
   peach pufft	   PeachPufft
   PeachPuff1t
   PeachPuff2t
   PeachPuff3t
   PeachPuff4t   perut   pinkt   pink1t   pink2t   pink3t   pink4t   plumt   plum1t   plum2t   plum3t   plum4s   powder bluet
   PowderBluet   purplet   purple1t   purple2t   purple3t   purple4t   redt   red1t   red2t   red3t   red4s
   rosy brownt	   RosyBrownt
   RosyBrown1t
   RosyBrown2t
   RosyBrown3t
   RosyBrown4s
   royal bluet	   RoyalBluet
   RoyalBlue1t
   RoyalBlue2t
   RoyalBlue3t
   RoyalBlue4s   saddle brownt   SaddleBrownt   salmont   salmon1t   salmon2t   salmon3t   salmon4s   sandy brownt
   SandyBrowns	   sea greent   SeaGreent	   SeaGreen1t	   SeaGreen2t	   SeaGreen3t	   SeaGreen4t   seashellt	   seashell1t	   seashell2t	   seashell3t	   seashell4t   siennat   sienna1t   sienna2t   sienna3t   sienna4s   sky bluet   SkyBluet   SkyBlue1t   SkyBlue2t   SkyBlue3t   SkyBlue4s
   slate blues
   slate grays
   slate greyt	   SlateBluet
   SlateBlue1t
   SlateBlue2t
   SlateBlue3t
   SlateBlue4t	   SlateGrayt
   SlateGray1t
   SlateGray2t
   SlateGray3t
   SlateGray4t	   SlateGreyt   snowt   snow1t   snow2t   snow3t   snow4s   spring greent   SpringGreent   SpringGreen1t   SpringGreen2t   SpringGreen3t   SpringGreen4s
   steel bluet	   SteelBluet
   SteelBlue1t
   SteelBlue2t
   SteelBlue3t
   SteelBlue4t   tant   tan1t   tan2t   tan3t   tan4t   thistlet   thistle1t   thistle2t   thistle3t   thistle4t   tomatot   tomato1t   tomato2t   tomato3t   tomato4t	   turquoiset
   turquoise1t
   turquoise2t
   turquoise3t
   turquoise4t   violets
   violet redt	   VioletRedt
   VioletRed1t
   VioletRed2t
   VioletRed3t
   VioletRed4t   wheatt   wheat1t   wheat2t   wheat3t   wheat4R   s   white smoket
   WhiteSmoket   yellows   yellow greent   yellow1t   yellow2t   yellow3t   yellow4t   YellowGreeni   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   ix   i   i   iv   i   if   i   iE   it   i   i   i   i   i   i   i   i   i   i}   ik   i    i   i+   i   i   i*   i@   i;   i3   i#   i   i   i   i   i   i   i   is   iU   i_   i   i   i   i   iz   iS   i   i   ii   i   i$   i!   i   i   iP   ir   iV   ij   i[   i>   i/   id   i   i   i   i   i   i   i   i   i   i   i   i2   i   i   i   i   iH   i=   iO   i   i   i   i   i   i   i   i   ie   i   i   ip   ih   i   iZ   in   i   i   i:   i   i"   i   i   i   iy   iR   i   i   i   i   i   i
   i   i   i   iN   i0   i,   i&   i   i   iu   i   i    i%   i   i   i   i   i   i   i)   i.   i6   i8   iB   iG   iJ   iM   iT   iW   iY   i\   i^   ia   ic   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i`   ib   i   i   i|   i   i   i   i   i   iw   i   i   iL   i   i   i{   i   i4   i<   iq   i   i7   i   i]   i   i   i   i   i   i   i?   il   iA   iC   i'   i9   i   i-   i~   io   ig   iF   i   iI   i   i   c         C   s%   i  |  ] \ } } | | j     q S(    (   Rm   (   t   .0t   kt   v(    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pys
   <dictcomp>  s   	 c         C   s)   i  |  ] \ } } d  | | j     q S(   s   #%02x%02x%02x(   Rm   (   R  R  R  (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pys
   <dictcomp>  s   	 c         C   s   i  |  ] \ } } | |  q S(    (    (   R  R  R  (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pys
   <dictcomp>  s   	 c         C   s#   i  |  ] \ } } | d  |  q S(   s   #%02x%02x%02x(    (   R  R  R  (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pys
   <dictcomp>  s   	 (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   ix   (   i   i   i   (   i   i   i   (   iv   i   i   (   if   i   i   (   iE   i   it   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i}   ik   (   i    i    i    (   i   i   i   (   i   i   i   (   i    i    i   (   i   i+   i   (   i    i    i   (   i    i    i   (   i    i    i   (   i    i    i   (   i   i+   i   (   i   i*   i*   (   i   i@   i@   (   i   i;   i;   (   i   i3   i3   (   i   i#   i#   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i}   (   i   is   iU   (   i_   i   i   (   i_   i   i   (   i   i   i   (   i   i   i   (   iz   i   i   (   iS   i   i   (   i   i   i    (   i   i   i    (   iv   i   i    (   if   i   i    (   iE   i   i    (   i   ii   i   (   i   i   i$   (   i   iv   i!   (   i   if   i   (   i   iE   i   (   i   i   iP   (   i   ir   iV   (   i   ij   iP   (   i   i[   iE   (   i   i>   i/   (   id   i   i   (   id   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   ix   (   i    i   i   (   i    i   i   (   i    i   i   (   i    i   i   (   i    i   i   (   i    i    i   (   i    i   i   (   i   i   i   (   i   i   i   (   i    id   i    (   i   i   i   (   i   i   ik   (   i   i    i   (   iU   ik   i/   (   i   i   i    (   i   i2   i   (   i   i    i    (   i   i   iz   (   i   i   i   (   iH   i=   i   (   i/   iO   iO   (   i/   iO   iO   (   i    i   i   (   i   i    i   (   i    i    i   (   i    i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   ie   i   (   i   i   i   (   i    id   i    (   i   i   i   (   i   i   ik   (   i   i    i   (   iU   ik   i/   (   i   i   ip   (   i   i   ih   (   i   i   iZ   (   in   i   i=   (   i   i   i    (   i   i   i    (   i   iv   i    (   i   if   i    (   i   iE   i    (   i   i2   i   (   i   i>   i   (   i   i:   i   (   i   i2   i   (   ih   i"   i   (   i   i    i    (   i   i   iz   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   ii   i   ii   (   iH   i=   i   (   i/   iO   iO   (   i   i   i   (   i   i   i   (   iy   i   i   (   iR   i   i   (   i/   iO   iO   (   i    i   i   (   i   i    i   (   i   i   i   (   i    i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   iv   (   i   i
   iP   (   i    i   i   (   i    i   i   (   i    i   i   (   i    i   i   (   i    ih   i   (   ii   ii   ii   (   ii   ii   ii   (   ii   ii   ii   (   ii   ii   ii   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   it   i   (   i   iN   i   (   i   i"   i"   (   i   i0   i0   (   i   i,   i,   (   i   i&   i&   (   i   i   i   (   i   i   i   (   i   i   i   (   i"   i   i"   (   i"   i   i"   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i    (   i   i   i    (   i   i   i    (   i   i   i    (   i   iu   i    (   i   i   i    (   i   i   i%   (   i   i   i"   (   i   i   i   (   i   ii   i   (   i   i   i   (   i    i    i    (   i   i   i   (   i   i   i   (   i   i   i   (   i
   i
   i
   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i!   i!   i!   (   i$   i$   i$   (   i&   i&   i&   (   i)   i)   i)   (   i+   i+   i+   (   i.   i.   i.   (   i0   i0   i0   (   i3   i3   i3   (   i6   i6   i6   (   i8   i8   i8   (   i;   i;   i;   (   i=   i=   i=   (   i@   i@   i@   (   iB   iB   iB   (   iE   iE   iE   (   iG   iG   iG   (   iJ   iJ   iJ   (   iM   iM   iM   (   iO   iO   iO   (   iR   iR   iR   (   iT   iT   iT   (   iW   iW   iW   (   iY   iY   iY   (   i\   i\   i\   (   i^   i^   i^   (   ia   ia   ia   (   ic   ic   ic   (   if   if   if   (   ii   ii   ii   (   ik   ik   ik   (   in   in   in   (   ip   ip   ip   (   is   is   is   (   iu   iu   iu   (   ix   ix   ix   (   iz   iz   iz   (   i}   i}   i}   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i    i   i    (   i   i   i/   (   i    i   i    (   i    i   i    (   i    i   i    (   i    i   i    (   i   i   i/   (   i   i   i   (   i    i    i    (   i   i   i   (   i   i   i   (   i   i   i   (   i
   i
   i
   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i!   i!   i!   (   i$   i$   i$   (   i&   i&   i&   (   i)   i)   i)   (   i+   i+   i+   (   i.   i.   i.   (   i0   i0   i0   (   i3   i3   i3   (   i6   i6   i6   (   i8   i8   i8   (   i;   i;   i;   (   i=   i=   i=   (   i@   i@   i@   (   iB   iB   iB   (   iE   iE   iE   (   iG   iG   iG   (   iJ   iJ   iJ   (   iM   iM   iM   (   iO   iO   iO   (   iR   iR   iR   (   iT   iT   iT   (   iW   iW   iW   (   iY   iY   iY   (   i\   i\   i\   (   i^   i^   i^   (   ia   ia   ia   (   ic   ic   ic   (   if   if   if   (   ii   ii   ii   (   ik   ik   ik   (   in   in   in   (   ip   ip   ip   (   is   is   is   (   iu   iu   iu   (   ix   ix   ix   (   iz   iz   iz   (   i}   i}   i}   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   ii   i   (   i   ii   i   (   i   in   i   (   i   ij   i   (   i   i`   i   (   i   i:   ib   (   i   i\   i\   (   i   i\   i\   (   i   ij   ij   (   i   ic   ic   (   i   iU   iU   (   i   i:   i:   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   is   (   i   i   iN   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i|   i   i    (   i|   i   i    (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   ip   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   iz   (   i    i   i   (   i   i   i   (   i   ip   i   (   iw   i   i   (   iw   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   ih   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   iz   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   ip   (   i   i   iL   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i_   ie   (   i   i   iz   (   i   i   iz   (   i   i   ir   (   i   i   ib   (   i   iW   iB   (   i    i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i`   i{   i   (   i   ip   i   (   iw   i   i   (   iw   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   in   i{   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   iz   (   i2   i   i2   (   i2   i   i2   (   i   i   i   (   i   i    i   (   i   i    i   (   i   i    i   (   i   i    i   (   i   i    i   (   i   i0   i`   (   i   i4   i   (   i   i0   i   (   i   i)   i   (   i   i   ib   (   if   i   i   (   i    i    i   (   i   iU   i   (   i   ip   i   (   i<   i   iq   (   i{   ih   i   (   i    i   i   (   iH   i   i   (   i   i   i   (   if   i   i   (   i    i    i   (   i   iU   i   (   i   if   i   (   i   i_   i   (   i   iR   i   (   iz   i7   i   (   i   ip   i   (   i   i   i   (   i   iy   i   (   i   ih   i   (   i]   iG   i   (   i<   i   iq   (   i{   ih   i   (   i    i   i   (   iH   i   i   (   i   i   i   (   i   i   ip   (   i   i   ip   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i}   i{   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   iy   i^   (   i    i    i   (   i    i    i   (   i    i    i   (   i   i   i   (   i   i   i   (   ik   i   i#   (   ik   i   i#   (   i   i   i>   (   i   i   i:   (   i   i   i2   (   ii   i   i"   (   i   i   i    (   i   iE   i    (   i   i   i    (   i   i   i    (   i   i   i    (   i   iZ   i    (   i   iE   i    (   i   iE   i    (   i   i@   i    (   i   i7   i    (   i   i%   i    (   i   ip   i   (   i   i   i   (   i   iz   i   (   i   ii   i   (   i   iG   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   ip   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i|   i   i|   (   iT   i   iT   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   if   i   i   (   i   ip   i   (   i   i   i   (   i   iy   i   (   i   ih   i   (   i   iG   i]   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   iw   ie   (   i   i   i?   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   ic   il   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   if   i   (   i   i   i   (   i   i   i   (   i   i    i   (   i   i0   i   (   i   i,   i   (   i}   i&   i   (   iU   i   i   (   i   i    i    (   i   i    i    (   i   i    i    (   i   i    i    (   i   i    i    (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   ii   ii   (   iA   ii   i   (   iA   ii   i   (   iH   iv   i   (   iC   in   i   (   i:   i_   i   (   i'   i@   i   (   i   iE   i   (   i   iE   i   (   i   i   ir   (   i   i   ii   (   i   i   ib   (   i   ip   iT   (   i   iL   i9   (   i   i   i`   (   i   i   i`   (   i.   i   iW   (   i.   i   iW   (   iT   i   i   (   iN   i   i   (   iC   i   i   (   i.   i   iW   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   iR   i-   (   i   i   iG   (   i   iy   iB   (   i   ih   i9   (   i   iG   i&   (   i   i   i   (   i   i   i   (   i   i   i   (   i~   i   i   (   il   i   i   (   iJ   ip   i   (   ij   iZ   i   (   ip   i   i   (   ip   i   i   (   ij   iZ   i   (   i   io   i   (   iz   ig   i   (   ii   iY   i   (   iG   i<   i   (   ip   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   il   i{   i   (   ip   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i    i   i   (   i    i   i   (   i    i   i   (   i    i   iv   (   i    i   if   (   i    i   iE   (   iF   i   i   (   iF   i   i   (   ic   i   i   (   i\   i   i   (   iO   i   i   (   i6   id   i   (   i   i   i   (   i   i   iO   (   i   i   iI   (   i   i   i?   (   i   iZ   i+   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i{   i   (   i   ic   iG   (   i   ic   iG   (   i   i\   iB   (   i   iO   i9   (   i   i6   i&   (   i@   i   i   (   i    i   i   (   i    i   i   (   i    i   i   (   i    i   i   (   i   i   i   (   i   i    i   (   i   i    i   (   i   i>   i   (   i   i:   i   (   i   i2   ix   (   i   i"   iR   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i~   if   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i    (   i   i   i2   (   i   i   i    (   i   i   i    (   i   i   i    (   i   i   i    (   i   i   i2   (  RD  RE  RF  R^   RL  RG  R   RM  RN  RO  R   RJ  R   R   t
   ALICE_BLUEt	   ALICEBLUEt   ANTIQUE_WHITEt   ANTIQUEWHITEt   ANTIQUEWHITE1t   ANTIQUEWHITE2t   ANTIQUEWHITE3t   ANTIQUEWHITE4t
   AQUAMARINEt   AQUAMARINE1t   AQUAMARINE2t   AQUAMARINE3t   AQUAMARINE4t   AZUREt   AZURE1t   AZURE2t   AZURE3t   AZURE4t   BEIGEt   BISQUEt   BISQUE1t   BISQUE2t   BISQUE3t   BISQUE4t   BLACKt   BLANCHED_ALMONDt   BLANCHEDALMONDt   BLUEt   BLUE_VIOLETt   BLUE1t   BLUE2t   BLUE3t   BLUE4t
   BLUEVIOLETt   BROWNt   BROWN1t   BROWN2t   BROWN3t   BROWN4t	   BURLYWOODt
   BURLYWOOD1t
   BURLYWOOD2t
   BURLYWOOD3t
   BURLYWOOD4t
   CADET_BLUEt	   CADETBLUEt
   CADETBLUE1t
   CADETBLUE2t
   CADETBLUE3t
   CADETBLUE4t
   CHARTREUSEt   CHARTREUSE1t   CHARTREUSE2t   CHARTREUSE3t   CHARTREUSE4t	   CHOCOLATEt
   CHOCOLATE1t
   CHOCOLATE2t
   CHOCOLATE3t
   CHOCOLATE4t   CORALt   CORAL1t   CORAL2t   CORAL3t   CORAL4t   CORNFLOWER_BLUEt   CORNFLOWERBLUEt   CORNSILKt	   CORNSILK1t	   CORNSILK2t	   CORNSILK3t	   CORNSILK4t   CYANt   CYAN1t   CYAN2t   CYAN3t   CYAN4t	   DARK_BLUEt	   DARK_CYANt   DARK_GOLDENRODt	   DARK_GRAYt
   DARK_GREENt	   DARK_GREYt
   DARK_KHAKIt   DARK_MAGENTAt   DARK_OLIVE_GREENt   DARK_ORANGEt   DARK_ORCHIDt   DARK_REDt   DARK_SALMONt   DARK_SEA_GREENt   DARK_SLATE_BLUEt   DARK_SLATE_GRAYt   DARK_SLATE_GREYt   DARK_TURQUOISEt   DARK_VIOLETt   DARKBLUEt   DARKCYANt   DARKGOLDENRODt   DARKGOLDENROD1t   DARKGOLDENROD2t   DARKGOLDENROD3t   DARKGOLDENROD4t   DARKGRAYt	   DARKGREENt   DARKGREYt	   DARKKHAKIt   DARKMAGENTAt   DARKOLIVEGREENt   DARKOLIVEGREEN1t   DARKOLIVEGREEN2t   DARKOLIVEGREEN3t   DARKOLIVEGREEN4t
   DARKORANGEt   DARKORANGE1t   DARKORANGE2t   DARKORANGE3t   DARKORANGE4t
   DARKORCHIDt   DARKORCHID1t   DARKORCHID2t   DARKORCHID3t   DARKORCHID4t   DARKREDt
   DARKSALMONt   DARKSEAGREENt   DARKSEAGREEN1t   DARKSEAGREEN2t   DARKSEAGREEN3t   DARKSEAGREEN4t   DARKSLATEBLUEt   DARKSLATEGRAYt   DARKSLATEGRAY1t   DARKSLATEGRAY2t   DARKSLATEGRAY3t   DARKSLATEGRAY4t   DARKSLATEGREYt   DARKTURQUOISEt
   DARKVIOLETt	   DEEP_PINKt   DEEP_SKY_BLUEt   DEEPPINKt	   DEEPPINK1t	   DEEPPINK2t	   DEEPPINK3t	   DEEPPINK4t   DEEPSKYBLUEt   DEEPSKYBLUE1t   DEEPSKYBLUE2t   DEEPSKYBLUE3t   DEEPSKYBLUE4t   DIM_GRAYt   DIM_GREYt   DIMGRAYt   DIMGREYt   DODGER_BLUEt
   DODGERBLUEt   DODGERBLUE1t   DODGERBLUE2t   DODGERBLUE3t   DODGERBLUE4t	   FIREBRICKt
   FIREBRICK1t
   FIREBRICK2t
   FIREBRICK3t
   FIREBRICK4t   FLORAL_WHITEt   FLORALWHITEt   FOREST_GREENt   FORESTGREENt	   GAINSBOROt   GHOST_WHITEt
   GHOSTWHITEt   GOLDt   GOLD1t   GOLD2t   GOLD3t   GOLD4t	   GOLDENRODt
   GOLDENROD1t
   GOLDENROD2t
   GOLDENROD3t
   GOLDENROD4t   GRAYt   GRAY0t   GRAY1t   GRAY2t   GRAY3t   GRAY4t   GRAY5t   GRAY6t   GRAY7t   GRAY8t   GRAY9t   GRAY10t   GRAY11t   GRAY12t   GRAY13t   GRAY14t   GRAY15t   GRAY16t   GRAY17t   GRAY18t   GRAY19t   GRAY20t   GRAY21t   GRAY22t   GRAY23t   GRAY24t   GRAY25t   GRAY26t   GRAY27t   GRAY28t   GRAY29t   GRAY30t   GRAY31t   GRAY32t   GRAY33t   GRAY34t   GRAY35t   GRAY36t   GRAY37t   GRAY38t   GRAY39t   GRAY40t   GRAY41t   GRAY42t   GRAY43t   GRAY44t   GRAY45t   GRAY46t   GRAY47t   GRAY48t   GRAY49t   GRAY50t   GRAY51t   GRAY52t   GRAY53t   GRAY54t   GRAY55t   GRAY56t   GRAY57t   GRAY58t   GRAY59t   GRAY60t   GRAY61t   GRAY62t   GRAY63t   GRAY64t   GRAY65t   GRAY66t   GRAY67t   GRAY68t   GRAY69t   GRAY70t   GRAY71t   GRAY72t   GRAY73t   GRAY74t   GRAY75t   GRAY76t   GRAY77t   GRAY78t   GRAY79t   GRAY80t   GRAY81t   GRAY82t   GRAY83t   GRAY84t   GRAY85t   GRAY86t   GRAY87t   GRAY88t   GRAY89t   GRAY90t   GRAY91t   GRAY92t   GRAY93t   GRAY94t   GRAY95t   GRAY96t   GRAY97t   GRAY98t   GRAY99t   GRAY100t   GREENt   GREEN_YELLOWt   GREEN1t   GREEN2t   GREEN3t   GREEN4t   GREENYELLOWt   GREYt   GREY0t   GREY1t   GREY2t   GREY3t   GREY4t   GREY5t   GREY6t   GREY7t   GREY8t   GREY9t   GREY10t   GREY11t   GREY12t   GREY13t   GREY14t   GREY15t   GREY16t   GREY17t   GREY18t   GREY19t   GREY20t   GREY21t   GREY22t   GREY23t   GREY24t   GREY25t   GREY26t   GREY27t   GREY28t   GREY29t   GREY30t   GREY31t   GREY32t   GREY33t   GREY34t   GREY35t   GREY36t   GREY37t   GREY38t   GREY39t   GREY40t   GREY41t   GREY42t   GREY43t   GREY44t   GREY45t   GREY46t   GREY47t   GREY48t   GREY49t   GREY50t   GREY51t   GREY52t   GREY53t   GREY54t   GREY55t   GREY56t   GREY57t   GREY58t   GREY59t   GREY60t   GREY61t   GREY62t   GREY63t   GREY64t   GREY65t   GREY66t   GREY67t   GREY68t   GREY69t   GREY70t   GREY71t   GREY72t   GREY73t   GREY74t   GREY75t   GREY76t   GREY77t   GREY78t   GREY79t   GREY80t   GREY81t   GREY82t   GREY83t   GREY84t   GREY85t   GREY86t   GREY87t   GREY88t   GREY89t   GREY90t   GREY91t   GREY92t   GREY93t   GREY94t   GREY95t   GREY96t   GREY97t   GREY98t   GREY99t   GREY100t   HONEYDEWt	   HONEYDEW1t	   HONEYDEW2t	   HONEYDEW3t	   HONEYDEW4t   HOT_PINKt   HOTPINKt   HOTPINK1t   HOTPINK2t   HOTPINK3t   HOTPINK4t
   INDIAN_REDt	   INDIANREDt
   INDIANRED1t
   INDIANRED2t
   INDIANRED3t
   INDIANRED4t   IVORYt   IVORY1t   IVORY2t   IVORY3t   IVORY4t   KHAKIt   KHAKI1t   KHAKI2t   KHAKI3t   KHAKI4t   LAVENDERt   LAVENDER_BLUSHt   LAVENDERBLUSHt   LAVENDERBLUSH1t   LAVENDERBLUSH2t   LAVENDERBLUSH3t   LAVENDERBLUSH4t
   LAWN_GREENt	   LAWNGREENt   LEMON_CHIFFONt   LEMONCHIFFONt   LEMONCHIFFON1t   LEMONCHIFFON2t   LEMONCHIFFON3t   LEMONCHIFFON4t
   LIGHT_BLUEt   LIGHT_CORALt
   LIGHT_CYANt   LIGHT_GOLDENRODt   LIGHT_GOLDENROD_YELLOWt
   LIGHT_GRAYt   LIGHT_GREENt
   LIGHT_GREYt
   LIGHT_PINKt   LIGHT_SALMONt   LIGHT_SEA_GREENt   LIGHT_SKY_BLUEt   LIGHT_SLATE_BLUEt   LIGHT_SLATE_GRAYt   LIGHT_SLATE_GREYt   LIGHT_STEEL_BLUEt   LIGHT_YELLOWt	   LIGHTBLUEt
   LIGHTBLUE1t
   LIGHTBLUE2t
   LIGHTBLUE3t
   LIGHTBLUE4t
   LIGHTCORALt	   LIGHTCYANt
   LIGHTCYAN1t
   LIGHTCYAN2t
   LIGHTCYAN3t
   LIGHTCYAN4t   LIGHTGOLDENRODt   LIGHTGOLDENROD1t   LIGHTGOLDENROD2t   LIGHTGOLDENROD3t   LIGHTGOLDENROD4t   LIGHTGOLDENRODYELLOWt	   LIGHTGRAYt
   LIGHTGREENt	   LIGHTGREYt	   LIGHTPINKt
   LIGHTPINK1t
   LIGHTPINK2t
   LIGHTPINK3t
   LIGHTPINK4t   LIGHTSALMONt   LIGHTSALMON1t   LIGHTSALMON2t   LIGHTSALMON3t   LIGHTSALMON4t   LIGHTSEAGREENt   LIGHTSKYBLUEt   LIGHTSKYBLUE1t   LIGHTSKYBLUE2t   LIGHTSKYBLUE3t   LIGHTSKYBLUE4t   LIGHTSLATEBLUEt   LIGHTSLATEGRAYt   LIGHTSLATEGREYt   LIGHTSTEELBLUEt   LIGHTSTEELBLUE1t   LIGHTSTEELBLUE2t   LIGHTSTEELBLUE3t   LIGHTSTEELBLUE4t   LIGHTYELLOWt   LIGHTYELLOW1t   LIGHTYELLOW2t   LIGHTYELLOW3t   LIGHTYELLOW4t
   LIME_GREENt	   LIMEGREENt   LINENt   MAGENTAt   MAGENTA1t   MAGENTA2t   MAGENTA3t   MAGENTA4t   MAROONt   MAROON1t   MAROON2t   MAROON3t   MAROON4t   MEDIUM_AQUAMARINEt   MEDIUM_BLUEt   MEDIUM_ORCHIDt   MEDIUM_PURPLEt   MEDIUM_SEA_GREENt   MEDIUM_SLATE_BLUEt   MEDIUM_SPRING_GREENt   MEDIUM_TURQUOISEt   MEDIUM_VIOLET_REDt   MEDIUMAQUAMARINEt
   MEDIUMBLUEt   MEDIUMORCHIDt   MEDIUMORCHID1t   MEDIUMORCHID2t   MEDIUMORCHID3t   MEDIUMORCHID4t   MEDIUMPURPLEt   MEDIUMPURPLE1t   MEDIUMPURPLE2t   MEDIUMPURPLE3t   MEDIUMPURPLE4t   MEDIUMSEAGREENt   MEDIUMSLATEBLUEt   MEDIUMSPRINGGREENt   MEDIUMTURQUOISEt   MEDIUMVIOLETREDt   MIDNIGHT_BLUEt   MIDNIGHTBLUEt
   MINT_CREAMt	   MINTCREAMt
   MISTY_ROSEt	   MISTYROSEt
   MISTYROSE1t
   MISTYROSE2t
   MISTYROSE3t
   MISTYROSE4t   MOCCASINt   NAVAJO_WHITEt   NAVAJOWHITEt   NAVAJOWHITE1t   NAVAJOWHITE2t   NAVAJOWHITE3t   NAVAJOWHITE4t   NAVYt	   NAVY_BLUEt   NAVYBLUEt   OLD_LACEt   OLDLACEt
   OLIVE_DRABt	   OLIVEDRABt
   OLIVEDRAB1t
   OLIVEDRAB2t
   OLIVEDRAB3t
   OLIVEDRAB4t   ORANGEt
   ORANGE_REDt   ORANGE1t   ORANGE2t   ORANGE3t   ORANGE4t	   ORANGEREDt
   ORANGERED1t
   ORANGERED2t
   ORANGERED3t
   ORANGERED4t   ORCHIDt   ORCHID1t   ORCHID2t   ORCHID3t   ORCHID4t   PALE_GOLDENRODt
   PALE_GREENt   PALE_TURQUOISEt   PALE_VIOLET_REDt   PALEGOLDENRODt	   PALEGREENt
   PALEGREEN1t
   PALEGREEN2t
   PALEGREEN3t
   PALEGREEN4t   PALETURQUOISEt   PALETURQUOISE1t   PALETURQUOISE2t   PALETURQUOISE3t   PALETURQUOISE4t   PALEVIOLETREDt   PALEVIOLETRED1t   PALEVIOLETRED2t   PALEVIOLETRED3t   PALEVIOLETRED4t   PAPAYA_WHIPt
   PAPAYAWHIPt
   PEACH_PUFFt	   PEACHPUFFt
   PEACHPUFF1t
   PEACHPUFF2t
   PEACHPUFF3t
   PEACHPUFF4t   PERUt   PINKt   PINK1t   PINK2t   PINK3t   PINK4t   PLUMt   PLUM1t   PLUM2t   PLUM3t   PLUM4t   POWDER_BLUEt
   POWDERBLUEt   PURPLEt   PURPLE1t   PURPLE2t   PURPLE3t   PURPLE4t   REDt   RED1t   RED2t   RED3t   RED4t
   ROSY_BROWNt	   ROSYBROWNt
   ROSYBROWN1t
   ROSYBROWN2t
   ROSYBROWN3t
   ROSYBROWN4t
   ROYAL_BLUEt	   ROYALBLUEt
   ROYALBLUE1t
   ROYALBLUE2t
   ROYALBLUE3t
   ROYALBLUE4t   SADDLE_BROWNt   SADDLEBROWNt   SALMONt   SALMON1t   SALMON2t   SALMON3t   SALMON4t   SANDY_BROWNt
   SANDYBROWNt	   SEA_GREENt   SEAGREENt	   SEAGREEN1t	   SEAGREEN2t	   SEAGREEN3t	   SEAGREEN4t   SEASHELLt	   SEASHELL1t	   SEASHELL2t	   SEASHELL3t	   SEASHELL4t   SIENNAt   SIENNA1t   SIENNA2t   SIENNA3t   SIENNA4t   SKY_BLUEt   SKYBLUEt   SKYBLUE1t   SKYBLUE2t   SKYBLUE3t   SKYBLUE4t
   SLATE_BLUEt
   SLATE_GRAYt
   SLATE_GREYt	   SLATEBLUEt
   SLATEBLUE1t
   SLATEBLUE2t
   SLATEBLUE3t
   SLATEBLUE4t	   SLATEGRAYt
   SLATEGRAY1t
   SLATEGRAY2t
   SLATEGRAY3t
   SLATEGRAY4t	   SLATEGREYt   SNOWt   SNOW1t   SNOW2t   SNOW3t   SNOW4t   SPRING_GREENt   SPRINGGREENt   SPRINGGREEN1t   SPRINGGREEN2t   SPRINGGREEN3t   SPRINGGREEN4t
   STEEL_BLUEt	   STEELBLUEt
   STEELBLUE1t
   STEELBLUE2t
   STEELBLUE3t
   STEELBLUE4t   TANt   TAN1t   TAN2t   TAN3t   TAN4t   THISTLEt   THISTLE1t   THISTLE2t   THISTLE3t   THISTLE4t   TOMATOt   TOMATO1t   TOMATO2t   TOMATO3t   TOMATO4t	   TURQUOISEt
   TURQUOISE1t
   TURQUOISE2t
   TURQUOISE3t
   TURQUOISE4t   VIOLETt
   VIOLET_REDt	   VIOLETREDt
   VIOLETRED1t
   VIOLETRED2t
   VIOLETRED3t
   VIOLETRED4t   WHEATt   WHEAT1t   WHEAT2t   WHEAT3t   WHEAT4t   WHITEt   WHITE_SMOKEt
   WHITESMOKEt   YELLOWt   YELLOW_GREENt   YELLOW1t   YELLOW2t   YELLOW3t   YELLOW4t   YELLOWGREENt   NAME_TO_RGBt   itemsRR  RS  t   RGB_TO_NAMERT  (    (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyR   Y  s  			
(   R   R   RW   R@  t   typesR  t   tkinterR    R   R   R   R   R   R   R   R   R	   R
   R   R   R   R   t   TkinterR#  R	  R   R   (    (    (    sZ   /home/stepp/Dropbox/data/docs/building-python-programs/chapters/ch03-files/DrawingPanel.pyt   <module>@   s(   .4(      