ok

Mini Shell

Direktori : /proc/thread-self/root/opt/alt/python37/lib64/python3.7/idlelib/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python37/lib64/python3.7/idlelib/__pycache__/tree.cpython-37.pyc

B

� f�?�@s0ddlZddlTddlmZmZddlmZddlmZdZ	yej
�ej
�e
�e	�ZWnek
rne	ZYnXej
�e�r�eZ	nej
�e	�s�ede	f��e	fdd	�Zdd
d�ZGdd
�d
�ZGdd�d�ZGdd�de�ZGdd�d�Zdd�Zedk�r,ddlmZedddd�ddlmZee�dS)�N)�*)�Frame�	Scrollbar)�idleConf)�
zoomheightZIconszcan't find icon directory (%r)cCs�t�}ddl}|�tj�|d��}|��g}d}}x�|D]�}tj�tj�|��d}t||d�}	|�	|	�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�listrrr
r�namer
�label�r!�1/opt/alt/python37/lib64/python3.7/idlelib/tree.py�	listicons%s&

r#cCsRtj|jdktj|jdki}||jr*dnd}|dkr<|jn|}|�t|d�dS)a6Handle scrollwheel event.

    For wheel up, event.delta = 120*n on Windows, -1*n on darwin,
    where n can be > 1 if one scrolls fast.  Flicking the wheel
    generates up to maybe 20 events with n up to 10 or more 1.
    Macs use wheel down (delta = 1*n) to scroll up, so positive
    delta means to scroll up on both systems.

    X-11 sends Control-Button-4,5 events instead.

    The widget parameter is needed so browser label bindings can pass
    the underlying canvas.

    This function depends on widget.yview to not be overridden by
    a subclass.
    r�����NZunits�break)	Z	EventTypeZ
MouseWheelZdeltaZButtonPressZnum�type�widget�yviewZSCROLL)�eventr)Zup�linesr!r!r"�wheel_event;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)�selfr0r1r2r!r!r"�__init__VszTreeNode.__init__cCs6x*|jdd�D]}|j�|�|��qWd|_dS)N)r5�remove�destroyr1)r9�cr!r!r"r<`szTreeNode.destroycCsfy
|j|Stk
rYnXtj�|�\}}|p6d}tj�t||�}t|j|d�}||j|<|S)Nz.gif)rr)	r8�KeyErrorrrrr�ICONDIRrr0)r9rrZext�fullnamer
r!r!r"�geticonimagefs

zTreeNode.geticonimageNcCs:|jr
dS|��d|_|j�|j�|��|��dS)NT)r4�deselectallr0�delete�image_id�drawicon�drawtext)r9r+r!r!r"�selectrszTreeNode.selectcCs2|js
dSd|_|j�|j�|��|��dS)NF)r4r0rCrDrErF)r9r+r!r!r"�deselect{szTreeNode.deselectcCs|jr|j��n|��dS)N)r1rB�deselecttree)r9r!r!r"rB�szTreeNode.deselectallcCs*|jr|��x|jD]}|��qWdS)N)r4rHr5rI)r9�childr!r!r"rI�szTreeNode.deselecttreecCs*|jdkr|��n|��|j��dS)N�expandedr')r3�collapse�expandr2�
OnDoubleClick)r9r+r!r!r"�flip�s



z
TreeNode.flipcCs2|j��sdS|jdkr.d|_|��|��dS)NrK)r2�
_IsExpandabler3�update�view)r9r+r!r!r"rM�s

zTreeNode.expandcCs|jdkrd|_|��dS)Nr/)r3rQ)r9r+r!r!r"rL�s
zTreeNode.collapsecCs�|jd}|��jd}||}|j�d�}|j��}|j�|�}||krV||krVdS|j�|jd�\}}}	}
||kr�||kr�|||}n|}t|�|
}|j�|�dS)Nr�r�scrollregion)r7�lastvisiblechildr0ZcanvasyZwinfo_heightZ_getints�floatZyview_moveto)r9�topZbottomZheightZvisible_topZvisible_heightZvisible_bottom�x0�y0�x1�y1Zfractionr!r!r"rR�s

z
TreeNode.viewcCs&|jr|jdkr|jd��S|SdS)NrK���)r5r3rU)r9r!r!r"rU�szTreeNode.lastvisiblechildcCs�|jr|j��nj|jd}d|jd<|j��|j�t�|�dd�|j�t�\}}}}|jjdd||fd�||jd<dS)NZcursorZwatch�rr)rT)r1rQr0rCZALL�draw�bbox�	configure)r9Z	oldcursorrXrYrZr[r!r!r"rQ�s


zTreeNode.updatecCsxd}|||_|_|��|��|jdkr4||S|jsz|j��}|sP|dSx(|D] }|�|j	||�}|j�
|�qVW|d}||}d}	x�|jD]�}|}	|j	j|d|d||ddd�|�||�}|j�
�r�|jdkr�d	}
|j}n
d
}
|j}|�|
�}|j	j|d|	d|d�}
|j	�|
d|�|j	�|
d
dd��q�W|j	j|d|d|d|	ddd�}
|j	�|
�|S)N�rKrSr�	r]Zgray50)�fillZ	minusnodeZplusnode)r
z<1>z
<Double-1>cSsdS)Nr!)r6r!r!r"�<lambda>��zTreeNode.draw.<locals>.<lambda>r)r6r7rErFr3r5r2�_GetSubList�	__class__r0rZcreate_liner^rPrLrMrA�create_image�tag_bindZ	tag_lower)r9r6r7Zdy�sublistr2rJZcxZcyZcylastZiconname�callbackr
�idr!r!r"r^�sD


"


z
TreeNode.drawcCs~|jr |j��p|j��pd}n|j��p,d}|�|�}|jj|j|jd|d�}||_	|j�
|d|j�|j�
|d|j�dS)NZ
openfolderZfolder�nw)�anchorr
z<1>z
<Double-1>)
r4r2�GetSelectedIconName�GetIconNamerAr0rhr6r7rDrirGrO)r9Z	imagenamer
rlr!r!r"rE�s


zTreeNode.drawiconc
s��jdd}�jd}�j��}|r��jj||d|d�}�j�|d�j��j�|d�j��j�	|�\}}}}t
|d�d	}�j��p�d
}	y
�jWnt
k
r�Yn
X���y
�jWn*t
k
r�t�j|	dddd
��_YnXt��}
�j�r�j�t�|
d��n�j�t�|
d���jj||d�jd�}�j�d�j��j�d�j��j�d�fdd���j�d�fdd���j�d�fdd��|�_dS)Nrar	r$rm)rnrz<1>z
<Double-1>��rz	<no text>rr)rrZpadxZpadyZhiliteZnormal)rnZwindowz<MouseWheel>cst|�j�S)N)r-r0)�e)r9r!r"rdrez#TreeNode.drawtext.<locals>.<lambda>z
<Button-4>cst|�j�S)N)r-r0)rr)r9r!r"rd rez
<Button-5>cst|�j�S)N)r-r0)rr)r9r!r"rd!re)r6r7r2�GetLabelTextr0Zcreate_textrirGrOr_�max�GetText�entry�AttributeError�edit_finishr rrZCurrentThemer4r`ZGetHighlightZ
create_window�bind�select_or_editZtext_id)r9ZtextxZtextyZ	labeltextrlrXrYrZr[rZthemer!)r9r"rF�s@




zTreeNode.drawtextcCs*|jr|j��r|�|�n
|�|�dS)N)r4r2�
IsEditable�editrG)r9r+r!r!r"rz$szTreeNode.select_or_editcCsrt|jdddd�|_|j�d|jd�|j�dt�|jjdd�|j��|j�d|j	�|j�d|j
�dS)	Nrr	)r�highlightthickness�widthrr&)Zipadxz<Return>z<Escape>)ZEntryr rv�insertZselection_rangeZEND�pack�	focus_setryrx�edit_cancel)r9r+r!r!r"r|*s
z
TreeNode.editcCs|y|j}|`Wntk
r"dSX|��}|��|rR||j��krR|j�|�|j��}||jd<|��|j	�
�dS)Nr)rvrw�getr<r2ru�SetTextr rFr0r�)r9r+rvrr!r!r"rx3s

zTreeNode.edit_finishcCsBy|j}|`Wntk
r"dSX|��|��|j��dS)N)rvrwr<rFr0r�)r9r+rvr!r!r"r�BszTreeNode.edit_cancel)N)N)N)N)N)N)N)N)N)�__name__�
__module__�__qualname__r:r<rArGrHrBrIrOrMrLrRrUrQr^rErFrzr|rxr�r!r!r!r"r.Ts(

	




*
%

	
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!)r9r!r!r"r:VszTreeItem.__init__cCsdS)zReturn text string to display.Nr!)r9r!r!r"ruYszTreeItem.GetTextcCsdS)z>Return label text string to display in front of text (if any).Nr!)r9r!r!r"rs\szTreeItem.GetLabelTextNcCs|jdkr|��|_|jS)z%Do not override!  Called by TreeNode.N)�
expandable�IsExpandable)r9r!r!r"rPas

zTreeItem._IsExpandablecCsdS)z"Return whether there are subitems.r	r!)r9r!r!r"r�gszTreeItem.IsExpandablecCs"|��sgS|��}|sd|_|S)z%Do not override!  Called by TreeNode.r)r��
GetSubListr�)r9rjr!r!r"rfkszTreeItem._GetSubListcCsdS)z-Return whether the item's text may be edited.Nr!)r9r!r!r"r{tszTreeItem.IsEditablecCsdS)z+Change the item's text (if it is editable).Nr!)r9rr!r!r"r�wszTreeItem.SetTextcCsdS)z-Return name of icon to be displayed normally.Nr!)r9r!r!r"rpzszTreeItem.GetIconNamecCsdS)z2Return name of icon to be displayed when selected.Nr!)r9r!r!r"ro}szTreeItem.GetSelectedIconNamecCsdS)z%Return list of items forming sublist.Nr!)r9r!r!r"r��szTreeItem.GetSubListcCsdS)z%Called on a double-click on the item.Nr!)r9r!r!r"rN�szTreeItem.OnDoubleClick)r�r�r��__doc__r:rursr�rPr�rfr{r�rpror�rNr!r!r!r"r�Ms	r�c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�FileTreeItemz4Example TreeItem subclass -- browse the file system.cCs
||_dS)N)r)r9rr!r!r"r:�szFileTreeItem.__init__cCstj�|j�p|jS)N)rrr)r9r!r!r"ru�szFileTreeItem.GetTextcCstj�|j�dkS)N�)rrr)r9r!r!r"r{�szFileTreeItem.IsEditablecCsltj�|j�}tj�||�}tj�|�tj�|j�kr:dSyt�|j|�||_Wntk
rfYnXdS)N)rr�dirnamer�rename�OSError)r9r�newpathr!r!r"r��s
zFileTreeItem.SetTextcCs|��sdSdS)N�python)r�)r9r!r!r"rp�szFileTreeItem.GetIconNamecCstj�|j�S)N)rr�isdir)r9r!r!r"r��szFileTreeItem.IsExpandablecCsjyt�|j�}Wntk
r$gSX|jtjjd�g}x*|D]"}ttj�|j|��}|�|�q@W|S)N)�key)	r�listdirrr�r�normcaser�rr)r9�namesrjrr2r!r!r"r��s
zFileTreeItem.GetSubListN)r�r�r�r�r:rur{r�rpr�r�r!r!r!r"r��sr�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ScrolledCanvascKshd|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<|j�d|j�|j�d|j�|j�d|j�|j�d|j�|j�dt�|j�dt�|j�dt�|j�d|j�|j��dS)NZyscrollincrementrSrr	)ZweightZnsew)rr
Zsticky�vbar)rZnse�hbarZ
horizontal)rZorientZewsZyscrollcommandZcommandZxscrollcommandz<Key-Prior>z
<Key-Next>z<Key-Up>z
<Key-Down>z<MouseWheel>z
<Button-4>z
<Button-5>z<Alt-Key-2>)rr�frameZrowconfigureZcolumnconfigureZCanvasr0rrr�r��setr*Zxviewry�page_up�	page_down�unit_up�	unit_downr-�zoom_heightr�)r9rZoptsr!r!r"r:�s2
zScrolledCanvas.__init__cCs|j�dd�dS)Nr\�pager')r0�yview_scroll)r9r+r!r!r"r��szScrolledCanvas.page_upcCs|j�dd�dS)Nr	r�r')r0r�)r9r+r!r!r"r��szScrolledCanvas.page_downcCs|j�dd�dS)Nr\�unitr')r0r�)r9r+r!r!r"r��szScrolledCanvas.unit_upcCs|j�dd�dS)Nr	r�r')r0r�)r9r+r!r!r"r��szScrolledCanvas.unit_downcCst�|j�dS)Nr')rr�r)r9r+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|���d�dd��\}}|�d|d|df�t|dddd�}|jjdd	td
�t	t
�}t|jd|�}|�
�dS)N�+r	z+%d+%d�2�Zwhiter)Zbgr}Z	takefocusZboth)rMrcZside)ZToplevel�map�intZgeometry�splitr�r�r�ZLEFTr�r?r.r0rM)r1rWr6r7Zscr2Znoder!r!r"�_tree_widget�s r��__main__)�mainzidlelib.idle_test.test_treerF)�	verbosity�exit)�run)N)rZtkinterZtkinter.ttkrrZidlelib.configrZidlelibrr?rrr��__file__Z_icondir�	NameErrorr��RuntimeErrorr#r-r.r�r�r�r�r�Zunittestr�Zidlelib.idle_test.htestr�r!r!r!r"�<module>s4

z<..



Zerion Mini Shell 1.0