tQc@sNddlZddlTddlZddlmZddlmZdZy%ejj ejj e eZ Wne k reZ nXejje re Zn%ejjesedefnedZddd YZd dd YZd efd YZdddYZdZdZedkrJendS(iN(t*(t ZoomHeight(tidleConftIconsscan't find icon directory (%r)c Cs8t}ddl}|jtjj|d}|jg}d}}x|D]}tjjtjj|d}td|d|} |j | t |d| dd d d } | j d |d |t |d|} | j d |d d ||d }|dkrT|d}d}qTqTW||_ dS(s'Utility to display the available icons.iNs*.gifitfiletmastertimagetbditrelieftraisedtrowtcolumnttexti i( tTktglobtostpathtjointsorttsplitexttbasenamet PhotoImagetappendtLabeltgridtimages( ticondirtrootRtlistRR R RtnameRtlabel((s(/sys/lib/python2.7/idlelib/TreeWidget.pyt listicons$s&     "     tTreeNodecBseZdZdZdZddZddZdZdZ ddZ ddZ dd Z d Z d Zd Zd ZdZdZddZddZddZddZRS(cCsS||_||_||_d|_t|_g|_d|_|_ i|_ dS(Nt collapsed( tcanvastparenttitemtstatetFalsetselectedtchildrentNonetxtyt iconimages(tselfR"R#R$((s(/sys/lib/python2.7/idlelib/TreeWidget.pyt__init__=s      cCs<x,|jD] }|jj||jq Wd|_dS(N(R(tremovetdestroyR)R#(R-tc((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR0GscCsy|j|SWntk r"nXtjj|\}}|pDd}tjjt||}td|jd|}||j|<|S(Ns.gifRR( R,tKeyErrorRRRRtICONDIRRR"(R-RRtexttfullnameR((s(/sys/lib/python2.7/idlelib/TreeWidget.pyt geticonimageMs   cCsK|jr dS|jt|_|jj|j|j|jdS(N(R't deselectalltTrueR"tdeletetimage_idtdrawicontdrawtext(R-tevent((s(/sys/lib/python2.7/idlelib/TreeWidget.pytselectYs    cCsA|js dSt|_|jj|j|j|jdS(N(R'R&R"R9R:R;R<(R-R=((s(/sys/lib/python2.7/idlelib/TreeWidget.pytdeselectbs    cCs'|jr|jjn |jdS(N(R#R7t deselecttree(R-((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR7js cCs8|jr|jnx|jD]}|jq WdS(N(R'R?R(R@(R-tchild((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR@ps  cCs7|jdkr|jn |j|jjdS(Ntexpandedtbreak(R%tcollapsetexpandR$t OnDoubleClick(R-R=((s(/sys/lib/python2.7/idlelib/TreeWidget.pytflipvs    cCsF|jjsdS|jdkrBd|_|j|jndS(NRB(R$t _IsExpandableR%tupdatetview(R-R=((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRE~s   cCs)|jdkr%d|_|jndS(NR!(R%RI(R-R=((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRDs c Cs|jd}|jjd}||}|jjd}|jj}|jj|}||kry||krydS|jj|jd\}}} } ||kr||kr|||} n|} t| | } |jj| dS(Niiit scrollregion(R+tlastvisiblechildR"tcanvasyt winfo_heightt_getintstfloatt yview_moveto( R-ttoptbottomtheightt visible_toptvisible_heighttvisible_bottomtx0ty0tx1ty1tfraction((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRJs  %cCs1|jr)|jdkr)|jdjS|SdS(NRBi(R(R%RL(R-((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRLscCs|jr|jjn|jd}d|jd<|jj|jjt|jdd|jjt\}}}}|jjddd||f||jd|dS|js|jj}|sd|dSx9|D].}|j|j ||}|jj |qkWn|d}|d}d}x|jD]}|}|j j |d|d||ddd|j ||}|jj r|jdkr=d } |j} nd } |j} |j| } |j j|d|dd | } |j j| d | |j j| d dqqW|j j |d|d|d|ddd} |j j| |S(NRBiiii itfilltgray50t minusnodetplusnodeRs<1>s cSsdS(N(R)(R*((s(/sys/lib/python2.7/idlelib/TreeWidget.pytsi (R*R+R;R<R%R(R$t _GetSubListt __class__R"Rt create_lineR`RHRDRER6t create_imagettag_bindt tag_lower( R-R*R+tsublistR$RAtcxtcytcylastticonnametcallbackRtid((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR`sB      +  # ( c Cs|jr0|jjp*|jjp*d}n|jjpBd}|j|}|jj|j|jddd|}||_ |jj |d|j |jj |d|j dS(Nt openfoldertfoldertanchortnwRs<1>s ( R'R$tGetSelectedIconNamet GetIconNameR6R"RlR*R+R:RmR>RG(R-t imagenameRRu((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR;s  ' c Cs|jdd}|jd}|jj}|r|jj||ddd|}|jj|d|j|jj|d|j|jj |\}}}}t |dd }n|jj pd } y |j Wnt k rn X|jy |j} Wn;t k rBt|jd| d d d ddd|_nXtjddd} |jr|jjtj| dn|jjtj| d|jj||ddd|j}|jjd|j|jjd|j||_dS(NiiRxRyR s<1>s ii s RitpadxitpadytmaintThemeRthilitetnormaltwindow(R*R+R$t GetLabelTextR"t create_textRmR>RGRatmaxtGetTexttentrytAttributeErrort edit_finishRRRt GetOptionR'Rbt GetHighlightt create_windowtbindtselect_or_editttext_id( R-ttextxttextyt labeltextRuRXRYRZR[R Rttheme((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR<s:       . cCs9|jr(|jjr(|j|n |j|dS(N(R'R$t IsEditableteditR>(R-R=((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRscCst|jdddddd|_|jjd|jd|jjdt|jjdd|jj|jjd |j |jjd |j dS( NRithighlightthicknessitwidthR tipadxiss( tEntryRRtinserttselection_rangetENDtpackt focus_setRRt edit_cancel(R-R=((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR s$ cCsy|j}|`Wntk r'dSX|j}|j|rl||jjkrl|jj|n|jj}||jd<|j|j j dS(NR ( RRtgetR0R$RtSetTextRR<R"R(R-R=RR ((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRs       cCsMy|j}|`Wntk r'dSX|j|j|jjdS(N(RRR0R<R"R(R-R=R((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR%s     N(t__name__t __module__R.R0R6R)R>R?R7R@RGRERDRJRLRIR`R;R<RRRR(((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR ;s(          ) "  tTreeItemcBseZdZdZdZdZd ZdZdZ dZ dZ dZ d Z d Zd Zd ZRS(sAbstract class representing tree items. Methods should typically be overridden, otherwise a default action is used. cCsdS(s)Constructor. Do whatever you need to do.N((R-((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR.9scCsdS(sReturn text string to display.N((R-((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR<scCsdS(s>Return label text string to display in front of text (if any).N((R-((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR?scCs(|jdkr!|j|_n|jS(s%Do not override! Called by TreeNode.N(t expandableR)t IsExpandable(R-((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRHDscCsdS(s"Return whether there are subitems.i((R-((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRJscCs2|jsgS|j}|s.d|_n|S(s%Do not override! Called by TreeNode.i(Rt GetSubListR(R-Ro((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRiNs    cCsdS(s-Return whether the item's text may be edited.N((R-((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRWscCsdS(s+Change the item's text (if it is editable).N((R-R ((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRZscCsdS(s-Return name of icon to be displayed normally.N((R-((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR{]scCsdS(s2Return name of icon to be displayed when selected.N((R-((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRz`scCsdS(s%Return list of items forming sublist.N((R-((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRcscCsdS(s%Called on a double-click on the item.N((R-((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRFfsN(RRt__doc__R.RRR)RRHRRiRRR{RzRRF(((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR0s          t FileTreeItemcBsMeZdZdZdZdZdZdZdZdZ RS(s4Example TreeItem subclass -- browse the file system.cCs ||_dS(N(R(R-R((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR.pscCstjj|jp|jS(N(RRR(R-((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRsscCstjj|jdkS(Nt(RRR(R-((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRvscCstjj|j}tjj||}tjj|tjj|jkrUdSy tj|j|||_Wntjk rnXdS(N(RRtdirnameRtrenameterror(R-R tnewpath((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRys' cCs|jsdSdS(Ntpython(R(R-((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR{s cCstjj|jS(N(RRtisdir(R-((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRscCsytj|j}Wntjk r-gSX|jdtjjg}x9|D]1}ttjj|j|}|j|qQW|S(Ntkey( RtlistdirRRRtnormcaseRRR(R-tnamesRoRR$((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRs ( RRRR.RRRR{RR(((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRls     tScrolledCanvascBs>eZdZdZdZdZdZdZRS(cKsd|krd|ds ss s (RtFrametframet rowconfiguretcolumnconfiguretCanvasR"Rt ScrollbarRRtsettyviewtxviewRtpage_upt page_downtunit_upt unit_downt zoom_heightR(R-Rtopts((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR.s,   cCs|jjdddS(NitpageRC(R"t yview_scroll(R-R=((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRscCs|jjdddS(NiRRC(R"R(R-R=((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRscCs|jjdddS(NitunitRC(R"R(R-R=((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRscCs|jjdddS(NiRRC(R"R(R-R=((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRscCstj|jdS(NRC(RRR(R-R=((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRs(RRR.RRRRR(((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRs      cCsddlm}t|j}|jdddd|jt|ddddd d }|jjd d d d t d}t |j d|}|j dS(Ni(tPyShellRitbgtyellowtwhiteRt takefocusiRERdtbothsC:/windows/desktop(tidlelibRtToplevelRRbRRRRRR R"R)RE(RRtscR$tnode((s(/sys/lib/python2.7/idlelib/TreeWidget.pyttests  cCst}|jddt|dddd}|jdddd ttj}t|d|}|j |j dS( NRiRRRREiRdR( R RbRRRRtcurdirR R)RIR(RR"R$R((s(/sys/lib/python2.7/idlelib/TreeWidget.pyttest2s  t__main__((((RtTkintertimpRRtidlelib.configHandlerRR3RRRt__file__t_icondirt NameErrorRt RuntimeErrorRR RRRRRR(((s(/sys/lib/python2.7/idlelib/TreeWidget.pyts,   %    <.,