mς
‘sCHc           @   sQ   d  Z  d k Td k Z d k l Z d a d a d a d a d   Z	 d   Z
 d S(   s   GUI for 2D CA bike simulator(   t   *N(   s   SpDisplayStatei    c          C   s  yn t  t i    t i j p t  t i    t i j o2 t i t i t  t i    t  t i     n Wn t	 j
 o n Xxy t
 t  t i     D]_ } t i   t i   t t  x8 t i i   D]' }  |  i t i j o t i   qΡ qΡ Wq Wd S(   s`  	
		This is called each time the 'step' button is clicked.
		If the numbers in either the east-west or north-south 
		text fields are different, the CA will be reinitialized with
		those new numbers of bikes randomly distributed. 
		If the numbers are unchanged, the simulation will simply continue 
		the simulation with the current state of the CA.
	N(   t   intt   tVertt   gett   cat   vbikest   tHorizt   hbikest   __init__t   sizet
   ValueErrort   xranget   tStepCntt   it   stepht   stepvt   SpDisplayStatet   pygamet   eventt   typet   QUITt   syst   exit(   R   R   (    (    tL   /Users/chaos/Presentations/NonlinearPhysics 2008/Software/Part10_Code/gui.pyt   step   s     86 


  c         C   s  |  a t   } | i d  t | d d } t   }	 |	 i	 t
 t i   t | d d d |	 a t | d d } | i d	 d
 d d  | i d	 d d d d d  t i   t | d d }
 t   } | i	 t
 t i   t |
 d d d | a t |
 d d } | i d	 d
 d d  |
 i d	 d d d d d  t i   t | d d d t } | i d	 d
 d d  t | d d } t   } | i	 t
 |   t | d d d | a t | d d } | i d	 d
 d d  | i d	 d d d d d  t i   | S(   Nt
   Controllert   borderi   t   relieft   sunkent   textvariablet   texts   Number of E-W Bikest   sidet   topt   padxi    t   bottomi   t   padys   Number of N-S Bikest   Runt   commandt   Stepst   right(   t   CAR   t   Tkt   roott   titlet   Framet   fVertt	   StringVart   tVarHt   sett   strR   t   EntryR   t   Labelt   lVertt   packt   fHorizt   tVarVR   R   t   lHorizt   ButtonR   t   bStept   fStepCntt	   tVarStepst   numStepsR   t   lStepCnt(   R(   R=   R-   R8   R;   R>   R<   R4   R:   R/   R6   R*   R7   (    (    R   t   InitGUI+   s>     		
	
	
(   t   __doc__t   TkinterR   t	   cadisplayR   R   R   R   R   R   R?   (   R?   R   R   R   (    (    R   t   ?   s   		