AlkantarClanX12

Your IP : 18.222.92.56


Current Path : /proc/self/root/opt/alt/python35/lib64/python3.5/idlelib/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python35/lib64/python3.5/idlelib/__pycache__/MultiCall.cpython-35.pyc



��Yf�H�@s�dZddlZddlZddlZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZdZdZdZdZdZdQZdRZdSZdTZdUZdVZ ej!dkrd[Z"eeee fZ#nd`Z"eeeefZ#e$d!d"�e%e&e"��D��Z'd#Z(Gd$d%�d%�Z)e%de&e"�>�Z*d&d"�e*D�Z+d'd(�Z,e,e*�Z-gZ.xZe*D]RZ/dZ0x6e%e&e"��D]"Z1de1>e/@r�e0e#e1OZ0q�We.j2e0�q�WGd)d*�d*�Z3dxZ4e3fde)fe&e4�dZ5e$dDd"�e%e&e4��D��Z6ej7dE�Z8ej7dF�Z9dGdH�Z:dIdJ�Z;iZ<dKdL�Z=dMdN�Z>e?dOkr�ddPl@mAZAeAe>�dS)ya�
MultiCall - a class which inherits its methods from a Tkinter widget (Text, for
example), but enables multiple calls of functions per virtual event - all
matching events will be called, not only the most specific one. This is done
by wrapping the event functions - event_add, event_delete and event_info.
MultiCall recognizes only a subset of legal event sequences. Sequences which
are not recognized are treated by the original Tk handling mechanism. A
more-specific event will be called before a less-specific event.

The recognized sequences are complete one-event sequences (no emacs-style
Ctrl-X Ctrl-C, no shortcuts like <3>), for all types of events.
Key/Button Press/Release events can have modifiers.
The recognized modifiers are Shift, Control, Option and Command for Mac, and
Control, Alt, Shift, Meta/M for other platforms.

For all events which were handled by MultiCall, a new member is added to the
event instance passed to the binded functions - mc_type. This is one of the
event type constants defined in this module (such as MC_KEYPRESS).
For Key/Button events (which are handled by MultiCall and may receive
modifiers), another member is added - mc_state. This member gives the state
of the recognized modifiers, as a combination of the modifier constants
also defined in this module (for example, MC_SHIFT).
Using these members is absolutely portable.

The order by which events are called is defined by these rules:
1. A more-specific event will be called before a less-specific event.
2. A recently-binded event will be called before a previously-binded event,
   unless this conflicts with the first rule.
Each function will be called at most once for each event.
�N���������	�
���
����������darwin�Shift�Control�Option�Command�Alt�Meta�McCs-g|]#}t|D]}||f�qqS�)�
_modifiers)�.0�number�namer r �6/opt/alt/python35/lib64/python3.5/idlelib/MultiCall.py�
<listcomp>7s	r&zapplication has been destroyedc@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�
_SimpleBindercCsJ||_dt|dd|_||_||_g|_d|_dS)N�<r�>)�type�_types�sequence�widget�
widgetinst�bindedfuncs�	handlerid)�selfr*r-r.r r r%�__init__Js				z_SimpleBinder.__init__cCsV|jsB|j|jdd�}|jj|j|j|�|_|jj|�dS)NcSsp||_i}xZtt|�ddd�D]<}||}||kr,d||<||�}|r,|Sq,WdS)NrT���r3)�mc_type�range�len)�event�lr4�	wascalled�i�func�rr r r%�handlerTs	#

z#_SimpleBinder.bind.<locals>.handler)r0r/r*r-�bindr.r,�append)r1�tripletr;r=r r r%r>Rs
	
z_SimpleBinder.bindcCsE|jj|�|jsA|jj|j|j|j�d|_dS)N)r/�remover-�unbindr.r,r0)r1r@r;r r r%rBbs	z_SimpleBinder.unbindcCsq|jrmy#|jj|j|j|j�Wn>tjk
rl}zt|jdkrZ�WYdd}~XnXdS)Nr)	r0r-rBr.r,�tkinter�TclError�APPLICATION_GONE�args)r1�er r r%�__del__hs	z_SimpleBinder.__del__N)�__name__�
__module__�__qualname__r2r>rBrHr r r r%r'Isr'cs8g|].�dj�fdd�tt�D���qS)�c3s1|]'\}}d|>�@r|ddVqdS)rr�-Nr )r"r:�m)�sr r%�	<genexpr>ws	z<listcomp>.<genexpr>)�join�	enumerater!)r"r )rOr%r&ws	csodd�}g}xV|D]N�tt�fdd�|D���}|jd|dd�|j|�qW|S)z�For each item of states return a list containing all combinations of
    that item with individual bits reset, sorted by the number of set bits.
    cSs6d}x)|r1t|d�\}}||7}q	W|S)znumber of bits set in n base 2rr)�divmod)�nZnbZremr r r%�nbits�s
	zexpand_substates.<locals>.nbitsc3s|]}�|@VqdS)Nr )r"�x)�stater r%rP�sz#expand_substates.<locals>.<genexpr>�key�reverseT)�list�set�sortr?)ZstatesrUZ	statelistZ	substatesr )rWr%�expand_substates|s
%r]c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�_ComplexBindercCs%||||j|jdd�}|S)NcSs�dg|dd�<||_||_i}d}xs|D]k}x[tt|�ddd�D]=}	||	}
|
|kr[d||
<||	|�}|r[Pq[W|r8Pq8Wg|dd�<x|D]
}|�q�Wg|dd�<|r�|SdS)NTrr3r3)r4�mc_stater5r6)r7�listsr4r_�ishandlerrunning�doafterhandlerr9r<r8r:r;�fr r r%r=�s*		
#


z0_ComplexBinder.__create_handler.<locals>.handler)rarb)r1r`r4r_r=r r r%Z__create_handler�s
z_ComplexBinder.__create_handlercs�|�_t|d�_|�_|�_ddd�tD�i�_g�_g�_g�_	x�tD]�}�fdd�t
|D�}�j||t|�}dt
|�jd}�jj|�jj�j||�f�qjWdS)NrcSsg|]}g�qSr r )r"rOr r r%r&�s	z+_ComplexBinder.__init__.<locals>.<listcomp>cs!g|]}�jd|�qS)N)r/)r"r:)r1r r%r&�s	r(r))r*r+�typenamer-r.�_statesr/�
handleridsrarb�_state_subsets�_ComplexBinder__create_handler�_state_codes�_state_namesr?r>)r1r*r-r.rOr`r=�seqr )r1r%r2�s						
z_ComplexBinder.__init__cs�d�jkr�dd�tD��j�d<x�tD]����fdd��ddfD�}�j|�jt��}dt��j�df}�jj|�j	j
�j||�f�q8W���fdd�}�js�|�n�j
j|�dS)NrcSsg|]}g�qSr r )r"rOr r r%r&�s	z'_ComplexBinder.bind.<locals>.<listcomp>cs2g|](}t�D]}�j||�qqSr )rgr/)r"�detailr:)rOr1r r%r&�s	z	<%s%s-%s>cs �j�d�dj��S)Nrr)r/r?r )r;r1r@r r%�<lambda>�sz%_ComplexBinder.bind.<locals>.<lambda>)r/rerhr*rirjrdrfr?r-r>r.rarb)r1r@r;r`r=rk�doitr )r;rOr1r@r%r>�s

	
z_ComplexBinder.bindcs?���fdd�}�js+|�n�jj|�dS)Ncs �j�d�dj��S)Nrr)r/rAr )r;r1r@r r%rm�sz'_ComplexBinder.unbind.<locals>.<lambda>)rarbr?)r1r@r;rnr )r;r1r@r%rB�s	
z_ComplexBinder.unbindcCs|xu|jD]j\}}y|jj|j||�Wq
tjk
rs}zt|jdkra�WYdd}~Xq
Xq
WdS)Nr)rfr-rBr.rCrDrErF)r1rk�idrGr r r%rH�sz_ComplexBinder.__del__N)rIrJrKrhr2r>rBrHr r r r%r^�s
r^�KeyPress�Key�
KeyRelease�ButtonPress�Button�
ButtonRelease�Activate�	Circulate�Colormap�	Configure�
Deactivate�Destroy�Enter�Expose�FocusIn�FocusOut�Gravity�Leave�Map�Motion�
MouseWheel�Property�Reparent�Unmap�
VisibilitycCs-g|]#}t|D]}||f�qqSr )r+)r"r#r$r r r%r&s	z^\w+$z^[1-5]$cCsY|s'|ddks'|ddkr+dS|dd�jd�}d}x7|r�|dtkr�|dt|d>O}|d=qMW|r�|dtkr�t|d}|d=ndSt|tkr�|s�|r�dSd}nm|dd�d
D�krt}nt}|sd}n6t|�dkrH|j|d�rH|d}ndS|||fS)a-Get a string which should describe an event sequence. If it is
    successfully parsed as one, return a tuple containing the state (as an int),
    the event type (as an index of _types), and the detail - None if none, or a
    string if there is one. If the parsing is unsuccessful, return None.
    rr(rr)NrMcSsg|]}t|�qSr )�_type_names)r"rOr r r%r&$s	z#_parse_sequence.<locals>.<listcomp>rprrr3r3)rprr)	�split�_modifier_namesr��_binder_classesr'�
_keysym_re�
_button_rer6�match)r,ZwordsZ	modifiersr*rlZtype_rer r r%�_parse_sequences0'
			%
r�cCsb|dr:dt|dt|ddd|ddSdt|dt|dddSdS)Nrr(rrrMr))rjr+)r@r r r%�_triplet_to_sequence2s
0r�cs>�tkrt�SG�fdd�d��}|t�<|S)z�Return a MultiCall class which inherits its methods from the
    given widget class (for example, Tkinter.Text). This is used
    instead of a templating mechanism.
    cs�eZdZe�ej�s$t��fdd�Zddd�fdd�Zd�fdd�Z	�fdd	�Z
�fd
d�Zd�fdd
�Zdd�Z
dS)z#MultiCallCreator.<locals>.MultiCallcsK�j�||�i�_��fdd�ttt��D��_dS)Ncs&g|]}t||����qSr )r�)r"r:)r1r-r r%r&Ks	z@MultiCallCreator.<locals>.MultiCall.__init__.<locals>.<listcomp>)r2�_MultiCall__eventinfor5r6r+�_MultiCall__binders)r1rF�kwargs)r-)r1r%r2Es	z,MultiCallCreator.<locals>.MultiCall.__init__Ncs&t|�tkrt|�dkr|dd�dkr|dd�dkr||jkr�|j|}|ddk	r�x1|dD]%}|j|dj||d�q�W||d<|ddk	rxC|dD]!}|j|dj||�q�Wn|gg|j|<�j||||�S)Nrz<<z>>rr���)r*�strr6r�r�rBr>)r1r,r;�addZeir@)r-r r%r>Ns$,
#
"z(MultiCallCreator.<locals>.MultiCall.bindcs�t|�tkr�t|�dkr�|dd�dkr�|dd�dkr�||jkr�|j|\}}|dk	r�x)|D]!}|j|dj||�q�Wd|j|d<�j|||�S)Nrz<<z>>rrr�)r*r�r6r�r�rB)r1r,Zfuncidr;�tripletsr@)r-r r%rB`s$,
z*MultiCallCreator.<locals>.MultiCall.unbindcs�||jkr"dgg|j|<|j|\}}xp|D]h}t|�}|dkrp�j|||�q<|dk	r�|j|dj||�|j|�q<WdS)Nr)r�r��	event_addr�r>r?)r1�virtual�	sequencesr;r�rkr@)r-r r%r�ks
z-MultiCallCreator.<locals>.MultiCall.event_addcs�||jkrdS|j|\}}xp|D]h}t|�}|dkra�j|||�q-|dk	r�|j|dj||�|j|�q-WdS)Nr)r�r��event_deleter�rBrA)r1r�r�r;r�rkr@)r-r r%r�|s
z0MultiCallCreator.<locals>.MultiCall.event_deletecs]|dks||jkr+�j||�Sttt|j|d���j||�SdS)Nr)r��
event_info�tuple�mapr�)r1r�)r-r r%r��s
	z.MultiCallCreator.<locals>.MultiCall.event_infocSs�x�|jD]�}|j|\}}|r
xn|D]f}y|j|dj||�Wq0tjk
r�}zt|jdkr��WYdd}~Xq0Xq0Wq
WdS)Nrr)r�r�rBrCrDrErF)r1r�r;r�r@rGr r r%rH�s
z+MultiCallCreator.<locals>.MultiCall.__del__)rIrJrK�
issubclassrCZMisc�AssertionErrorr2r>rBr�r�r�rHr )r-r r%�	MultiCallBs	r�)�_multicall_dict)r-r�r )r-r%�MultiCallCreator:s
[
r�cs$tj�}|jd�ttttjd|j����\}}}}|jd||df�t	tj
�|���j�dg�fdd�}|d�|d	�|d
�|d�|d�|d
�|d�|d�|d�|d�|d�|d�|j�dS)NzTest MultiCallz[x+]z+%d+%d�rcsT�fdd�}�jd|d|��jd|d��|dd7<dS)Ncst��dS)N)�print)r7)rkr r%r=�sz-_multi_call.<locals>.bindseq.<locals>.handlerz
<<handler%d>>rr)r>r�)rkrTr=)�text)rkr%�bindseq�sz_multi_call.<locals>.bindseqz<Key>z
<Control-Key>z<Alt-Key-a>z<Control-Key-a>z<Alt-Control-Key-a>z<Key-b>z<Control-Button-1>z
<Button-2>z<Alt-Button-1>z
<FocusOut>z<Enter>z<Leave>)
rCZTk�titlerZr��int�rer�Zgeometryr�ZTextZpackZmainloop)�parent�root�widthZheightrV�yr�r )r�r%�_multi_call�s(
3












r��__main__)�runrrr	� �@��r�r�r�r)r�r�r�r��r�r�r�rr)r�r�r�r��rprq�rr�rsrt�ru�rv�rw�rx�ry�rz�r{�r|�r}�r~�r�r��r��r��r��r��r��r��r��r�)r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�)B�__doc__�sysr�rCZMC_KEYPRESSZ
MC_KEYRELEASEZMC_BUTTONPRESSZMC_BUTTONRELEASEZMC_ACTIVATEZMC_CIRCULATEZMC_COLORMAPZMC_CONFIGUREZ
MC_DEACTIVATEZ
MC_DESTROYZMC_ENTERZ	MC_EXPOSEZ
MC_FOCUSINZMC_FOCUSOUTZ
MC_GRAVITYZMC_LEAVEZMC_MAPZ	MC_MOTIONZ
MC_MOUSEWHEELZMC_PROPERTYZMC_REPARENTZMC_UNMAPZ
MC_VISIBILITYZMC_SHIFTZ
MC_CONTROLZMC_ALTZMC_METAZ	MC_OPTIONZ
MC_COMMAND�platformr!Z_modifier_masks�dictr5r6r�rEr'rerjr]rgrirOr<r:r?r^r+r�r��compiler�r�r�r�r�r�r�rIZidlelib.idle_test.htestr�r r r r%�<module>s�
-	

`"'g