a
    åzeq  ã                   @   sr   d dl T d dlmZmZ d dlmZ G dd„ dƒZdd„ Zedkrnd d	l	m
Z
 e
d
dd d dlmZ eeƒ dS )é    )Ú*)ÚFrameÚ	Scrollbar)Úmacosxc                   @   sŒ   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dZdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ ZdS )!ÚScrolledListz(None)c                 K   s  || _ t|ƒ | _}| jjddd t|dd | _}| jjddd t|d	d
d | _}|rh| |¡ |jddd |j	|d< |j
|d< | d| j¡ | d| j¡ t ¡ rÌ| d| j¡ | d| j¡ n| d| j¡ | d| j¡ | d| j¡ |  ¡  d S )NZbothé   )ÚfillÚexpandÚvbar)ÚnameÚrightÚy)Zsider   r   Zwhite)ZexportselectionZ
background)r	   r   ZcommandZyscrollcommandz<ButtonRelease-1>z<Double-ButtonRelease-1>z<ButtonPress-2>z<Control-Button-1>z<ButtonPress-3>z<Key-Up>z
<Key-Down>)Úmasterr   ÚframeÚpackr   r
   ZListboxÚlistboxZ	configureZyviewÚsetÚbindÚclick_eventÚdouble_click_eventr   ZisAquaTkÚpopup_eventÚup_eventÚ
down_eventÚclear)Úselfr   Úoptionsr   r
   r   © r   ú*/usr/lib/python3.9/idlelib/scrolledlist.pyÚ__init__   s,    ÿ


zScrolledList.__init__c                 C   s   | j  ¡  d S ©N)r   Zdestroy©r   r   r   r   Úclose'   s    zScrolledList.closec                 C   s(   | j  dd¡ d| _| j  d| j¡ d S )Nr   Úendr   )r   ÚdeleteÚemptyÚinsertÚdefaultr    r   r   r   r   *   s    zScrolledList.clearc                 C   s0   | j r| j dd¡ d| _ | j dt|ƒ¡ d S ©Nr   r"   )r$   r   r#   r%   Ústr)r   Úitemr   r   r   Úappend/   s    zScrolledList.appendc                 C   s   | j  |¡S r   )r   Úget©r   Úindexr   r   r   r+   5   s    zScrolledList.getc                 C   s<   | j  d|j|jf ¡ | j  d¡}|  |¡ |  |¡ dS ©Nz@%d,%dÚactiveÚbreak)r   ÚactivateÚxr   r-   ÚselectÚ	on_select©r   Úeventr-   r   r   r   r   8   s
    

zScrolledList.click_eventc                 C   s$   | j  d¡}|  |¡ |  |¡ dS )Nr/   r0   )r   r-   r3   Ú	on_doubler5   r   r   r   r   ?   s    

zScrolledList.double_click_eventNc                 C   sV   | j s|  ¡  | j }| j d|j|jf ¡ | j d¡}|  |¡ | |j	|j
¡ dS r.   )ÚmenuÚ	make_menur   r1   r2   r   r-   r3   Ztk_popupZx_rootZy_root)r   r6   r8   r-   r   r   r   r   G   s    
zScrolledList.popup_eventc                 C   s    t | jdd}|| _|  ¡  d S )Nr   )Ztearoff)ZMenur   r8   Ú	fill_menu)r   r8   r   r   r   r9   Q   s    zScrolledList.make_menuc                 C   s\   | j  d¡}| j  |¡r"|d }n| j  ¡ d }|dk rD| j  ¡  n|  |¡ |  |¡ dS ©Nr/   r   r   r0   ©r   r-   Zselection_includesÚsizeZbellr3   r4   r5   r   r   r   r   V   s    


zScrolledList.up_eventc                 C   sX   | j  d¡}| j  |¡r"|d }nd}|| j  ¡ kr@| j  ¡  n|  |¡ |  |¡ dS r;   r<   r5   r   r   r   r   c   s    


zScrolledList.down_eventc                 C   s@   | j  ¡  | j  |¡ | j  dd¡ | j  |¡ | j  |¡ d S r'   )r   Z	focus_setr1   Zselection_clearZselection_setZseer,   r   r   r   r3   p   s
    
zScrolledList.selectc                 C   s   d S r   r   r    r   r   r   r:   y   s    zScrolledList.fill_menuc                 C   s   d S r   r   r,   r   r   r   r4   |   s    zScrolledList.on_selectc                 C   s   d S r   r   r,   r   r   r   r7      s    zScrolledList.on_double)Ú__name__Ú
__module__Ú__qualname__r&   r   r!   r   r*   r+   r   r   r8   r   r9   r   r   r3   r:   r4   r7   r   r   r   r   r      s"   
	r   c                 C   sz   t | ƒ}tt|  ¡  d¡dd … ƒ\}}| d|d |d f ¡ G dd„ dtƒ}||ƒ}tdƒD ]}| d	| ¡ qbd S )
Nú+r   z+%d+%déÈ   é¯   c                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )z&_scrolled_list.<locals>.MyScrolledListc                 S   s   | j jdd d S )Nzright click)Zlabel)r8   Zadd_commandr    r   r   r   r:   ˆ   ó    z0_scrolled_list.<locals>.MyScrolledList.fill_menuc                 S   s   t d|  |¡ƒ d S )Nr3   ©Úprintr+   r,   r   r   r   r4   ‰   rD   z0_scrolled_list.<locals>.MyScrolledList.on_selectc                 S   s   t d|  |¡ƒ d S )NZdoublerE   r,   r   r   r   r7   Š   rD   z0_scrolled_list.<locals>.MyScrolledList.on_doubleN)r>   r?   r@   r:   r4   r7   r   r   r   r   ÚMyScrolledList‡   s   rG   é   z	Item %02d)ZToplevelÚmapÚintZgeometryÚsplitr   Úranger*   )ÚparentÚtopr2   r   rG   Zscrolled_listÚir   r   r   Ú_scrolled_listƒ   s     rP   Ú__main__)Úmainz#idlelib.idle_test.test_scrolledlisté   )Ú	verbosity)ÚrunN)ÚtkinterZtkinter.ttkr   r   Zidlelibr   r   rP   r>   ZunittestrR   Zidlelib.idle_test.htestrU   r   r   r   r   Ú<module>   s   |