
    ;bh                     ~   d dl Z d dlZd dlZd dlZd dlmZ d dlmZmZm	Z	m
Z
  ej                  d        G d deej                        Z G d deej                        Z G d	 d
eej                        Z G d deej                        Z G d deej                        ZddZedk(  r ej(                          yy)    N)support)AbstractTkTestAbstractDefaultRootTestrequires_tkget_tk_patchlevelguic                   x    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zy)MiscTestc                    | j                  dt        j                         | j                  dt        j                         | j                  t        j                         | j                  dt        j                         | j                  dt        j                         | j                  dt        j                         | j                  dt        j                         | j                  dt        j                         y )NWidgetCASCADEresys	constants_tkerrorwantobjects)assertIntkinter__all__assertIsNotNoner   assertNotIn)selfs    E/opt/python-3.12.12/usr/lib/python3.12/test/test_tkinter/test_misc.pytest_allzMiscTest.test_all   s    h0i1W__-w/0goo6W__58    c                     t        j                  | j                  d      }t        j                  |d      }| j	                  t        |      d       y )Ntop)namechildz!<tkinter.Frame object .top.child>)r   ToplevelrootFrameassertEqualrepr)r   tfs      r   	test_reprzMiscTest.test_repr   s=    TYYU3MM!'*a"EFr   c           
          G d dt         j                        }t        j                  | j                        }t        j                  |      }t        j                  |      }| j                  t        |      t        |             t        j                  |      } ||      }t        |      j                  d      t        |      j                  d      z   D ],  }| j                  |j                         t        |             . t        j                  |      } ||      }	| j                  t        t        |      t        |      t        |      t        |	      h      d       y )Nc                       e Zd Zy).MiscTest.test_generated_names.<locals>.Button2N)__name__
__module____qualname__ r   r   Button2r*   !   s    r   r/   .)msg   )r   Buttonr    r!   r"   assertNotEqualstrsplitassertFalseisidentifierr$   r#   len)
r   r/   r%   r&   f2bb2r   b3b4s
             r   test_generated_nameszMiscTest.test_generated_names    s   	gnn 	 TYY'MM!]]1CFCG,NN2R[FLL%Bc(::DT..0d4jA ;^^BR[c!fc"gs2wB@A1Er   c                 \   | j                   }|j                  d       | j                  |d   d       |j                  d       | j                  |d   d       | j                  t        j
                  d|j                  d       |j                  d       | j                  |d   d       |j                  dd	       | j                  |d   d       | j                  |d
   d       |j                  dd	       | j                  |d   d       | j                  |d
   d       | j                  t        j
                  d|j                  d       | j                  t        j
                  d|j                  d       | j                  t        j
                  d|j                  d       y )Nblack
backgroundwhitez^unknown color name "spam"$spam)rB   blueyellow)rB   highlightColorhighlightcolorz!^must specify a background color$)rD   )rG   )r!   tk_setPaletter#   assertRaisesRegexr   TclErrorr   r!   s     r   test_tk_setPalettezMiscTest.test_tk_setPalette0   s   yy7#l+W57#l+W5w//-""F	, 	g.l+W5fXFl+V4./:hvFl+X6./8w//-""v 	 	7 	w//3"" 	 	2 	w//3""6 	 	;r   c                    | j                   }d
fd	}| j                  |j                  d             d|j                  d|      }| j                  ||j                  j                  dd             |j                  j                  |j                  j                  dd|            \  }}|j                          | j                  d       | j                  t        j                        5  |j                  j                  |       d d d        d|j                  d|dd      }|j                          | j                  d       |j                  d	|      }| j                  ||j                  j                  dd             |j                  j                  |j                  j                  dd|            \  }}|j                  |       | j                  d       | j                  t        j                        5  |j                  j                  |       d d d        d|j                  dt        j                  |dd            }|j                          | j                  d       y # 1 sw Y   kxY w# 1 sw Y   bxY w)Nr      c                     | |z   y Nr.   startstepcounts     r   callbackz%MiscTest.test_after.<locals>.callbackO       DLEr   afterinfo*      5   i  r   rO   )r!   assertIsNonerX   r   tkcall	splitlistupdater#   assertRaisesr   rK   after_cancel	functoolspartial)r   r!   rV   timer1script_rU   s         @r   
test_afterzMiscTest.test_afterL   s   yy	!
 	$**Q-( Ax(fdggll7F;<gg''Wff(MN"w//0GGLL  1 AxR0# D(+fdggll7F;<gg''Wff(MN&!#w//0GGLL  1 Ay002rBC#- 10 10s   .I3J 3I= J	c                 <   | j                   }d	fd	}d|j                  |      }| j                  ||j                  j	                  dd             |j                  j                  |j                  j	                  dd|            \  }}|j                          | j                  d       | j                  t        j                        5  |j                  j	                  |       d d d        d|j                  |dd      }|j                          | j                  d       |j                  |      }| j                  ||j                  j	                  dd             |j                  j                  |j                  j	                  dd|            \  }}|j                  |       | j                  d       | j                  t        j                        5  |j                  j	                  |       d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)
Nr   rO   c                     | |z   y rQ   r.   rR   s     r   rV   z*MiscTest.test_after_idle.<locals>.callbackx   rW   r   rX   rY   rZ   r[   r\   r]   )r!   
after_idler   r_   r`   ra   update_idletasksr#   rc   r   rK   rd   )r   r!   rV   idle1rh   ri   rU   s         @r   test_after_idlezMiscTest.test_after_idleu   s   yy	!
 )eTWW\\'6:;gg''Wfe(LM"w//0GGLL  1 "b1# )eTWW\\'6:;gg''Wfe(LM% #w//0GGLL  10 10 10s   H HHHc                    | j                   }fd}|j                  d|      }|j                  |      }| j                  t              5  |j                  d        d d d        d|j                  j                  |j                  j                  dd|            \  }}|j                  j                  |       | j                  d       |j                  |       | j                  t        j                        5  |j                  j                  |       d d d        | j                  d       | j                  t        j                        5  |j                  j                  dd|       d d d        |j                  |       d|j                  j                  |j                  j                  dd|            \  }}|j                  j                  |       | j                  d       |j                  |       | j                  t        j                        5  |j                  j                  |       d d d        | j                  d       | j                  t        j                        5  |j                  j                  dd|       d d d        y # 1 sw Y   BxY w# 1 sw Y   xY w# 1 sw Y   IxY w# 1 sw Y   xY w# 1 sw Y   y xY w)Nc                       dz   y )NrO   r.   )rU   s   r   rV   z,MiscTest.test_after_cancel.<locals>.callback   s    QJEr   i  r   rX   rY   rO   )r!   rX   rm   rc   
ValueErrorrd   r_   ra   r`   r#   r   rK   )r   r!   rV   rg   ro   rh   ri   rU   s          @r   test_after_cancelzMiscTest.test_after_cancel   s   yy	 D(+) z*d# + gg''Wff(MNV"&!w//0GGLL  1"w//0GGLL&&1 1 	&! gg''Wfe(LMV"% w//0GGLL  1"w//0GGLL&%0 107 +* 10 10 10 10s<   J=J*J7!K6KJ'*J47KKKc                    | j                   }|j                          |j                  d       | j                  |j	                         d       |j                  d       | j                  |j	                         d       |j                          | j                  t        j                        5  |j	                          d d d        y # 1 sw Y   y xY w)Nu   Ùñîu   çōđěu   Ùñîçōđěr!   clipboard_clearclipboard_appendr#   clipboard_getrc   r   rK   rL   s     r   test_clipboardzMiscTest.test_clipboard   s    yyh'++-x8j)++-/?@w//0  100   .CCc                    | j                   }|j                          |j                  d       | j                  |j	                         d       |j                  d       | j                  |j	                         d       |j                          | j                  t        j                        5  |j	                          d d d        y # 1 sw Y   y xY w)Nu   𝔘𝔫𝔦u   𝔠𝔬𝔡𝔢u   𝔘𝔫𝔦𝔠𝔬𝔡𝔢rv   rL   s     r   test_clipboard_astralzMiscTest.test_clipboard_astral   s    yyn-++-~>01++-/MNw//0  100r{   c                      fd} j                   }|j                  } j                   |d      d        j                   |d      d        j                   |d      d        | |d      d	        | |d
      d        j                  t        j
                        5   |d       d d d         j                  t        j
                        5   |d       d d d        y # 1 sw Y   :xY w# 1 sw Y   y xY w)Nc                 V    t        | |      D ]  \  }}j                  ||d        y )N!   )delta)zipassertAlmostEqual)col1col2col1_channelcol2_channelr   s       r   assertApproxz-MiscTest.test_winfo_rgb.<locals>.assertApprox   s/     /2$o*l&&|\&L />r   red)  r   r   zdark slate blue)iHH  i==  i  z#F0F)r   r   r   z#4a3c8c)iJJ  i<<  i  z#dede14143939)i  i  i99  z#123456789a)o   N   7   )r!   	winfo_rgbr#   rc   r   rK   )r   r   r!   rgbs   `   r   test_winfo_rgbzMiscTest.test_winfo_rgb   s    	M yynn 	U]3./1FGV&>?S^%=>S)+CDw//0 1 w//0 10 10 10s   $	C&	C2&C/2C;c                 n   t        j                  | j                        }t        j                  |      }|j	                         }| j                  |t               | j                  | j                  j                  t        |            t        |             | j                  | j                  j                  t        |      d       t        |             | j                  | j                  j                  t        |      |      t        |             | j                  | j                  j                  |      t        |             | j                  | j                  j                  |d       t        |             | j                  | j                  j                  ||      t        |             y )N)	displayof)r   r    r!   r3   winfo_idassertIsInstanceintr#   winfo_pathnamehexr5   )r   r%   wwids       r   test_winfo_pathnamezMiscTest.test_winfo_pathname   s2   TYY'NN1jjlc3'11#c(;SVD11#c(d1KSQRVT11#c(a1H#a&Q11#6A?11#1FAO11#1CSVLr   c                 P   t        j                         }d|_        d|_        d|_        d|_        d|_        d|_        d|_        d|_	        d|_
        d|_        d|_        d|_        d|_        d|_        d|_        d|_        d|_        | j'                  t)        |      d       y )N90  ??r   [ 100z<100 event>)r   Eventserialnumheightkeycodestatetimewidthxycharkeysym
keysym_numtypewidgetx_rooty_rootr   r#   r$   r   es     r   test_event_repr_defaultsz!MiscTest.test_event_repr_defaults   s    MMO	a-0r   c                    t        j                         }d|_        d|_        d|_        d|_        d|_        d|_        d|_        d|_	        d	|_
        d
|_        d|_        d|_        d|_        t        d      |_        t         j"                  j$                  |_        d|_        d|_        d|_        d|_        | j1                  t3        |      d       y )Nr      T   A   i r   i,  
      AzKey-Az.texti  i  z<Configure event send_event=True state=Shift|Control|Button3|0x30000 keysym=Key-A keycode=65 char='A' num=3 delta=-1 focus=True x=10 y=20 width=300 height=200>)r   r   r   r   focusr   r   r   r   r   r   r   r   
send_eventr   ordr   	EventType	Configurer   r   r   r   r   r#   r$   r   s     r   test_event_reprzMiscTest.test_event_repr  s    MMO	3x"",,a<	=r   c                 ~     G d dt         j                        }t        j                  |t        j                         y )Nc                       e Zd ZdZeZdZdZeZdZdZ	dZ
dZdZd	Zd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#d Z$d!Z%d"Z&d#Z'd$Z(d%Z)y&)'6MiscTest.test_eventtype_enum.<locals>.CheckedEventType234567891011121314151617181920212223242526272829303132333435363738N)*r+   r,   r-   KeyPressKey
KeyReleaseButtonPressr3   ButtonReleaseMotionEnterLeaveFocusInFocusOutKeymapExposeGraphicsExposeNoExpose
VisibilityCreateDestroyUnmapMap
MapRequestReparentr   ConfigureRequestGravityResizeRequest	CirculateCirculateRequestPropertySelectionClearSelectionRequest	SelectionColormapClientMessageMappingVirtualEventActivate
Deactivate
MouseWheelr.   r   r   CheckedEventTyper   -  s    HCJK FMFEEGHFF!NHJFGECJHI#G MI#H!N#IH MGLHJJr   r  )enumStrEnum_test_simple_enumr   r   )r   r  s     r   test_eventtype_enumzMiscTest.test_eventtype_enum,  s,    '	t|| '	P 	/1B1BCr   c                 $   dD ]-  }| j                  | j                  j                  |      d       / dD ]-  }| j                  | j                  j                  |      d       / | j                  t        | j                  j                  d       | j                  t        | j                  j                  d       | j                  t
        | j                  j                  d        | j                  t
        | j                  j                  d       y )N)trueyeson1r%   r   rO   TT)falsenooff0r&   nr   FFyear   r.   )assertIsr!   
getbooleanrc   rs   	TypeError)r   vs     r   test_getbooleanzMiscTest.test_getbooleanW  s    <AMM$))..q148 =>AMM$))..q159 ?*dii&:&:EB*dii&:&:B?)TYY%9%94@)TYY%9%92>r   c                 X    g  fd} j                   j                  d|        j                   j                  d        j                  g         j                   j                  d        j                  dg        j	                   j                   j                                y )Nc                       j                  d       j                  j                  dj                  j                         y )NrO   d   )appendr!   rX   quit)logr   s   r   rV   z(MiscTest.test_mainloop.<locals>.callbackc  s(    JJqMIIOOC0r   r'  rO   r   )r!   rX   mainloopr#   
assertTruewinfo_exists)r   rV   r*  s   ` @r   test_mainloopzMiscTest.test_mainloopa  s    	1 			X&		1b!		1qc"		..01r   c                    | j                   j                         }t        j                  | j                         }| j	                  |j                         |       | j                  |d d  t               | j	                  t        |      d       | j                  |d   t               | j                  |d   t               | j                  |d   t               | j                  |d   d       | j                  |d   t               | j                  |j                  t               | j                  |j                  t               | j                  |j                  t               | j                  |j                  d       | j                  |j                  t               | j	                  |d   |j                         | j	                  |d   |j                         | j	                  |d   |j                         | j	                  |d   |j                         | j	                  |d   |j                         | j                  |d	kD         |j                  d
k(  r| j	                  |j                  d       n| j	                  |j                  d       | j                  t!        |      j#                  |j                   d|j                                y )N   r   rO      r   )alphabeta	candidatefinalr2   )r2  r3  r5  )rO   r   r   r5  r0   )r!   info_patchlevelr   r"   r#   r   tupler9   r   r   majorminormicroreleaselevelr   r,  r5   
startswith)r   vir&   s      r   test_info_patchlevelzMiscTest.test_info_patchlevelm  s   YY&&(MM$))$**,b1beU+R!$beS)beS)beS)beDEbeS)bhh,bhh,bhh,boo'ABbii-A)A)A)A0A		*W%??g%RYY*RXXq)B**bhhZq
+CDEr   c                 R   t        j                  | j                        }|j                  dd       |j	                  dd       | j                  |j                         d       |j                  dd       |j	                  dd       | j                  |j                         d       y )Nr   zabc defendu   € u   € abc def)r   Entryr!   insertselection_ranger#   selection_get)r   r   s     r   test_embedded_nullzMiscTest.test_embedded_null  s    tyy)a$q%(--/>a$q%(--/1EFr   N)r+   r,   r-   r   r'   r?   rM   rj   rp   rt   rz   r}   r   r   r   r   r  r$  r.  r>  rE  r.   r   r   r
   r
      sf    9G
F ;8'$R!@'1R	!	!6
M1*=8)DV?
2F:Gr   r
   c                       e Zd Zd Zy)WmTestc                 Z   t        j                  | j                        }| j                  |j	                         d       |j	                  d       d}|j
                  dk(  r t        |      }|dk  sd|cxk  rdk  rn nd}|s | j                  |j	                         d       | j                  | j                  j	                         d       |j	                  d       | j                  |j	                         d       |j
                  d	k(  r|j	                  d
       | j                  |j	                         d       | j                  | j                  j	                         d       |j	                  d
       | j                  |j	                         d       |j                          y )Nr   	hourglassFaqua)         )	   r   )rN  r   r1  Twin32)default)r   r    r!   r#   wm_iconbitmap_windowingsystemr   destroy)r   r%   bug
patchlevels       r   test_wm_iconbitmapzWmTest.test_wm_iconbitmap  sG   TYY'*B/	$'*1-JJ&&J*J*JQ__.<002B7	*B/(OOKO0Q__.<TYY446;OOBO'Q__.3			r   N)r+   r,   r-   rV  r.   r   r   rG  rG    s    r   rG  c                   <    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
y	)
	EventTestc                 6   t        j                  | j                  dd      }|j                          | j                  j	                          | j                  j                          g }|j                  d|j                         |j                          | j                  j                          | j                  t        |      d|       |d   }| j                  |j                  t         j                  j                         | j                  |j                   |       | j#                  |j$                  t&               | j                  |j(                  d       | j                  |j*                  d       | j-                  t/        |d	             | j                  |j0                  d       | j                  |j2                  d       | j                  |j4                  d       | j                  |j6                  d       | j                  |j8                  d       | j                  |j:                  d       | j                  |j<                  d       | j                  |j>                  d       | j                  |j@                  d       | j                  |jB                  d       | j                  |jD                  d       | j                  |jF                  d       | j                  |jH                  d       | j                  tK        |      d
       y )N   r'  r   r   z	<FocusIn>rO   r   r   Fr   z<FocusIn event>)&r   r"   r!   packwait_visibilityrn   bindr(  focus_forcerb   r#   r9   r   r   r   r   r   r   r   r   r   r   r7   hasattrr   r   r   r   r   r   r   r   r   r   r   r   r   r$   r   r&   eventsr   s       r   
test_focuszEventTest.test_focus  s(   MM$))3s;			!!#		""$	{FMM*			Va01Iaffg//778ahh"ahh,&allE*G,-%$'&D)4(t,$'4(d#d#4(4(!$a"34r   c                    t        j                  | j                  dd      }|j                          | j                  j	                          | j                  j                          g }|j                  d|j                         |j                  dd       | j                  t        |      d|       |d	   }| j                  |j                  t         j                  j                         | j                  |j                  |       | j!                  |j"                  t$               | j                  |j&                  d
       | j                  |j(                  d       | j+                  t-        |d             | j                  |j.                  d
       | j                  |j0                  d
       | j                  |j2                  d
       | j                  |j4                  d
       | j                  |j6                  d
       | j                  |j8                  d
       | j                  |j:                  d       | j                  |j<                  d       | j                  |j>                  d	       | j                  |j@                  d	       | j                  |jB                  d
       | j                  |jD                  d
       | j                  |jF                  d	       | j                  tI        |      d       y )NrZ  r'  r[  z<Configure>x   r   )r   borderwidthrO   r   r   Fr   z.<Configure event x=0 y=0 width=150 height=100>)%r   r"   r!   r\  r]  rn   r^  r(  	configurer#   r9   r   r   r   r   r   r   r   r   r   r   r7   r`  r   r   r   r   r   r   r   r   r   r   r   r   r   r$   ra  s       r   test_configurezEventTest.test_configure  s   MM$))3s;			!!#		""$	}fmm,	3B/Va01Iaffg//99:ahh"ahh,&allE*G,-%$'&D)4(t,#&3'a a 4(4(!$a"RSr   c                 f   t        j                  | j                  dd      }|j                          | j                  j	                          | j                  j                          g }|j                  d|j                         |j                          |j                  d       | j                  t        |      d|       |d   }| j                  |j                  t         j                  j                         | j                  |j                   |       | j#                  |j$                  t&               | j                  |j(                  d       | j                  |j*                  d       | j-                  t/        |d	             | j                  |j0                  d
       | j#                  |j2                  t&               | j5                  |j2                  d       | j                  |j6                  d       | j#                  |j8                  t&               | j5                  |j8                  d       | j                  |j:                  d       | j                  |j<                  t?        d             | j                  |j@                  d
       | j                  |jB                  d
       | j                  |jD                  d|jG                         z
         | j                  |jH                  d|jK                         z
         | j                  |jL                  d       | j                  |jN                  d       | j                  |jP                  d       | j                  tS        |      d|j2                  dd|j8                   d|jD                   d|jH                   d	       y )NrZ  r'  r[  z
<KeyPress>z<Alt-z>rO   r   Fr   r   zr   z<KeyPress event state=z#xz keysym=z keycode=z char='z' x=z y=>)*r   r"   r!   r\  r]  rn   r^  r(  r_  event_generater#   r9   r   r   r   r   r   r   r   r   r   r   r7   r`  r   r   r4   r   r   r   r   r   r   r   r   winfo_rootxr   winfo_rootyr   r   r   r$   ra  s       r   test_event_generate_key_pressz'EventTest.test_event_generate_key_press  s   MM$))3s;			!!#		""$	|V]]+		#Va01Iaffg//889ahh"ahh,#allE*G,-%aggs+AGGQ'%aii-AIIq)3's3x0$'4(b1==?23b1==?232&2&!$a$QWWRL 1  !		{,qsse3qsse1F	Gr   c                 P   t        j                  | j                  dd      }|j                          | j                  j	                          | j                  j                          g }|j                  d|j                         |j                  ddd       | j                  t        |      d|       |d   }| j                  |j                  t         j                  j                         | j                  |j                  |       | j!                  |j"                  t$               | j                  |j&                  d       | j                  |j(                  d	       | j                  |j*                  d	       | j                  |j,                  d
       | j                  |j.                  d       | j                  |j0                  d
       | j                  |j2                  d
       | j                  |j4                  d
       | j                  |j6                  d
       | j                  |j8                  d
       | j                  |j:                  d
       | j                  |j<                  d       | j                  |j>                  d       | j                  |j@                  d|jC                         z          | j                  |jD                  d|jG                         z          | j                  |jH                  d       | j                  tK        |      d       y )NrZ  r'  r[  <Enter>2   r   r   rO   r   Fr   z$<Enter event focus=False x=100 y=50>)&r   r"   r!   r\  r]  rn   r^  r(  rl  r#   r9   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rm  r   rn  r   r$   ra  s       r   test_event_generate_enterz#EventTest.test_event_generate_enter  s7   MM$))3s;			!!#		""$	y&--(	cR0Va01Iaffg//556ahh"ahh,#allE*aggu%%!$&D)4(t,$'4(c"b!3#892#78!$a"HIr   c                 n   t        j                  | j                  dd      }|j                          | j                  j	                          | j                  j                          g }|j                  d|j                         |j                          |j                  ddd       | j                  t        |      d|       |d	   }| j                  |j                  t         j                  j                         | j                  |j                   |       | j#                  |j$                  t&               | j                  |j(                  d	       | j                  |j*                  d
       | j-                  t/        |d             | j                  |j0                  d       | j                  |j2                  d	       | j                  |j4                  d       | j                  |j6                  d       | j                  |j8                  d       | j                  |j:                  d       | j                  |j<                  d       | j                  |j>                  d       | j                  |j@                  d       | j                  |jB                  d       | j                  |jD                  |jG                         dz          | j                  |jH                  |jK                         dz          | j                  |jL                  d	       | j                  tO        |      d       y )NrZ  r'  r[  z<ButtonPress>z
<Button-1>rr  rs  rO   r   Fr   r   z$<ButtonPress event num=1 x=100 y=50>)(r   r"   r!   r\  r]  rn   r^  r(  r_  rl  r#   r9   r   r   r   r   r   r   r   r   r   r   r7   r`  r   r   r   r   r   r   r   r   r   r   r   rm  r   rn  r   r$   ra  s       r    test_event_generate_button_pressz*EventTest.test_event_generate_button_press<  sC   MM$))3s;			!!#		""$	.		3Va01Iaffg//;;<ahh"ahh,#allE*G,-"!$&D)4(t,$'4(c"b!1==?S#891==?R#78!$a"HIr   c                 n   t        j                  | j                  dd      }|j                          | j                  j	                          | j                  j                          g }|j                  d|j                         |j                          |j                  ddd       | j                  t        |      d|       |d	   }| j                  |j                  t         j                  j                         | j                  |j                   |       | j#                  |j$                  t&               | j                  |j(                  d	       | j                  |j*                  d
       | j-                  t/        |d             | j                  |j0                  d       | j                  |j2                  d       | j                  |j4                  d       | j                  |j6                  d       | j                  |j8                  d       | j                  |j:                  d       | j                  |j<                  d       | j                  |j>                  d       | j                  |j@                  d       | j                  |jB                  d       | j                  |jD                  |jG                         dz          | j                  |jH                  |jK                         dz          | j                  |jL                  d	       | j                  tO        |      d       y )NrZ  r'  r[  z<Motion>z<B1-Motion>rr  rs  rO   r   Fr   r      z'<Motion event state=Button1 x=100 y=50>)(r   r"   r!   r\  r]  rn   r^  r(  r_  rl  r#   r9   r   r   r   r   r   r   r   r   r   r   r7   r`  r   r   r   r   r   r   r   r   r   r   r   rm  r   rn  r   r$   ra  s       r   test_event_generate_motionz$EventTest.test_event_generate_motion^  sC   MM$))3s;			!!#		""$	z6==)		#4Va01Iaffg//667ahh"ahh,#allE*G,-%%(&D)4(t,$'4(c"b!1==?S#891==?R#78!$a"KLr   c                 p   t        j                  | j                  dd      }|j                          | j                  j	                          | j                  j                          g }|j                  d|j                         |j                          |j                  dddd       | j                  t        |      d|       |d	   }| j                  |j                  t         j                  j                         | j                  |j                   |       | j#                  |j$                  t&               | j                  |j(                  d
       | j+                  t-        |d             | j                  |j.                  d	       | j                  |j0                  d       | j                  |j2                  d	       | j                  |j4                  d       | j                  |j6                  d       | j                  |j8                  d       | j                  |j:                  d       | j                  |j<                  d       | j                  |j>                  d       | j                  |j@                  d       | j                  |jB                  d       | j                  |jD                  |jG                         dz          | j                  |jH                  |jK                         dz          | j                  |jL                  d       | j                  tO        |      d       y )NrZ  r'  r[  z<MouseWheel>rr  )r   r   r   rO   r   Fr   r   z&<MouseWheel event delta=-5 x=100 y=50>)(r   r"   r!   r\  r]  rn   r^  r(  r_  rl  r#   r9   r   r   r   r  r   r   r   r   r   r7   r`  r   r   r   r   r   r   r   r   r   r   r   r   rm  r   rn  r   r$   ra  s       r   test_event_generate_mouse_wheelz)EventTest.test_event_generate_mouse_wheel  sE   MM$))3s;			!!#		""$	~v}}-		3"B?Va01Iaffg//::;ahh"ahh,allE*G,-#%!$&D)4(t,$'4(c"b!1==?S#891==?R#78"%a"JKr   c                 J   t        j                  | j                  dd      }|j                          | j                  j	                          | j                  j                          g }|j                  d|j                         |j                          |j                  dd       | j                  t        |      d|       |d   }| j                  |j                  t         j                  j                         | j                  |j                   |       | j#                  |j$                  t&               | j                  |j(                  d       | j                  |j*                  d	       | j-                  t/        |d
             | j                  |j0                  d       | j                  |j2                  d       | j                  |j4                  d       | j                  |j6                  d       | j                  |j8                  d       | j                  |j:                  d       | j                  |j<                  d       | j                  |j>                  d       | j                  |j@                  d       | j                  |jB                  d       | j                  |jD                  |jG                         dz          | j                  |jH                  d       | j                  |jJ                  d       | j                  tM        |      d       y )NrZ  r'  r[  z<<Spam>>rr  )r   rO   r   Fr   r   r   z<VirtualEvent event x=50 y=0>)'r   r"   r!   r\  r]  rn   r^  r(  r_  rl  r#   r9   r   r   r   r  r   r   r   r   r   r   r7   r`  r   r   r   r   r   r   r   r   r   r   r   rm  r   r   r$   ra  s       r   !test_generate_event_virtual_eventz+EventTest.test_generate_event_virtual_event  s8   MM$))3s;			!!#		""$	z6==)		r*Va01Iaffg//<<=ahh"ahh,#allE*G,-%!$&D)4(t,$'4(b!a 1==?R#782&!$a+	.r   N)r+   r,   r-   rc  rh  ro  rt  rv  ry  r|  r~  r.   r   r   rX  rX    s7     5DTB$GLJB JD MD LD!.r   rX  c                        e Zd Z fdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z xZS )BindTestc                     t         |           | j                  }t        j                  | j                  ddd      | _        | j
                  j                          y )NTestrZ  r'  class_r   r   )supersetUpr!   r   r"   framer\  )r   r!   	__class__s     r   r  zBindTest.setUp  s@    yy]]499V),S:


r   c                 R    | j                  t        | j                  |      |f       y rQ   r#   _info_commandsr!   r   funcids     r   assertCommandExistzBindTest.assertCommandExist  s    		6:VIFr   c                 P    | j                  t        | j                  |      d       y )Nr.   r  r  s     r   assertCommandNotExistzBindTest.assertCommandNotExist  s    		6:B?r   c                 R   d}| j                   }| j                  |j                         d       | j                  |j                  |      d       d }d }|j                  ||      }| j                  |j                         |f       |j                  |      }| j                  ||       | j	                  |       |j                  ||d      }|j                  |      }| j                  ||       | j                  ||       | j	                  |       | j	                  |       y )N<Control-Alt-Key-a>r.   r   c                      y rQ   r.   r   s    r   test1z!BindTest.test_bind.<locals>.test1      dr   c                      y rQ   r.   r  s    r   test2z!BindTest.test_bind.<locals>.test2  r  r   Tadd)r  r#   r^  r   r  )r   eventr&   r  r  r  rh   funcid2s           r   	test_bindzBindTest.test_bind  s    %JJ2&+u%E8,ff%'&&4&0ff%gv&'(r   c                    d}| j                   }| j                  |j                         d       | j                  |j                  |      d       d }d }|j                  ||      }|j                  ||d      }| j                  t        |j
                         |j                  |       | j                  |j                  |      d       | j                  |j                         d       y )N<Control-Alt-Key-b>r.   r   c                      y rQ   r.   r  s    r   r  z#BindTest.test_unbind.<locals>.test1  r  r   c                      y rQ   r.   r  s    r   r  z#BindTest.test_unbind.<locals>.test2  r  r   Tr  )r  r#   r^  rc   r"  unbind)r   r  r&   r  r  r  r  s          r   test_unbindzBindTest.test_unbind  s    %JJ2&+u%&&4&0)QXX.	+2&r   c                 ^  
 | j                   }|j                          |j                          |j                          d}| j	                  |j                         d       | j	                  |j                  |      d       
fd}
fd}
fd}|j                  ||      }|j                  ||d      }|j                  ||d      }g 
|j                  |       | j	                  
g d	       |j                  ||       |j                  |      }	| j                  ||	       | j                  ||	       | j                  ||	       | j	                  |j                         |f       | j                  |       | j                  |       | j                  |       g 
|j                  |       | j	                  
d
dg       |j                  ||       |j                  ||       | j	                  |j                  |      d       | j	                  |j                         d       | j                  |       | j                  |       | j                  |       g 
|j                  |       | j	                  
g        | j                  t        j                  |j                  ||       y )Nz<Control-Alt-Key-c>r.   r   c                 (    j                  d       y )Nar(  r   rb  s    r   r  z$BindTest.test_unbind2.<locals>.test1      fmmC(r   c                 (    j                  d       y )Nr;   r  r  s    r   r  z$BindTest.test_unbind2.<locals>.test2  r  r   c                 (    j                  d       y )Ncr  r  s    r   test3z$BindTest.test_unbind2.<locals>.test3  r  r   Tr  )r  r;   r  r  r  )r  r]  r_  rn   r#   r^  rl  r  r   r   r  r  rc   r   rK   )r   r&   r  r  r  r  r  r  funcid3rh   rb  s             @r   test_unbind2zBindTest.test_unbind2  s+   JJ			%2&+(((u%&&4&0&&4&0	1	 &)ff%gv&E8,""7+'(	#s,		 +2&""6*""7+""7+	$ 	'**AHHeWEr   c                    d}| j                   }| j                  |j                         d       | j                  |j                  |      d       d }d }d }|j                  ||      }|j                  ||d      }|j                  |      }| j                  ||       | j                  ||       | j	                  |       | j	                  |       |j                  ||      }	|j                  |      }| j                  ||       | j                  ||       | j                  |	|       | j	                  |	       y )	N<Control-Alt-Key-d>r.   r   c                      y rQ   r.   r  s    r   r  z(BindTest.test_bind_rebind.<locals>.test1-  r  r   c                      y rQ   r.   r  s    r   r  z(BindTest.test_bind_rebind.<locals>.test2.  r  r   c                      y rQ   r.   r  s    r   r  z(BindTest.test_bind_rebind.<locals>.test3/  r  r   Tr  )r  r#   r^  r   r  r   )
r   r  r&   r  r  r  r  r  rh   r  s
             r   test_bind_rebindzBindTest.test_bind_rebind(  s	   %JJ2&+u%&&4&0gv&ff%'(&&&(&)gv&(r   c                 t   d}| j                   j                  }| j                   j                  }| j                  t        |       | j                   |d      d       | j                   |d|      d       | j                  |d|       d }d } |d||      }| j                   |d      |f        |d|      }| j                  ||       | j                  |        |d||d      } |d|      }| j                  ||       | j                  ||       | j                  |       | j                  |       y )	Nz<Control-Alt-Key-e>r  r.   r   c                      y rQ   r.   r  s    r   r  z'BindTest.test_bind_class.<locals>.test1H  r  r   c                      y rQ   r.   r  s    r   r  z'BindTest.test_bind_class.<locals>.test2I  r  r   Tr  )	r!   
bind_classunbind_classrc   r"  r#   
addCleanupr   r  )	r   r  r  r  r  r  r  rh   r  s	            r   test_bind_classzBindTest.test_bind_class@  s   %YY))
yy--)Z0F+R0FE2B7fe4FE51F+eX6FE*ff%'VUEt<FE*ff%gv&'(r   c                 D   d}| j                   j                  }| j                   j                  }| j                   |d      d       | j                   |d|      d       | j	                  |d|       d }d } |d||      } |d||d      }| j                  t        |       | j                  t        |d        |d|       | j                   |d|      d       | j                   |d      d       | j                  |       | j                  |        |d|       y )	Nz<Control-Alt-Key-f>r  r.   r   c                      y rQ   r.   r  s    r   r  z)BindTest.test_unbind_class.<locals>.test1_  r  r   c                      y rQ   r.   r  s    r   r  z)BindTest.test_unbind_class.<locals>.test2`  r  r   Tr  )r!   r  r  r#   r  rc   r"  r  )r   r  r  r  r  r  r  r  s           r   test_unbind_classzBindTest.test_unbind_classX  s   %YY))
yy--F+R0FE2B7fe4FE51VUEt<)\2)\6:VU#FE2B7F+R0'(VU#r   c                    d}| j                   j                  }| j                   j                  }| j                   |d      d       | j                   |d|      d       | j	                  |d|       d }d }d } |d||      } |d||d	      } |d|      }	| j                  ||	       | j                  ||	       | j                  |       | j                  |        |d||      }
 |d|      }	| j                  ||	       | j                  ||	       | j                  |
|	       | j                  |       | j                  |       | j                  |
       y )
Nz<Control-Alt-Key-g>r  r.   r   c                      y rQ   r.   r  s    r   r  z.BindTest.test_bind_class_rebind.<locals>.test1v  r  r   c                      y rQ   r.   r  s    r   r  z.BindTest.test_bind_class_rebind.<locals>.test2w  r  r   c                      y rQ   r.   r  s    r   r  z.BindTest.test_bind_class_rebind.<locals>.test3x  r  r   Tr  )r!   r  r  r#   r  r   r  r   )r   r  r  r  r  r  r  r  r  rh   r  s              r   test_bind_class_rebindzBindTest.test_bind_class_rebindo  s>   %YY))
yy--F+R0FE2B7fe4FE51VUEt<FE*gv&ff%'(VUE2FE*(&)gv&'((r   c                 6   d}| j                   j                  }| j                   j                  }| j                  | |              | j	                   ||      d       | j                  ||       d }d } |||      }| j                  | |               ||      }| j                  ||       | j                  |        |||d      } ||      }| j                  ||       | j                  ||       | j                  |       | j                  |       y )Nz<Control-Alt-Key-h>r   c                      y rQ   r.   r  s    r   r  z%BindTest.test_bind_all.<locals>.test1  r  r   c                      y rQ   r.   r  s    r   r  z%BindTest.test_bind_all.<locals>.test2  r  r   Tr  r!   bind_all
unbind_allr   r#   r  r   r  )	r   r  r  r  r  r  r  rh   r  s	            r   test_bind_allzBindTest.test_bind_all  s    %99%%YY))

+%"-
E*%'eXZ(%ff%'5%T2%ff%gv&'(r   c                    d}| j                   j                  }| j                   j                  }| j                  | |              | j	                   ||      d       | j                  ||       d }d } |||      } |||d      } ||       | j	                   ||      d       | j                  | |              | j                  |       | j                  |        ||       y )Nz<Control-Alt-Key-i>r   c                      y rQ   r.   r  s    r   r  z'BindTest.test_unbind_all.<locals>.test1  r  r   c                      y rQ   r.   r  s    r   r  z'BindTest.test_unbind_all.<locals>.test2  r  r   Tr  )r!   r  r  r   r#   r  r  )r   r  r  r  r  r  r  r  s           r   test_unbind_allzBindTest.test_unbind_all  s    %99%%YY))

+%"-
E*%'5%T25%"-
+'(5r   c                    d}| j                   j                  }| j                   j                  }| j                  | |              | j	                   ||      d       | j                  ||       d }d }d } |||      } |||d      } ||      }	| j                  ||	       | j                  ||	       | j                  |       | j                  |        |||      }
 ||      }	| j                  ||	       | j                  ||	       | j                  |
|	       | j                  |       | j                  |       | j                  |
       y )Nz<Control-Alt-Key-j>r   c                      y rQ   r.   r  s    r   r  z,BindTest.test_bind_all_rebind.<locals>.test1  r  r   c                      y rQ   r.   r  s    r   r  z,BindTest.test_bind_all_rebind.<locals>.test2  r  r   c                      y rQ   r.   r  s    r   r  z,BindTest.test_bind_all_rebind.<locals>.test3  r  r   Tr  r  )r   r  r  r  r  r  r  r  r  rh   r  s              r   test_bind_all_rebindzBindTest.test_bind_all_rebind  s*   %99%%YY))

+%"-
E*%'5%T2%gv&ff%'(5%(%(&)gv&'((r   c                 p   d}d}|j                          | j                  t        |j                         t	        |t
        j                        r|j                  n|j                  }t	        |t
        j                        rC| j                  t        |j                  |       | j                  t        |j                  ||       | j                   ||      d       | j                   |||      d       d }d }|j                  |||      }| j                   ||      |f        |||      }| j                  ||       | j                  |       |j                  |||d      }	 |||      }| j                  ||       | j                  |	|       | j                  |       | j                  |	       y )	Nselr  r.   r   c                      y rQ   r.   r  s    r   r  z&BindTest._test_tag_bind.<locals>.test1  r  r   c                      y rQ   r.   r  s    r   r  z&BindTest._test_tag_bind.<locals>.test2  r  r   Tr  )r\  rc   r"  tag_bind
isinstancer   Text	_tag_bindr#   r   r  )
r   r   tagr  r  r  r  r  rh   r  s
             r   _test_tag_bindzBindTest._test_tag_bind  s\   %	)QZZ0",Q"=1;;1::a&iS9iS%@#+#u-r2C.#1#u%ff%'**S%D*9#u%ff%gv&'(r   c                    d}d}|j                          t        |t        j                        r|j                  n|j
                  }| j                   ||      d       | j                   |||      d       d }d }|j                  |||      }|j                  |||d      }| j                  t        |j                  |       |j                  ||       | j                   |||      d       | j                   ||      d       y )	Nr  r  r.   r   c                      y rQ   r.   r  s    r   r  z(BindTest._test_tag_unbind.<locals>.test1  r  r   c                      y rQ   r.   r  s    r   r  z(BindTest._test_tag_unbind.<locals>.test2  r  r   Tr  )
r\  r  r   r  r  r  r#   rc   r"  
tag_unbind)	r   r   r  r  r  r  r  r  r  s	            r   _test_tag_unbindzBindTest._test_tag_unbind  s    %	",Q"=1;;1::#+#u-r2C.**S%D*9)Q\\37	S% #u-r2#+r   c                    d}d}|j                          t        |t        j                        r|j                  n|j
                  }| j                   ||      d       | j                   |||      d       d }d }d }|j                  |||      }|j                  |||d	      }	 |||      }
| j                  |	|
       | j                  ||
       | j                  |       | j                  |	       |j                  |||      } |||      }
| j                  ||
       | j                  |	|
       | j                  ||
       | j                  |       y )
Nr  r  r.   r   c                      y rQ   r.   r  s    r   r  z-BindTest._test_tag_bind_rebind.<locals>.test1  r  r   c                      y rQ   r.   r  s    r   r  z-BindTest._test_tag_bind_rebind.<locals>.test2  r  r   c                      y rQ   r.   r  s    r   r  z-BindTest._test_tag_bind_rebind.<locals>.test3	  r  r   Tr  )
r\  r  r   r  r  r  r#   r   r  r   )r   r   r  r  r  r  r  r  r  r  rh   r  s               r   _test_tag_bind_rebindzBindTest._test_tag_bind_rebind   s+   %	",Q"=1;;1::#+#u-r2C.**S%D*9#u%gv&ff%'(**S%/#u%(&)gv&(r   c                 d    t        j                  | j                        }| j                  |       y rQ   )r   Canvasr  r  r   r  s     r   test_canvas_tag_bindzBindTest.test_canvas_tag_bind  s"    NN4::&Ar   c                 d    t        j                  | j                        }| j                  |       y rQ   )r   r  r  r  r  s     r   test_canvas_tag_unbindzBindTest.test_canvas_tag_unbind  s"    NN4::&a r   c                 d    t        j                  | j                        }| j                  |       y rQ   )r   r  r  r  r  s     r   test_canvas_tag_bind_rebindz$BindTest.test_canvas_tag_bind_rebind"  s"    NN4::&""1%r   c                 d    t        j                  | j                        }| j                  |       y rQ   )r   r  r  r  r   r%   s     r   test_text_tag_bindzBindTest.test_text_tag_bind&  s"    LL$Ar   c                 d    t        j                  | j                        }| j                  |       y rQ   )r   r  r  r  r  s     r   test_text_tag_unbindzBindTest.test_text_tag_unbind*  s"    LL$a r   c                 d    t        j                  | j                        }| j                  |       y rQ   )r   r  r  r  r  s     r   test_text_tag_bind_rebindz"BindTest.test_text_tag_bind_rebind.  s"    LL$""1%r   c                 ,   | j                   }| j                  | j                  j                         d       | j                  |j                         t	        |      dddf       |j                  d       | j                  |j                         d       y )N)r0   Tkallr  r0   r  )r  zb c)r  r#   r!   bindtagsr5   )r   r&   s     r   test_bindtagszBindTest.test_bindtags2  sn    JJ++-/ABAU'CD	

< |4r   c                    d}| j                   }t        j                  |      }t        j                  |ddd      }|j	                          |j                          |j                          | j                  |j                  d|       | j                  |j                  d|       | j                  |j                  d|       | j                  |j                  d|       | j                  |j                  |       fd	}|j                  | |d
             |j                  d| |d             |j                  d| |d             |j                  d| |d             |j                  d| |d             |j                  | |d             |j                  | |d             g |j                  |       | j                  d|fd|fd|fd
|fg       g |j                  |       | j                  d|fd|fd
|fg       |j                  d       g |j                  |       | j                  d|fg       y )Nrq  r  rZ  r'  r  r    r  tag2c                       fdS )Nc                 >    j                  | j                  f      S rQ   )r(  r   )r   rb  whats    r   <lambda>z9BindTest.test_bind_events.<locals>.test.<locals>.<lambda>G  s    V]]D!((+;<r   r.   )r  rb  s   `r   testz'BindTest.test_bind_events.<locals>.testF  s	    <<r   r  zframe classztoplevel classr  toplevel)r  tag3)r!   r   r    r"   r\  r]  rn   r  r  r  r  r  r^  rl  r#   r  )r   r  r!   r%   r&   r  rb  s         @r   test_bind_eventszBindTest.test_bind_events9  s   yyT"MM!F#cB	))659)):u=))5%8))659/	= 	eT%[)tM':;
E40@+ABud5k2tF|4	ud7m$	ud:&'	aLAOAJ	"
 	 	Oq!AJ"
 	 	


?#	5!*.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  __classcell__)r  s   @r   r  r    s    G@)*' ,F\)0)0$.)8).*)8)6,$)4!&!&5,/r   r  c                   $    e Zd Zd Zd Zd Zd Zy)DefaultRootTestc                 V   | j                  t        j                  d       | j                  t        j                         t        j
                         }t        j
                         }t        j
                         }| j                  t        j                  |       |j                          | j                  t        j                  |       |j                          | j                  t        j                         |j                          | j                  t        j                         y )NT)r   r   _support_default_rootr^   _default_rootr  rS  )r   r!   root2root3s       r   test_default_rootz!DefaultRootTest.test_default_rootj  s    g33T:'//0zz|



g++T2g++T2'//0'//0r   c                    | j                  t        j                  d       | j                  t        j                         t        j
                         }| j                  t        j                  |       t        j                          | j                  t        j                  d       | j                  t        t        d             t        j                          | j                  t        j                  d       | j                  t        t        d             |j                          | j                  t        j                  d       | j                  t        t        d             t        j
                         }| j                  t        j                  d       | j                  t        t        d             |j                          y )NTFr  )
r   r   r  r^   r  r  NoDefaultRootr7   r`  rS  rL   s     r   test_no_default_rootz$DefaultRootTest.test_no_default_rootx  s"   g33T:'//0zz|g++T2g33U;/:;g33U;/:;g33U;/:;zz|g33U;/:;r   c                    | j                  t        t        j                  d       t        j                         }| j                  t        j                  d      d       | j                  t        t        j                  d       |j                          t        j                          | j                  t        t        j                  d       y )Nr  Tr  )	rc   RuntimeErrorr   r!  r  r   rs   rS  r  rL   s     r   r$  zDefaultRootTest.test_getboolean  s    ,(:(:C@zz|g((-t4*g&8&8%@,(:(:C@r   c                 b   | j                  t        t        j                         t        j                         }|j                  |j                         t        j                          |j                          t        j                          | j                  t        t        j                         y rQ   )	rc   r  r   r+  r  rm   r)  rS  r  rL   s     r   r.  zDefaultRootTest.test_mainloop  sj    ,(8(89zz|		",(8(89r   N)r+   r,   r-   r  r  r$  r.  r.   r   r   r
  r
  h  s    1(A:r   r
  c                 n    | j                   j                  | j                   j                  dd|            S )NrY   commands)r_   ra   r`   )r   patterns     r   r  r    s(    99vyy~~fj'JKKr   __main__rQ   )re   unittestr   r  r  r   test.test_tkinter.supportr   r   r   r   requiresTestCaser
   rG  rX  r  r
  r  r+   mainr.   r   r   <module>r      s        G G    FG~x00 FGR^X.. 8S. 1 1 S.l_/~x00 _/D4:-x/@/@ 4:nL zHMMO r   