Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/sys/lib/python2.7/idlelib/TreeWidget.pyo

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�`^c@sXddlZddlTddlZddlmZddlmZdZy%ejj	ejj
e�e�ZWne
k
r�eZnXejje�r�eZn%ejje�s�edef�ned�Zddd	��YZd
dd��YZdefd
��YZddd��YZd�ZedkrTddlmZee�ndS(i�N(t*(t
ZoomHeight(tidleConftIconsscan't find icon directory (%r)c	Cs8t�}ddl}|jtjj|d��}|j�g}d}}x�|D]�}tjjtjj|��d}td|d|�}	|j	|	�t
|d|	dd	d
d�}
|
jd|d
|�t
|d|�}
|
jd|d	d
|�|d	}|dkrT|d}d}qTqTW||_dS(s'Utility to display the available icons.i�Ns*.gifitfiletmastertimagetbditrelieftraisedtrowtcolumnttexti
i(
tTktglobtostpathtjointsorttsplitexttbasenamet
PhotoImagetappendtLabeltgridtimages(ticondirtrootRtlistRR
RRtnameRtlabel((s(/sys/lib/python2.7/idlelib/TreeWidget.pyt	listicons$s&	


"



tTreeNodecBs�eZd�Zd�Zd�Zdd�Zdd�Zd�Zd�Z	dd�Z
dd�Zdd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zdd�Zdd�Zdd�Zdd�ZRS(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|�|j�qWd|_dS(N(R(tremovetdestroyR)R#(R-tc((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR0GscCs�y|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|j�t|_|jj|j�|j�|j�dS(N(R'tdeselectalltTrueR"tdeletetimage_idtdrawicontdrawtext(R-tevent((s(/sys/lib/python2.7/idlelib/TreeWidget.pytselectYs	
	
cCsA|js
dSt|_|jj|j�|j�|j�dS(N(R'R&R"R9R:R;R<(R-R=((s(/sys/lib/python2.7/idlelib/TreeWidget.pytdeselectbs		
cCs'|jr|jj�n
|j�dS(N(R#R7tdeselecttree(R-((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR7js	cCs8|jr|j�nx|jD]}|j�q WdS(N(R'R?R(R@(R-tchild((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR@ps	
cCs7|jdkr|j�n
|j�|jj�dS(Ntexpandedtbreak(R%tcollapsetexpandR$t
OnDoubleClick(R-R=((s(/sys/lib/python2.7/idlelib/TreeWidget.pytflipvs



cCsF|jj�sdS|jdkrBd|_|j�|j�ndS(NRB(R$t
_IsExpandableR%tupdatetview(R-R=((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRE~s	
cCs)|jdkr%d|_|j�ndS(NR!(R%RI(R-R=((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRD�s	cCs�|jd}|j�jd}||}|jjd�}|jj�}|jj|�}||kry||krydS|jj|jd�\}}}	}
||kr�||kr�|||}n|}t|�|
}|jj|�dS(Niiitscrollregion(R+tlastvisiblechildR"tcanvasytwinfo_heightt_getintstfloattyview_moveto(R-ttoptbottomtheighttvisible_toptvisible_heighttvisible_bottomtx0ty0tx1ty1tfraction((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRJ�s

%cCs1|jr)|jdkr)|jdj�S|SdS(NRBi�(R(R%RL(R-((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRL�scCs�|jr|jj�n�|jd}d|jd<|jj�|jjt�|jdd�|jjt�\}}}}|jjddd||f�||jd<dS(NtcursortwatchiiRKi(R#RIR"R9tALLtdrawtbboxt	configure(R-t	oldcursorRXRYRZR[((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRI�s	


c
Cs�|||_|_|j�|j�|jdkr>|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
d��q�q�W|j	j|d|d|d|ddd�}|j	j|�|S(NRBiiii	itfilltgray50t	minusnodetplusnodeRs<1>s
<Double-1>cSsdS(N(R)(R*((s(/sys/lib/python2.7/idlelib/TreeWidget.pyt<lambda>�si
(R*R+R;R<R%R(R$t_GetSubListt	__class__R"Rtcreate_lineR`RHRDRER6tcreate_imagettag_bindt	tag_lower(
R-R*R+tsublistR$RAtcxtcytcylastticonnametcallbackRtid((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR`�sB

	


+	# (	cCs�|jr0|jj�p*|jj�p*d}n|jj�pBd}|j|�}|jj|j|jddd|�}||_	|jj
|d|j�|jj
|d|j�dS(Nt
openfoldertfoldertanchortnwRs<1>s
<Double-1>(
R'R$tGetSelectedIconNametGetIconNameR6R"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
|d�d	}n|jj�p�d
}	y|jWnt
k
r�nX|j�y
|j}
Wn;t
k
rBt|jd|	ddd
ddd�|_nXtjddd�}|jr�|jjtj|d��n|jjtj|d��|jj||ddd|j�}|jjd|j�|jjd|j�||_dS(NiiRxRyRs<1>s
<Double-1>i�i
s	<no text>RitpadxitpadytmaintThemeRthilitetnormaltwindow(R*R+R$tGetLabelTextR"tcreate_textRmR>RGRatmaxtGetTexttentrytAttributeErrortedit_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(|jj�r(|j|�n
|j|�dS(N(R'R$t
IsEditableteditR>(R-R=((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR�scCs�t|jdddddd�|_|jjd|jd�|jjdt�|jjdd�|jj�|jjd	|j	�|jjd
|j
�dS(NRithighlightthicknessitwidthRtipadxis<Return>s<Escape>(tEntryRR�tinserttselection_rangetENDtpackt	focus_setR�R�tedit_cancel(R-R=((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR�
s$
cCs�y|j}|`Wntk
r'dSX|j�}|j�|rl||jj�krl|jj|�n|jj�}||jd<|j�|j	j
�dS(NR(R�R�tgetR0R$R�tSetTextRR<R"R�(R-R=R�R((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR�s	




cCsMy|j}|`Wntk
r'dSX|j�|j�|jj�dS(N(R�R�R0R<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<R�R�R�R�(((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR ;s(	
								
	)	
	"	tTreeItemcBs�eZdZd�Zd�Zd�Zd
Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zd�ZRS(s�Abstract 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.pyR�JscCs2|j�sgS|j�}|s.d|_n|S(s%Do not override!  Called by TreeNode.i(R�t
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.pyR�WscCsdS(s+Change the item's text (if it is editable).N((R-R((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR�ZscCsdS(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.pyR�cscCsdS(s%Called on a double-click on the item.N((R-((s(/sys/lib/python2.7/idlelib/TreeWidget.pyRFfsN(R�R�t__doc__R.R�R�R)R�RHR�RiR�R�R{RzR�RF(((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR�0s												tFileTreeItemcBsMeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	RS(s4Example TreeItem subclass -- browse the file system.cCs
||_dS(N(R(R-R((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR.pscCstjj|j�p|jS(N(RRR(R-((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR�sscCstjj|j�dkS(Nt(RRR(R-((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR�vscCs�tjj|j�}tjj||�}tjj|�tjj|j�krUdSy tj|j|�||_Wntjk
r�nXdS(N(RRtdirnameRtrenameterror(R-Rtnewpath((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR�ys'
cCs|j�sdSdS(Ntpython(R�(R-((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR{�scCstjj|j�S(N(RRtisdir(R-((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR��scCs�ytj|j�}Wntjk
r-gSX|jdtjj�g}x9|D]1}ttjj|j|��}|j|�qQW|S(Ntkey(	RtlistdirRR�RtnormcaseR�RR(R-tnamesRoRR$((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR��s
(
R�R�R�R.R�R�R�R{R�R�(((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR�ls						tScrolledCanvascBs>eZd�Zd�Zd�Zd�Zd�Zd�ZRS(cKs�d|krd|d<n||_t|�|_|jjddd�|jjddd�t|j|�|_|jjdddddd	�t|jd
d�|_	|j	jdddddd�t|jd
d
dd�|_
|j
jdddddd�|j	j|jd<|jj|j	d<|j
j|jd<|jj
|j
d<|jjd|j�|jjd|j�|jjd|j�|jjd|j�|jjd|j�|jj�dS(NtyscrollincrementiitweightiR
RtstickytnsewRtvbartnsethbartorientt
horizontaltewstyscrollcommandtcommandtxscrollcommands<Key-Prior>s
<Key-Next>s<Key-Up>s
<Key-Down>s<Alt-Key-2>(RtFrametframetrowconfiguretcolumnconfiguretCanvasR"Rt	ScrollbarR�R�tsettyviewtxviewR�tpage_upt	page_downtunit_upt	unit_downtzoom_heightR�(R-Rtopts((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR.�s,
	cCs|jjdd�dS(Ni�tpageRC(R"tyview_scroll(R-R=((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR��scCs|jjdd�dS(NiR�RC(R"R�(R-R=((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR��scCs|jjdd�dS(Ni�tunitRC(R"R�(R-R=((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR��scCs|jjdd�dS(NiR�RC(R"R�(R-R=((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR��scCstj|j�dS(NRC(RR�R(R-R=((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR��s(R�R�R.R�R�R�R�R�(((s(/sys/lib/python2.7/idlelib/TreeWidget.pyR��s					c	Cs�t�}|jd�ttttjd|j����\}}}}|jd||df�t|ddddd	d
�}|j	j
dd
dd
dt�tt
j��}t|jd|�}|j�|j�dS(NsTest TreeWidgets[x+]s+%d+%di�tbgtwhiteR�it	takefocusiRERdtbothtside(R
ttitleRtmaptinttretsplittgeometryR�R�R�tLEFTR�RtgetcwdR R"R)REtmainloop(	R#RR�RTR*R+tscR$tnode((s(/sys/lib/python2.7/idlelib/TreeWidget.pyt_tree_widget�s	
3
t__main__(trun((((RtTkintertimptidlelibRtidlelib.configHandlerRR3RRR�t__file__t_icondirt	NameErrorR�tRuntimeErrorRR R�R�R�R�R�tidlelib.idle_test.htestR�(((s(/sys/lib/python2.7/idlelib/TreeWidget.pyt<module>s,
%

	�.*	

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].