Your IP : 18.118.0.93


Current Path : /opt/alt/python36/lib64/python3.6/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/idlelib/__pycache__/tree.cpython-36.opt-1.pyc

3

� f�:�
@s"ddlZddlTddlmZddlmZddlmZdZyej	j
ej	je�e�Z
Wnek
rjeZ
YnXej	je
�r~e
Znej	je�s�edef��efdd	�ZGd
d�d�ZGdd
�d
�ZGdd�de�ZGdd�d�Zdd�Zedk�rddlmZedddd�ddlmZee�dS)�N)�*)�	Scrollbar)�idleConf)�
zoomheightZIconszcan't find icon directory (%r)cCs�t�}ddl}|jtjj|d��}|j�g}d}}x�|D]�}tjjtjj|��d}t||d�}	|j	|	�t
||	ddd�}
|
j||d�t
||d	�}
|
j|d|d�|d}|d
kr<|d}d}q<W||_dS)z'Utility to display the available icons.rNz*.gif)�file�master�Zraised)�image�bdZrelief)�row�column)�text�
�)
ZTk�glob�os�path�join�sort�splitext�basename�
PhotoImage�append�Label�grid�images)Zicondir�rootr�listrrrr�namer	�label�r �1/opt/alt/python36/lib64/python3.6/idlelib/tree.py�	listicons%s&

r"c@s�eZdZdd�Zdd�Zdd�Zd*dd	�Zd+d
d�Zdd
�Zdd�Z	d,dd�Z
d-dd�Zd.dd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd/d"d#�Zd0d$d%�Zd1d&d'�Zd2d(d)�ZdS)3�TreeNodecCs:||_||_||_d|_d|_g|_d|_|_i|_dS)N�	collapsedF)	�canvas�parent�item�state�selected�children�x�y�
iconimages)�selfr%r&r'r r r!�__init__>szTreeNode.__init__cCs6x*|jdd�D]}|jj|�|j�qWd|_dS)N)r*�remove�destroyr&)r.�cr r r!r1HszTreeNode.destroycCsfy
|j|Stk
rYnXtjj|�\}}|p6d}tjjt||�}t|j|d�}||j|<|S)Nz.gif)rr)	r-�KeyErrorrrrr�ICONDIRrr%)r.rrZext�fullnamer	r r r!�geticonimageNs

zTreeNode.geticonimageNcCs:|jr
dS|j�d|_|jj|j�|j�|j�dS)NT)r)�deselectallr%�delete�image_id�drawicon�drawtext)r.�eventr r r!�selectZszTreeNode.selectcCs2|js
dSd|_|jj|j�|j�|j�dS)NF)r)r%r8r9r:r;)r.r<r r r!�deselectcszTreeNode.deselectcCs|jr|jj�n|j�dS)N)r&r7�deselecttree)r.r r r!r7kszTreeNode.deselectallcCs*|jr|j�x|jD]}|j�qWdS)N)r)r>r*r?)r.�childr r r!r?qszTreeNode.deselecttreecCs*|jdkr|j�n|j�|jj�dS)N�expanded�break)r(�collapse�expandr'�
OnDoubleClick)r.r<r r r!�flipws



z
TreeNode.flipcCs2|jj�sdS|jdkr.d|_|j�|j�dS)NrA)r'�
_IsExpandabler(�update�view)r.r<r r r!rDs

zTreeNode.expandcCs|jdkrd|_|j�dS)Nr$)r(rH)r.r<r r r!rC�s
zTreeNode.collapsecCs�|jd}|j�jd}||}|jjd�}|jj�}|jj|�}||krV||krVdS|jj|jd�\}}}	}
||kr�||kr�|||}n|}t|�|
}|jj|�dS)Nr�r�scrollregion)r,�lastvisiblechildr%ZcanvasyZwinfo_heightZ_getints�floatZyview_moveto)r.�topZbottomZheightZvisible_topZvisible_heightZvisible_bottom�x0�y0�x1�y1Zfractionr r r!rI�s

z
TreeNode.viewcCs&|jr|jdkr|jdj�S|SdS)NrAr���)r*r(rL)r.r r r!rL�szTreeNode.lastvisiblechildcCs�|jr|jj�nj|jd}d|jd<|jj�|jjt�|jdd�|jjt�\}}}}|jjdd||fd�||jd<dS)NZcursorZwatch�rr)rK)r&rHr%r8ZALL�draw�bbox�	configure)r.Z	oldcursorrOrPrQrRr r r!rH�s


zTreeNode.updatecCsxd}|||_|_|j�|j�|jdkr4||S|jsz|jj�}|sP|dSx(|D] }|j|j	||�}|jj
|�qVW|d}||}d}	x�|jD]�}|}	|j	j|d|d||ddd�|j||�}|jj
�r�|jdkr�d	}
|j}n
d
}
|j}|j|
�}|j	j|d|	d|d�}
|j	j|
d|�|j	j|
d
dd��q�W|j	j|d|d|d|	ddd�}
|j	j|
�|S)N�rArJr�	rTZgray50)�fillZ	minusnodeZplusnode)r	z<1>z
<Double-1>cSsdS)Nr )r+r r r!�<lambda>�szTreeNode.draw.<locals>.<lambda>r)r+r,r:r;r(r*r'�_GetSubList�	__class__r%rZcreate_linerUrGrCrDr6�create_image�tag_bindZ	tag_lower)r.r+r,Zdy�sublistr'r@ZcxZcyZcylastZiconname�callbackr	�idr r r!rU�sD


"


z
TreeNode.drawcCs~|jr |jj�p|jj�pd}n|jj�p,d}|j|�}|jj|j|jd|d�}||_	|jj
|d|j�|jj
|d|j�dS)NZ
openfolderZfolder�nw)�anchorr	z<1>z
<Double-1>)
r)r'�GetSelectedIconName�GetIconNamer6r%r^r+r,r9r_r=rF)r.Z	imagenamer	rbr r r!r:�s


zTreeNode.drawiconcCsf|jdd}|jd}|jj�}|r�|jj||d|d�}|jj|d|j�|jj|d|j�|jj	|�\}}}}t
|d�d	}|jj�p�d
}	y
|jWnt
k
r�Yn
X|j�y
|jWn*t
k
r�t|j|	dddd
�|_YnXtj�}
|j�r|jjtj|
d��n|jjtj|
d��|jj||d|jd�}|jjd|j�|jjd|j�||_dS)NrXr�rc)rdr
z<1>z
<Double-1>��rz	<no text>rr)r
r
ZpadxZpadyZhiliteZnormal)rdZwindow)r+r,r'�GetLabelTextr%Zcreate_textr_r=rFrV�max�GetText�entry�AttributeError�edit_finishrrrZCurrentThemer)rWZGetHighlightZ
create_window�bind�select_or_editZtext_id)r.ZtextxZtextyZ	labeltextrbrOrPrQrRr
Zthemer r r!r;�s:




zTreeNode.drawtextcCs*|jr|jj�r|j|�n
|j|�dS)N)r)r'�
IsEditable�editr=)r.r<r r r!rp	szTreeNode.select_or_editcCsrt|jdddd�|_|jjd|jd�|jjdt�|jjdd�|jj�|jjd|j	�|jjd|j
�dS)	Nrr)r
�highlightthickness�widthr
�)Zipadxz<Return>z<Escape>)ZEntryrrl�insertZselection_rangeZEND�pack�	focus_setrorn�edit_cancel)r.r<r r r!rrs
z
TreeNode.editcCs|y|j}|`Wntk
r"dSX|j�}|j�|rR||jj�krR|jj|�|jj�}||jd<|j�|j	j
�dS)Nr
)rlrm�getr1r'rk�SetTextrr;r%rx)r.r<rlr
r r r!rns

zTreeNode.edit_finishcCsBy|j}|`Wntk
r"dSX|j�|j�|jj�dS)N)rlrmr1r;r%rx)r.r<rlr r r!ry'szTreeNode.edit_cancel)N)N)N)N)N)N)N)N)N)�__name__�
__module__�__qualname__r/r1r6r=r>r7r?rFrDrCrIrLrHrUr:r;rprrrnryr r r r!r#<s(

	




*
"

	
r#c@steZdZdZdd�Zdd�Zdd�ZdZd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�TreeItemz�Abstract class representing tree items.

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

    cCsdS)z)Constructor.  Do whatever you need to do.Nr )r.r r r!r/;szTreeItem.__init__cCsdS)zReturn text string to display.Nr )r.r r r!rk>szTreeItem.GetTextcCsdS)z>Return label text string to display in front of text (if any).Nr )r.r r r!riAszTreeItem.GetLabelTextNcCs|jdkr|j�|_|jS)z%Do not override!  Called by TreeNode.N)�
expandable�IsExpandable)r.r r r!rGFs

zTreeItem._IsExpandablecCsdS)z"Return whether there are subitems.rr )r.r r r!r�LszTreeItem.IsExpandablecCs"|j�sgS|j�}|sd|_|S)z%Do not override!  Called by TreeNode.r)r��
GetSubListr�)r.r`r r r!r\PszTreeItem._GetSubListcCsdS)z-Return whether the item's text may be edited.Nr )r.r r r!rqYszTreeItem.IsEditablecCsdS)z+Change the item's text (if it is editable).Nr )r.r
r r r!r{\szTreeItem.SetTextcCsdS)z-Return name of icon to be displayed normally.Nr )r.r r r!rf_szTreeItem.GetIconNamecCsdS)z2Return name of icon to be displayed when selected.Nr )r.r r r!rebszTreeItem.GetSelectedIconNamecCsdS)z%Return list of items forming sublist.Nr )r.r r r!r�eszTreeItem.GetSubListcCsdS)z%Called on a double-click on the item.Nr )r.r r r!rEhszTreeItem.OnDoubleClick)r|r}r~�__doc__r/rkrir�rGr�r\rqr{rfrer�rEr r r r!r2s	rc@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�FileTreeItemz4Example TreeItem subclass -- browse the file system.cCs
||_dS)N)r)r.rr r r!r/rszFileTreeItem.__init__cCstjj|j�p|jS)N)rrr)r.r r r!rkuszFileTreeItem.GetTextcCstjj|j�dkS)N�)rrr)r.r r r!rqxszFileTreeItem.IsEditablecCsltjj|j�}tjj||�}tjj|�tjj|j�kr:dSytj|j|�||_Wntk
rfYnXdS)N)rr�dirnamer�rename�OSError)r.r
�newpathr r r!r{{s
zFileTreeItem.SetTextcCs|j�sdSdS)N�python)r�)r.r r r!rf�szFileTreeItem.GetIconNamecCstjj|j�S)N)rr�isdir)r.r r r!r��szFileTreeItem.IsExpandablec
Csjytj|j�}Wntk
r$gSX|jtjjd�g}x*|D]"}ttjj|j|��}|j|�q@W|S)N)�key)	r�listdirrr�r�normcaser�rr)r.�namesr`rr'r r r!r��s
zFileTreeItem.GetSubListN)r|r}r~r�r/rkrqr{rfr�r�r r r r!r�nsr�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ScrolledCanvascKs>d|krd|d<||_t|�|_|jjddd�|jjddd�t|jf|�|_|jjdddd�t|jdd	�|_	|j	jddd
d�t|jddd
�|_
|j
jdddd�|j	j|jd<|jj|j	d<|j
j|jd<|jj
|j
d<|jjd|j�|jjd|j�|jjd|j�|jjd|j�|jjd|j�|jj�dS)NZyscrollincrementrJrr)ZweightZnsew)rrZsticky�vbar)rZnse�hbarZ
horizontal)rZorientZewsZyscrollcommandZcommandZxscrollcommandz<Key-Prior>z
<Key-Next>z<Key-Up>z
<Key-Down>z<Alt-Key-2>)rZFrame�frameZrowconfigureZcolumnconfigureZCanvasr%rrr�r��setZyviewZxviewro�page_up�	page_down�unit_up�	unit_down�zoom_heightrx)r.rZoptsr r r!r/�s,
zScrolledCanvas.__init__cCs|jjdd�dS)Nr�pagerBrS)r%�yview_scroll)r.r<r r r!r��szScrolledCanvas.page_upcCs|jjdd�dS)Nrr�rB)r%r�)r.r<r r r!r��szScrolledCanvas.page_downcCs|jjdd�dS)Nr�unitrBrS)r%r�)r.r<r r r!r��szScrolledCanvas.unit_upcCs|jjdd�dS)Nrr�rB)r%r�)r.r<r r r!r��szScrolledCanvas.unit_downcCstj|j�dS)NrB)rr�r)r.r<r r r!r��szScrolledCanvas.zoom_heightN)	r|r}r~r/r�r�r�r�r�r r r r!r��sr�cCs�t|�}tt|j�jd�dd��\}}|jd|d|df�t|dddd�}|jjdd	td
�t	t
�}t|jd|�}|j
�dS)N�+rz+%d+%d�2�Zwhiter)ZbgrsZ	takefocusZboth)rDrZZside)ZToplevel�map�intZgeometry�splitr�r�rwZLEFTr�r4r#r%rD)r&rNr+r,Zscr'Znoder r r!�_tree_widget�s r��__main__)�mainzidlelib.idle_test.test_treerF)�	verbosity�exit)�run)rZtkinterZtkinter.ttkrZidlelib.configrZidlelibrr4rrr��__file__Z_icondir�	NameErrorr��RuntimeErrorr"r#rr�r�r�r|Zunittestr�Zidlelib.idle_test.htestr�r r r r!�<module>s2
w<.*



?>