ÿØÿà JFIF      ÿÛ „ 	 ( %!1!%)+//.383,7(-.+



-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ               ÿÄ J  	     ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ              ÿÄ *        !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍÑ¶¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
..............................................................................................................................................................................
.............................................................................                                                  
                                                                                                                                                                                     ÿØÿà JFIF      ÿÛ „ 	 ( %!1!%)+//.383,7(-.+



-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ               ÿÄ J  	     ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ              ÿÄ *        !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍÑ¶¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
..............................................................................................................................................................................
.............................................................................                                                  
                                                                                                                                                                                     
^c           @   s  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d d f \ Z Z	 Z
 d   Z d   Z d	   Z i e e 6e e	 6e e
 6Z i d
 e 6d e	 6d e
 6Z i e d
 6e	 d 6e
 d 6Z i d e 6d e	 6d e
 6Z d   Z d f  d     YZ d f  d     YZ d f  d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d   Z d   Z d   Z d   Z d d l Z d  f  d!     YZ d"   Z  d#   Z! e" d$ k re!   n  d S(%   s   SS1 -- a spreadsheet.iN(   t   expatt   LEFTt   CENTERt   RIGHTc         C   s   |  j  |  S(   N(   t   ljust(   t   xt   n(    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR      s    c         C   s   |  j  |  S(   N(   t   center(   R   R   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR      s    c         C   s   |  j  |  S(   N(   t   rjust(   R   R   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR      s    t   leftR   t   rightt   wt   ec         C   s4   d } x' |  D] } | d  k	 r | | 7} q q W| S(   Ni    (   t   None(   t   seqt   totalR   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt   sum   s
    t   Sheetc           B   s   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   c         C   sO   i  |  _  t j   |  _ |  j j d  } |  j | _ |  j | _  t | _ d  S(   Nt   __main__(   t   cellst   rexect   RExect
   add_modulet	   cellvaluet   cellt   multicellvalueR   (   t   selft   m(    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt   __init__"   s    	c         C   s9   |  j  | |  } t | d  r1 | j |  j  S| Sd  S(   Nt   recalc(   t   getcellt   hasattrR   R   (   R   R   t   yR   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR   *   s    c         C   s   | | k r | | } } n  | | k r8 | | } } n  g  } xR t  | | d  D]= } x4 t  | | d  D] } | j |  j | |   ql WqR W| S(   Ni   (   t   ranget   appendR   (   R   t   x1t   y1t   x2t   y2R   R    R   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR   1   s    !c         C   s   |  j  j | | f  S(   N(   R   t   get(   R   R   R    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR   <   s    c         C   s   | |  j  | | f <d  S(   N(   R   (   R   R   R    R   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt   setcell?   s    c         C   s,   y |  j  | | f =Wn t k
 r' n Xd  S(   N(   R   t   KeyError(   R   R   R    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt	   clearcellD   s    c         C   s1   x* |  j  | | | |  D] } |  j | =q Wd  S(   N(   t   selectcellsR   (   R   R#   R$   R%   R&   t   xy(    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt
   clearcellsJ   s    c         C   s   |  j  d | t j |  d  S(   Ni    (   R-   t   syst   maxint(   R   R$   R&   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt	   clearrowsN   s    c         C   s   |  j  | d | t j  d  S(   Ni    (   R-   R.   R/   (   R   R#   R%   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt   clearcolumnsQ   s    c         C   s   | | k r | | } } n  | | k r8 | | } } n  g  |  j  D]P \ } } | | k oe | k n rB | | k o | k n rB | | f ^ qB S(   N(   R   (   R   R#   R$   R%   R&   R   R    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR+   T   s    c         C   s#  | d k r | d k r d  S| | k r8 | | } } n  | | k rT | | } } n  i  } x |  j  D] \ } }	 |  j  | |	 f }
 t |
 d  r |
 j | | | | | |  }
 n  | | k o | k n r| |	 k o | k n r| | 7} |	 | 7}	 n  |
 | | |	 f <qd W| |  _  d  S(   Ni    t   renumber(   R   R   R2   (   R   R#   R$   R%   R&   t   dxt   dyt   newR   R    R   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt	   movecells\   s     !8
c         C   s&   |  j  d | t j t j d |  d  S(   Ni    (   R6   R.   R/   (   R   R    R   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt
   insertrowso   s    c         C   s^   | | k r | | } } n  |  j  | |  |  j d | d t j t j d | | d  d  S(   Ni    i   (   R0   R6   R.   R/   (   R   R$   R&   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt
   deleterowss   s    c         C   s&   |  j  | d t j t j | d  d  S(   Ni    (   R6   R.   R/   (   R   R   R   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt   insertcolumnsy   s    c         C   s^   | | k r | | } } n  |  j  | |  |  j | d d t j t j | | d d  d  S(   Ni   i    (   R-   R6   R.   R/   (   R   R#   R%   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt   deletecolumns}   s    c         C   sL   d } } x5 |  j  D]* \ } } t | |  } t | |  } q W| | f S(   Ni    (   R   t   max(   R   t   maxxt   maxyR   R    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt   getsize   s
    
c         C   s:   x3 |  j  j   D]" } t | d  r | j   q q Wd  S(   Nt   reset(   R   t
   itervaluesR   R?   (   R   R   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR?      s    c         C   sJ   |  j    x9 |  j j   D]( } t | d  r | j |  j  q q Wd  S(   NR   (   R?   R   R@   R   R   R   (   R   R   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR      s    
c         C   s  |  j    \ } } | d | d } } d g | } i  } xZ t d |  D]I } t |  t f | | d f <\ } }	 t | | t |   | | <qJ WxZ t d |  D]I }
 t |
  t f | d |
 f <\ } }	 t | d t |   | d <q Wx |  j j   D] \ \ } }
 } | d k s|
 d k r4qn  t	 | d  rV| j
 |  j  n  t	 | d  rz| j   \ } }	 n* t |  } t | t  rt }	 n t }	 | |	 f | | |
 f <t | | t |   | | <qWd } x9 t |  D]+ } | r| d 7} n  | d | | 7} qWx t |  D] }
 d } xo t |  D]a } | j | |
 f  pgd t f \ } }	 t |	 | | |  } | r| d 7} n  | | 7} qCW| GH|
 d k r*| GHq*q*Wd  S(	   Ni   i    R   t   formatt    t   +t   -t   |(   R>   R!   t   colnum2nameR   R;   t   lent   strR   t	   iteritemsR   R   R   RA   t
   isinstanceR   R'   t   align2action(   R   R<   R=   t   widtht   heightt   colwidtht   fullR   t   textt	   alignmentR    R   t   sept   line(    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt   display   sP    &!&!"	!'c         C   s   d g } xn |  j  j   D]] \ \ } } } t | d  rI | j   } n d t j |  } | j d | | | f  q W| j d  d j |  S(   Ns   <spreadsheet>t   xmls   <value>%s</value>s%   <cell row="%s" col="%s">
  %s
</cell>s   </spreadsheet>s   
(   R   RI   R   RU   t   cgit   escapeR"   t   join(   R   t   outR   R    R   t   cellxml(    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRU      s    	"	c         C   s\   |  j    } t | d  } | j |  | rN | j d  rN | j d  n  | j   d  S(   NR   s   
(   RU   t   opent   writet   endswitht   close(   R   t   filenameRP   t   f(    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt   save   s    c         C   s0   t  | d  } t |   j |  | j   d  S(   Nt   r(   R[   t   SheetParsert	   parsefileR^   (   R   R_   R`   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt   load   s    (   t   __name__t
   __module__R   R   R   R   R(   R*   R-   R0   R1   R+   R6   R7   R8   R9   R:   R>   R?   R   RT   RU   Ra   Re   (    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR       s,   																			2		Rc   c           B   s   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z e Z	 d   Z
 d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z RS(   c         C   s   | |  _  d  S(   N(   t   sheet(   R   Rh   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR      s    c         C   sA   t  j   } |  j | _ |  j | _ |  j | _ | j |  d  S(   N(	   R    t   ParserCreatet   startelementt   StartElementHandlert
   endelementt   EndElementHandlert   datat   CharacterDataHandlert	   ParseFile(   R   R`   t   parser(    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRd      s
    c         C   sc   t  |  d | d   } | rV x* | j   D] \ } } t |  | | <q) W| |  n  g  |  _ d  S(   Nt   start_(   t   getattrR   RI   RH   t   texts(   R   t   tagt   attrst   methodt   keyt   value(    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRj      s    c         C   s    t  |  } |  j j |  d  S(   N(   RH   Rt   R"   (   R   RP   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRn      s    c         C   s9   t  |  d | d   } | r5 | d j |  j   n  d  S(   Nt   end_RB   (   Rs   R   RX   Rt   (   R   Ru   Rw   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRl      s    c         C   s4   t  | j d   |  _ t  | j d   |  _ d  S(   Nt   rowt   col(   t   intR'   R    R   (   R   Rv   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt
   start_cell   s    c         C   s1   | j  d  |  _ t j  | j  d   |  _ d  S(   NRA   t   align(   R'   t   fmtt	   xml2alignRQ   (   R   Rv   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt   start_value  s    c         C   s*   y t  |  |  _ Wn d  |  _ n Xd  S(   N(   R}   Ry   R   (   R   RP   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt   end_int  s    c         C   s*   y t  |  |  _ Wn d  |  _ n Xd  S(   N(   t   longRy   R   (   R   RP   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt   end_long  s    c         C   s*   y t  |  |  _ Wn d  |  _ n Xd  S(   N(   t   floatRy   R   (   R   RP   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt
   end_double  s    c         C   s*   y t  |  |  _ Wn d  |  _ n Xd  S(   N(   t   complexRy   R   (   R   RP   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt   end_complex  s    c         C   s$   y | |  _  Wn d  |  _  n Xd  S(   N(   Ry   R   (   R   RP   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt
   end_string  s    c         C   s   t  |  j t  r! |  j |  _ ni t  |  j t  r` t |  j |  j pH d |  j pT t  |  _ n* t	 |  j |  j pu d |  j p t
  |  _ d  S(   Ns   %s(   RJ   Ry   t   BaseCellR   RH   t
   StringCellR   RQ   R   t   NumericCellR   (   R   RP   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt	   end_value%  s    		c         C   s+   t  | |  j p d |  j p t  |  _ d  S(   Ns   %s(   t   FormulaCellR   RQ   R   R   (   R   RP   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt   end_formula1  s    c         C   s#   |  j  j |  j |  j |  j  d  S(   N(   Rh   R(   R   R    R   (   R   RP   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt   end_cell6  s    (   Rf   Rg   R   Rd   Rj   Rn   Rl   R~   R   t   start_formulaR   R   R   R   R   R   R   R   (    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRc      s    														R   c           B   s   e  Z d  Z RS(   N(   Rf   Rg   R   R   (    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR   9  s   	R   c           B   sV   e  Z d  e d  Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   s   %sc         C   s   | |  _  | |  _ | |  _ d  S(   N(   Ry   R   RQ   (   R   Ry   R   RQ   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR   G  s    		c         C   s   |  j  S(   N(   Ry   (   R   R   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR   N  s    c         C   s:   y |  j  |  j } Wn t |  j  } n X| |  j f S(   N(   R   Ry   RH   RQ   (   R   RP   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRA   Q  s
    c         C   s=   t  |  d t |  j  j  } d t |  j |  j |   f S(   Nt   _xml_s(   <value align="%s" format="%s">%s</value>(   Rs   t   typeRy   Rf   t	   align2xmlRQ   R   (   R   Rw   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRU   X  s
    
c         C   s8   d |  j  k o d k  n r* d |  j  S|  j   Sd  S(   Ni   i   s   <int>%s</int>I       i   I       (   Ry   t	   _xml_long(   R   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt   _xml_int_  s    c         C   s   d |  j  S(   Ns   <long>%s</long>(   Ry   (   R   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR   e  s    c         C   s   d t  |  j  S(   Ns   <double>%s</double>(   t   reprRy   (   R   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt
   _xml_floath  s    c         C   s   d t  |  j  S(   Ns   <complex>%s</double>(   R   Ry   (   R   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt   _xml_complexk  s    (   Rf   Rg   R   R   R   RA   RU   R   R   R   R   (    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR   E  s   						R   c           B   s2   e  Z d  e d  Z d   Z d   Z d   Z RS(   s   %sc         C   s   | |  _  | |  _ | |  _ d  S(   N(   RP   R   RQ   (   R   RP   R   RQ   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR   p  s    		c         C   s   |  j  S(   N(   RP   (   R   R   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR   w  s    c         C   s   |  j  |  j f S(   N(   RP   RQ   (   R   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRA   z  s    c         C   s-   d } | t  |  j |  j t j |  j  f S(   Ns9   <value align="%s" format="%s"><string>%s</string></value>(   R   RQ   R   RV   RW   RP   (   R   t   s(    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRU   }  s
    
(   Rf   Rg   R   R   R   RA   RU   (    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR   n  s   		R   c           B   sD   e  Z d  e d  Z d   Z d   Z d   Z d   Z d   Z RS(   s   %sc         C   s;   | |  _  t |  j   |  _ | |  _ | |  _ |  j   d  S(   N(   t   formulat	   translatet
   translatedR   RQ   R?   (   R   R   R   RQ   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR     s
    			c         C   s   d  |  _ d  S(   N(   R   Ry   (   R   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR?     s    c         C   s   |  j  d  k r y4 | j d d t |  j   | j d  |  _  Wq t j   d } t | d  rw | j	 |  _  q t
 |  |  _  q Xn  |  j  S(   Ns    from __future__ import division
s   __value__ = eval(%s)t	   __value__i    Rf   (   Ry   R   t   r_execR   R   t   r_evalR.   t   exc_infoR   Rf   RH   (   R   R   t   exc(    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR     s    	c         C   s:   y |  j  |  j } Wn t |  j  } n X| |  j f S(   N(   R   Ry   RH   RQ   (   R   RP   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRA     s
    c         C   s   d t  |  j |  j |  j f S(   Ns,   <formula align="%s" format="%s">%s</formula>(   R   RQ   R   R   (   R   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRU     s    
c         C   s   g  } x t  j d |  j  D] } t  j d |  }	 |	 d  k	 r |	 j   \ }
 } t |
  } t |  } | | k o | k n r | | k o | k n r t | | | |  } q n  | j	 |  q Wt
 d j |  |  j |  j  S(   Ns   (\w+)s   ^([A-Z]+)([1-9][0-9]*)$RB   (   t   ret   splitR   t   matchR   t   groupst   colname2numR}   t   cellnameR"   R   RX   R   RQ   (   R   R#   R$   R%   R&   R3   R4   RY   t   partR   t   sxt   syR   R    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR2     s    8(	   Rf   Rg   R   R   R?   R   RA   RU   R2   (    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR     s   				c   	      C   s   g  } x t  j d |   D] } t  j d |  } | d k rM | j |  q | j   \ } } } } t |  } | d k r d | | f } n" t |  } d | | | | f } | j |  q Wd j |  S(   s   Translate a formula containing fancy cell names to valid Python code.

    Examples:
        B4 -> cell(2, 4)
        B4:Z100 -> cells(2, 4, 26, 100)
    s   (\w+(?::\w+)?)s2   ^([A-Z]+)([1-9][0-9]*)(?::([A-Z]+)([1-9][0-9]*))?$s   cell(%s, %s)s   cells(%s, %s, %s, %s)RB   N(   R   R   R   R   R"   R   R   RX   (	   R   RY   R   R   R#   R$   R%   R&   R   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR     s    c         C   s   t  |   t |  S(   sE   Translate a cell coordinate to a fancy cell name (e.g. (1, 1)->'A1').(   RF   RH   (   R   R    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR     s    c         C   sI   |  j    }  d } x0 |  D]( } | d t |  t d  d } q W| S(   sC   Translate a column name to number (e.g. 'A'->1, 'Z'->26, 'AA'->27).i    i   t   Ai   (   t   uppert   ord(   R   R   t   c(    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR     s
    &c         C   sJ   d } x= |  rE t  |  d d  \ }  } t | t d   | } q	 W| S(   s6   Translate a column number to name (e.g. 1->'A', etc.).RB   i   i   R   (   t   divmodt   chrR   (   R   R   R   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRF     s
    	t   SheetGUIc           B   s   e  Z d  Z d d d d  Z d   Z d   Z d   Z d   Z d	   Z d
   Z	 d   Z
 d   Z d   Z d   Z d   Z e Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   s7  Beginnings of a GUI for a spreadsheet.

    TO DO:
    - clear multiple cells
    - Insert, clear, remove rows or columns
    - Show new contents while typing
    - Scroll bars
    - Grow grid when window is grown
    - Proper menus
    - Undo, redo
    - Cut, copy and paste
    - Formatting and alignment
    s
   sheet1.xmli
   i   c         C   s*  | |  _  t   |  _ t j j |  r: |  j j |  n  |  j j   \ } } t | |  } t | |  } t	 j	   |  _
 |  j
 j d |  j   t	 j |  j
 d d d d |  _ t	 j |  j
  |  _ t	 j |  j
 d d d	 |  j |  _ t	 j |  j
  |  _ |  j j d
 d d d d d  |  j j d
 d  |  j j d
 d  |  j j d
 d d d d d  |  j j d |  j  |  j j d |  j  |  j j d |  j  |  j j d |  j  |  j j d |  j  |  j j d |  j  |  j | |  d |  _ d |  _  |  j! d d  |  j"   d S(   sl   Constructor.

        Load the sheet from the filename argument.
        Set up the Tk widget tree.
        s   Spreadsheet: %sRP   t   A1t   fontt	   helveticai   t   boldt   Savet   commandt   sidet   bottomt   expandi   t   fillt   bothR	   R
   R   s   <Return>s   <Shift-Return>s   <Tab>s   <Shift-Tab>s   <Delete>s   <Escape>N(   R   i   R   (#   R_   R   Rh   t   ost   patht   isfileRe   R>   R;   t   Tkt   roott   wm_titlet   Labelt   beacont   Entryt   entryt   ButtonRa   t
   savebuttont   Framet   cellgridt   packt   bindt   return_eventt   shift_return_eventt	   tab_eventt   shift_tab_eventt   delete_eventt   escape_eventt   makegridR   t	   currentxyt   cornerxyt
   setcurrentt   sync(   R   R_   t   rowst   columnsR<   R=   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR     s<    			c         C   sr   |  j  |  j k r> |  j  d  k	 r> |  j j |  j |  j    n |  j j |  j   |  j   |  j j d d  d S(   Ni    t   endt   break(	   R   R   R   Rh   R-   R*   R   R   t   delete(   R   t   event(    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR   '  s    !
c         C   s#   |  j  \ } } |  j | |  d  S(   N(   R   t
   load_entry(   R   R   R   R    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR   0  s    c         C   s   |  j  j | |  } | d  k r* d } n1 t | t  rI d | j } n | j   \ } } |  j j d d  |  j j	 d |  |  j j
 d d  d  S(   NRB   t   =i    R   (   Rh   R   R   RJ   R   R   RA   R   R   t   insertt   selection_range(   R   R   R    R   RP   RQ   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR   4  s    	c      
   C   s  | |  _  | |  _ i  |  _ t j |  j d d } | j d d d d d d  | j d |  j  x t	 d	 | d	  D] } |  j j
 | d
 d t j |  j d t |  d d } | j d | d d d d  | |  j | d f <| | _ d | _ | j d |  j  | j d |  j  | j d |  j  | j d |  j  qv Wx t	 d	 | d	  D] } t j |  j d t |  d d } | j d d d | d d  | |  j d | f <d | _ | | _ | j d |  j  | j d |  j  | j d |  j  | j d |  j  q[Wx t	 d	 | d	  D] } x t	 d	 | d	  D] } t j |  j d d d d d d } | j d | d | d d  | |  j | | f <| | _ | | _ | j d |  j  | j d |  j  | j d |  j  | j d |  j  qDWq*Wd S(   s   Helper to create the grid of GUI cells.

        The edge (x==0 or y==0) is filled with labels; the rest is real cells.
        t   relieft   raisedt   columni    R{   t   stickyt   NSWEs   <ButtonPress-1>i   t   minsizei@   RP   t   WEs   <B1-Motion>s   <ButtonRelease-1>s   <Shift-Button-1>t   sunkent   bgt   whitet   fgt   blackN(   R   R   t	   gridcellsR   R   R   t   grid_configureR   t	   selectallR!   t   grid_columnconfigureRF   t   _SheetGUI__xt   _SheetGUI__yt   selectcolumnt   extendcolumnRH   t	   selectrowt	   extendrowt   presst   motiont   release(   R   R   R   R   R   R    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR   @  sN    			$		$				c         C   s*   |  j  d d  |  j t j t j  d  S(   Ni   (   R   t	   setcornerR.   R/   (   R   R   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR   r  s    c         C   s<   |  j  |  \ } } |  j | d  |  j | t j  d  S(   Ni   (   t   whichxyR   R   R.   R/   (   R   R   R   R    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR   v  s    c         C   sR   |  j  |  \ } } | d k rN |  j |  j d d  |  j | t j  n  d  S(   Ni    i   (   R   R   R   R   R.   R/   (   R   R   R   R    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR   {  s    c         C   s<   |  j  |  \ } } |  j d |  |  j t j |  d  S(   Ni   (   R   R   R   R.   R/   (   R   R   R   R    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR     s    c         C   sR   |  j  |  \ } } | d k rN |  j d |  j d  |  j t j |  n  d  S(   Ni    i   (   R   R   R   R   R.   R/   (   R   R   R   R    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR     s    c         C   sD   |  j  |  \ } } | d k r@ | d k r@ |  j | |  n  d  S(   Ni    (   R   R   (   R   R   R   R    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR     s    c         C   sD   |  j  |  \ } } | d k r@ | d k r@ |  j | |  n  d  S(   Ni    (   R   R   (   R   R   R   R    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR     s    c         C   sh   |  j  j | j | j  } | d  k	 rd t | t j  rd y | j | j	 f SWqd t
 k
 r` qd Xn  d S(   Ni    (   i    i    (   R   t   winfo_containingt   x_roott   y_rootR   RJ   R   R   R   R   t   AttributeError(   R   R   R   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR     s    c         C   s   |  j  j |  j  d  S(   N(   Rh   Ra   R_   (   R   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyRa     s    c         C   s   |  j  d k	 r |  j   n  |  j   t | |  |  j d <|  j | |  |  j j   | | f |  _  d |  _	 |  j
 j |  j   } | d k	 r d | d <n  d S(   s   Make (x, y) the current cell.RP   t   yellowR   N(   R   R   t   change_cellt
   clearfocusR   R   R   R   t	   focus_setR   R   R'   (   R   R   R    t   gridcell(    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR     s    
	c   	      C   sc  |  j  d  k s$ |  j  | | f k r8 |  j | |  d  S|  j   | | f |  _ |  j  \ } } |  j po |  j  \ } } | | k r | | } } n  | | k r | | } } n  xh |  j j   D]W \ \ } } } | | k o | k n r | | k o| k n r d | d <q q W|  j j |  j   } | d  k	 rId | d <n  |  j | | | |  d  S(   Nt	   lightBlueR   R  (	   R   R   R   R  R   R   RI   R'   t	   setbeacon(	   R   R   R    R#   R$   R%   R&   R   R  (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR     s$    $
"8c         C   s#  | | k o d k n rD | | k o6 t  j k n rD d } n | | f d t  j f k r | | k rx d | } qd | | f } n | | f d t  j f k r | | k r d t |  } qd t |  t |  f } n. t |  j   } t |  j   } d | | f } | |  j d <d  S(   Ni   t   :s   %ds   %d:%ds   %ss   %s:%sRP   (   R.   R/   RF   R   R   R   R   (   R   R#   R$   R%   R&   t   namet   name1t   name2(    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR	    s    ;	c         C   s   |  j  d  k	 r |  j  \ } } |  j p- |  j  \ } } | | k rR | | } } n  | | k rn | | } } n  xk |  j j   D]W \ \ } } } | | k o | k n r~ | | k o | k n r~ d | d <q~ q~ Wn  d  S(   NR   R   (   R   R   R   R   RI   (   R   R#   R$   R%   R&   R   R    R   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR    s    "8c         C   s1   |  j    |  j \ } } |  j | | d  d S(   s   Callback for the Return key.i   R   (   R  R   R   (   R   R   R   R    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR     s    
c         C   s:   |  j    |  j \ } } |  j | t d | d   d S(   s0   Callback for the Return key with Shift modifier.i   R   (   R  R   R   R;   (   R   R   R   R    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR     s    
c         C   s1   |  j    |  j \ } } |  j | d |  d S(   s   Callback for the Tab key.i   R   (   R  R   R   (   R   R   R   R    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR     s    
c         C   s:   |  j    |  j \ } } |  j t d | d  |  d S(   s-   Callback for the Tab key with Shift modifier.i   R   (   R  R   R   R;   (   R   R   R   R    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR     s    
c         C   s   |  j  \ } } |  j j   } d } | j d  rF t | d  } nG xD t t t t	 f D]0 } y | |  } Wn
 qY qY Xt
 |  } PqY W| d k r | r t |  } n  | d k r |  j j | |  n |  j j | | |  |  j   d S(   s+   Set the current cell from the entry widget.R   i   N(   R   R   R'   R   t
   startswithR   R}   R   R   R   R   R   Rh   R*   R(   R   (   R   R   R    RP   R   t   clsRy   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR    s$    c         C   s   |  j  j   x |  j j   D] \ \ } } } | d k s | d k rM q n  |  j  j | |  } | d k r{ d | d <q t | d  r | j   \ } } n t |  t	 } } | | d <t
 | | d <q Wd S(   s(   Fill the GUI cells from the sheet cells.i    RB   RP   RA   t   anchorN(   Rh   R   R   RI   R   R   R   RA   RH   R   t   align2anchor(   R   R   R    R  R   RP   RQ   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR     s    "
(   Rf   Rg   t   __doc__R   R   R   R   R   R   R   R   R   R   R   R   R   R   Ra   R   R   R	  R  R   R   R   R   R  R   (    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyR     s4   -					2																			c          C   s   d d l  }  t   } x t d d  D] } x t d d  D] } | d k r\ t |  } nU | d k rw t |  } n: t | d  } t d |  } d | | f } t |  } | j | | |  q; Wq% W| j   | j d  d S(   s   Basic non-gui self-test.iNi   i   s   %s*%ss
   sheet1.xml(	   R   R   R!   R   R   R   R(   RT   Ra   (   R   t   aR   R    R   t   c1t   c2R   (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt
   test_basic,  s    	
c          C   s@   t  j d r t  j d }  n d }  t |   } | j j   d S(   s	   GUI test.i   s
   sheet1.xmlN(   R.   t   argvR   R   t   mainloop(   R_   t   g(    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt   test_guiB  s
    R   (#   R  R   R   R.   RV   R   t   xml.parsersR    R   R   R   R   R   R   RK   R   R   R  R   R   Rc   R   R   R   R   R   R   R   RF   t   TkinterR   R   R  R  Rf   (    (    (    s.   /usr/lib64/python2.7/Demo/tkinter/guido/ss1.pyt   <module>   s@   				Y)6						 C			