m
fIc           @   sL  d  k  Z  d  k Z d k Td  k Z d  k Z d k l Z d Z y% e  i i	 e  i i
 e  e  Z Wn e j
 o e Z n Xe  i i e  o
 e Z n( e  i i e  p e d e f  n e d  Z d f  d     YZ d f  d	     YZ d
 e f d     YZ d f  d     YZ d   Z d   Z e d j o e   n d  S(   N(   t   *(   s   idleConft   Iconss   can't find icon directory (%r)c      	   C   s7  t    } d k } | i t i i |  d   } | i   g  } d }
 } x | D] } t i i t i i |   d } t d | d |  }	 | i |	  t | d |	 d d d	 d
 } | i d |
 d |  t | d | } | i d |
 d d |  | d } | d j o |
 d }
 d } qQ qQ W| | _	 d S(   s'   Utility to display the available icons.Ns   *.gifi    t   filet   mastert   imaget   bdi   t   relieft   raisedt   rowt   columnt   texti
   i   (   t   Tkt   roott   globt   ost   patht   joint   icondirt   listt   sortt   imagesR   R	   R   t   splitextt   basenamet   namet
   PhotoImageR   t   appendt   Labelt   labelt   grid(   R   R   R	   R   R   R   R   R   R   R   R   (    (    t/   /mit/python/lib/python2.4/idlelib/TreeWidget.pyt	   listicons%   s*     		

 "

t   TreeNodec           B   s   t  Z d   Z d   Z d   Z d  d  Z d  d  Z d   Z d   Z	 d  d  Z
 d  d	  Z d  d
  Z d   Z d   Z d   Z d   Z d   Z d   Z d  d  Z d  d  Z d  d  Z d  d  Z RS(   Nc         C   sS   | |  _  | |  _ | |  _ d |  _ t |  _ g  |  _ d  |  _	 |  _
 h  |  _ d  S(   Nt	   collapsed(   t   canvast   selft   parentt   itemt   statet   Falset   selectedt   childrent   Nonet   xt   yt
   iconimages(   R"   R!   R#   R$   (    (    R   t   __init__>   s    						c         C   s<   x, |  i D]  } |  i i |  | i   q Wd  |  _ d  S(   N(   R"   R(   t   ct   removet   destroyR)   R#   (   R"   R.   (    (    R   R0   H   s
     c         C   s   y |  i | SWn t j
 o n Xt i i |  \ } } | p d } t i i	 t
 | |  } t d |  i d |  } | |  i | <| S(   Ns   .gifR   R   (   R"   R,   R   t   KeyErrorR   R   R   R   t   extR   t   ICONDIRt   fullnameR   R!   R   (   R"   R   R2   R   R4   R   (    (    R   t   geticonimageN   s    c         C   sP   |  i o d  Sn |  i   t |  _ |  i i |  i  |  i   |  i   d  S(   N(	   R"   R'   t   deselectallt   TrueR!   t   deletet   image_idt   drawicont   drawtext(   R"   t   event(    (    R   t   selectZ   s    

	
c         C   sF   |  i p d  Sn t |  _ |  i i |  i  |  i   |  i   d  S(   N(   R"   R'   R&   R!   R8   R9   R:   R;   (   R"   R<   (    (    R   t   deselectc   s    
	
c         C   s)   |  i o |  i i   n |  i   d  S(   N(   R"   R#   R6   t   deselecttree(   R"   (    (    R   R6   k   s    
c         C   s:   |  i o |  i   n x |  i D] } | i   q" Wd  S(   N(   R"   R'   R>   R(   t   childR?   (   R"   R@   (    (    R   R?   q   s
    

 c         C   s9   |  i d j o |  i   n |  i   |  i i   d S(   Nt   expandedt   break(   R"   R%   t   collapset   expandR$   t   OnDoubleClick(   R"   R<   (    (    R   t   flipw   s
    
c         C   sM   |  i i   p d  Sn |  i d j o! d |  _ |  i   |  i   n d  S(   NRA   (   R"   R$   t   _IsExpandableR%   t   updatet   view(   R"   R<   (    (    R   RD      s    	
c         C   s+   |  i d j o d |  _ |  i   n d  S(   NR    (   R"   R%   RH   (   R"   R<   (    (    R   RC      s    	c         C   s   |  i d } |  i   i d } | | } |  i i d  } |  i i	   } |  i i |  } | | j o | | j o d  Sn |  i i |  i d  \ }	 } }
 } | | j o | | j o | | | } n | } t |  | } |  i i |  d  S(   Ni   i   i    t   scrollregion(   R"   R+   t   topt   lastvisiblechildt   bottomt   heightR!   t   canvasyt   visible_topt   winfo_heightt   visible_heightt   visible_bottomt   _getintst   x0t   y0t   x1t   y1t   fractiont   floatt   yview_moveto(   R"   RS   RM   RP   RN   RY   RR   RX   RV   RU   RW   RK   (    (    R   RI      s    
%c         C   s7   |  i o% |  i d j o |  i d i   Sn |  Sd  S(   NRA   i(   R"   R(   R%   RL   (   R"   (    (    R   RL      s    c         C   s   |  i o |  i i   n |  i d } d |  i d <|  i i   |  i i t  |  i d d  |  i i t  \ } } } } |  i i d d d | | f  | |  i d <d  S(   Nt   cursort   watchi   i   RJ   i    (   R"   R#   RH   R!   t	   oldcursorR8   t   ALLt   drawt   bboxRU   RV   RW   RX   t	   configure(   R"   RX   RV   RU   RW   R^   (    (    R   RH      s    
c         C   s	  | | |  _  |  _ |  i   |  i   |  i d j o | d Sn |  i p_ |  i i   } | p | d Sn x: | D]. } |  i
 |  i |  |  } |  i i |  qv Wn | d }	 | d } d }
 x |  i D] } | }
 |  i i | d | d |	 | d d d | i |	 |  } | i i   o | i d j o d	 } | i } n d
 } | i } |  i |  } |  i i | d |
 d d | } |  i i | d |  |  i i | d d    q q W|  i i | d | d | d |
 d d d } |  i i |  | S(   NRA   i   i   i    i	   i   t   fillt   gray50t	   minusnodet   plusnodeR   s   <1>s
   <Double-1>c         C   s   d  S(   N(   R)   (   R*   (    (    R   t   <lambda>   s    i
   (   R*   R+   R"   R:   R;   R%   R(   R$   t   _GetSubListt   sublistt	   __class__R!   R@   R   t   cxt   cyt   cylastt   create_lineR`   RG   t   iconnameRC   t   callbackRD   R5   R   t   create_imaget   idt   tag_bindt	   tag_lower(   R"   R*   R+   Ro   Rp   Ri   Rr   R$   Rl   Rk   Rm   R@   R   (    (    R   R`      sF    


 


 +	#!%c         C   s   |  i o* |  i i   p |  i i   p d } n |  i i   p d } |  i |  } |  i i	 |  i
 |  i d d d | } | |  _ |  i i | d |  i  |  i i | d |  i  d  S(   Nt
   openfoldert   foldert   anchort   nwR   s   <1>s
   <Double-1>(   R"   R'   R$   t   GetSelectedIconNamet   GetIconNamet	   imagenameR5   R   R!   Rq   R*   R+   Rr   R9   Rs   R=   RF   (   R"   R{   R   Rr   (    (    R   R:      s    
*'	c      
   C   s  |  i d d } |  i d }
 |  i i   } | o |  i i	 | |
 d d d | } |  i i | d |  i  |  i i | d |  i  |  i i |  \ }	 } } } t | d  d	 } n |  i i   p d
 } y |  i Wn t j
 o n X|  i   y |  i } Wn= t j
 o1 t |  i d | d d d d d d |  _ n Xt i d d d  } |  i o  |  i i t i  | d   n |  i i t i  | d   |  i i! | |
 d d d |  i } |  i i" d |  i#  |  i i" d |  i  | |  _$ d  S(   Ni   i   Rw   Rx   R
   s   <1>s
   <Double-1>i   i
   s	   <no text>R   i    t   padxi   t   padyt   maint   ThemeR   t   hilitet   normalt   window(%   R"   R*   t   textxR+   t   textyR$   t   GetLabelTextt	   labeltextR!   t   create_textRr   Rs   R=   RF   Ra   RU   RV   RW   RX   t   maxt   GetTextR
   t   entryt   AttributeErrort   edit_finishR   R   t   idleConft	   GetOptiont   themeR'   Rb   t   GetHighlightt   create_windowt   bindt   select_or_editt   text_id(   R"   RW   R   R   Rr   R   R
   RX   RV   RU   R   R   (    (    R   R;      s:    
/
 c         C   s<   |  i o! |  i i   o |  i |  n |  i |  d  S(   N(   R"   R'   R$   t
   IsEditablet   editR<   R=   (   R"   R<   (    (    R   R     s    c         C   s   t  |  i d d d d d d |  _ |  i i d |  i d  |  i i d t  |  i i d d  |  i i   |  i i	 d	 |  i
  |  i i	 d
 |  i  d  S(   NR   i    t   highlightthicknessi   t   widthR
   t   ipadxi   s   <Return>s   <Escape>(   t   EntryR"   R   R   t   insertt   selection_ranget   ENDt   packt	   focus_setR   R   t   edit_cancel(   R"   R<   (    (    R   R     s    $c         C   s   y |  i } |  ` Wn t j
 o d  Sn X| i   } | i   | o* | |  i i   j o |  i i |  n |  i i   } | |  i	 d <|  i
   |  i i   d  S(   NR
   (   R"   R   R   t   getR
   R0   R$   R   t   SetTextR   R;   R!   R   (   R"   R<   R   R
   (    (    R   R     s    	
	

c         C   sR   y |  i } |  ` Wn t j
 o d  Sn X| i   |  i   |  i i   d  S(   N(   R"   R   R   R0   R;   R!   R   (   R"   R<   R   (    (    R   R   &  s    	
	

(   t   __name__t
   __module__R-   R0   R5   R)   R=   R>   R6   R?   RF   RD   RC   RI   RL   RH   R`   R:   R;   R   R   R   R   (    (    (    R   R   <   s(   	
									)		"	t   TreeItemc           B   s   t  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 RS(   s   Abstract class representing tree items.

    Methods should typically be overridden, otherwise a default action
    is used.

    c         C   s   d S(   s)   Constructor.  Do whatever you need to do.N(    (   R"   (    (    R   R-   :  s    c         C   s   d S(   s   Return text string to display.N(    (   R"   (    (    R   R   =  s    c         C   s   d S(   s>   Return label text string to display in front of text (if any).N(    (   R"   (    (    R   R   @  s    c         C   s*   |  i d j o |  i   |  _ n |  i S(   s%   Do not override!  Called by TreeNode.N(   R"   t
   expandableR)   t   IsExpandable(   R"   (    (    R   RG   E  s     c         C   s   d S(   s"   Return whether there are subitems.i   N(    (   R"   (    (    R   R   K  s     c         C   s9   |  i   p g  Sn |  i   } | p d |  _ n | S(   s%   Do not override!  Called by TreeNode.i    N(   R"   R   t
   GetSubListRi   R   (   R"   Ri   (    (    R   Rh   O  s     c         C   s   d S(   s-   Return whether the item's text may be edited.N(    (   R"   (    (    R   R   X  s    c         C   s   d S(   s+   Change the item's text (if it is editable).N(    (   R"   R
   (    (    R   R   [  s    c         C   s   d S(   s-   Return name of icon to be displayed normally.N(    (   R"   (    (    R   Rz   ^  s    c         C   s   d S(   s2   Return name of icon to be displayed when selected.N(    (   R"   (    (    R   Ry   a  s    c         C   s   d S(   s%   Return list of items forming sublist.N(    (   R"   (    (    R   R   d  s    c         C   s   d S(   s%   Called on a double-click on the item.N(    (   R"   (    (    R   RE   g  s    (   R   R   t   __doc__R-   R   R   R)   R   RG   R   Rh   R   R   Rz   Ry   R   RE   (    (    (    R   R   1  s    												t   FileTreeItemc           B   sM   t  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 RS(   s4   Example TreeItem subclass -- browse the file system.c         C   s   | |  _  d  S(   N(   R   R"   (   R"   R   (    (    R   R-   q  s    c         C   s   t  i i |  i  p |  i S(   N(   R   R   R   R"   (   R"   (    (    R   R   t  s    c         C   s   t  i i |  i  d j S(   Nt    (   R   R   R   R"   (   R"   (    (    R   R   w  s    c         C   s   t  i i |  i  } t  i i | |  } t  i i |  t  i i |  i  j o d  Sn y  t  i |  i |  | |  _ Wn t  i j
 o n Xd  S(   N(	   R   R   t   dirnameR"   t   newpathR   R
   t   renamet   error(   R"   R
   R   (    (    R   R   z  s    (c         C   s   |  i   p d Sn d  S(   Nt   python(   R"   R   (   R"   (    (    R   Rz     s    c         C   s   t  i i |  i  S(   N(   R   R   t   isdirR"   (   R"   (    (    R   R     s    c         C   s   y t  i |  i  } Wn t  i j
 o g  Sn X| i d    g  } x9 | D]1 } t	 t  i i
 |  i |   } | i |  qP W| S(   Nc         C   s%   t  t i i |   t i i |   S(   N(   t   cmpR   R   t   normcaset   at   b(   R   R   (    (    R   Rg     s    (   R   t   listdirR"   R   t   namesR   R   Ri   R   R   R   R$   R   (   R"   R   Ri   R$   R   (    (    R   R     s    	 (
   R   R   R   R-   R   R   R   Rz   R   R   (    (    (    R   R   m  s    						t   ScrolledCanvasc           B   s>   t  Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   Nc         K   s  | i d  p d | d <n | |  _ t |  |  _ |  i i d d d |  i i d d d t |  i |  |  _	 |  i	 i
 d d d d d d	  t |  i d
 d |  _ |  i i
 d d d d d d  t |  i d
 d d d |  _ |  i i
 d d d d d d  |  i i |  i	 d <|  i	 i |  i d <|  i i |  i	 d <|  i	 i |  i d <|  i	 i d |  i  |  i	 i d |  i  |  i	 i d |  i  |  i	 i d |  i  |  i	 i d |  i  |  i	 i   d  S(   Nt   yscrollincrementi   i    t   weighti   R   R	   t   stickyt   nsewR   t   vbart   nset   hbart   orientt
   horizontalt   ewst   yscrollcommandt   commandt   xscrollcommands   <Key-Prior>s
   <Key-Next>s   <Key-Up>s
   <Key-Down>s   <Alt-Key-2>(   t   optst   has_keyR   R"   t   Framet   framet   rowconfiguret   columnconfiguret   CanvasR!   R   t	   ScrollbarR   R   t   sett   yviewt   xviewR   t   page_upt	   page_downt   unit_upt	   unit_downt   zoom_heightR   (   R"   R   R   (    (    R   R-     s,    	c         C   s   |  i i d d  d S(   Nit   pageRB   (   R"   R!   t   yview_scroll(   R"   R<   (    (    R   R     s    c         C   s   |  i i d d  d S(   Ni   R   RB   (   R"   R!   R   (   R"   R<   (    (    R   R     s    c         C   s   |  i i d d  d S(   Nit   unitRB   (   R"   R!   R   (   R"   R<   (    (    R   R     s    c         C   s   |  i i d d  d S(   Ni   R   RB   (   R"   R!   R   (   R"   R<   (    (    R   R     s    c         C   s   t  i |  i  d S(   NRB   (   t
   ZoomHeightR   R"   R   (   R"   R<   (    (    R   R     s    (   R   R   R-   R   R   R   R   R   (    (    (    R   R     s   					c          C   s   d  k  } t | i  } | i d d d d  | i   t | d d d d d d } | i i d	 d d
 d  t	 d  } t | i d  |  }  |  i   d  S(   NR   i    t   bgt   yellowt   whiteR   t	   takefocusi   RD   Rc   t   boths   C:/windows/desktop(   t   PyShellt   ToplevelR   Rb   R   R   t   scR   R   R   R$   R   R!   R)   t   nodeRD   (   R   R$   R   R   R   (    (    R   t   test  s    	
c          C   s   t    } | i d d  t | d d d d } | i d d d d	  t t i  } t
 | d  |  }  |  i   | i   d  S(
   NR   i    R   R   R   RD   i   Rc   R   (   R   R   Rb   R   R!   R   R   R   t   curdirR$   R   R)   R   RH   R   (   R   R!   R$   R   (    (    R   t   test2  s    	
t   __main__(   R   t   syst   Tkintert   impR   t   configHandlerR   R3   R   R   R   t   __file__t   _icondirt	   NameErrorR   t   RuntimeErrorR   R   R   R   R   R   R   R   (   R   R   R   R   R   R   R   R   R   R   R3   R   R   R   (    (    R   t   ?   s.   				%
<.,		