
   y<x                      S r SSKJrJrJrJrJrJrJrJ	r	J
r
JrJr  SSKJrJrJr  SSKJr  SSKJr   " S S\5      r " S S	\5      r " S
 S\5      r " S S\5      rSS jr  SS jr\S:X  a  SSKJr  \" SSSS9  SSKJr  \" \5        gg)zSimple text browser for IDLE

    )ToplevelTextTclError
HORIZONTALVERTICALNSEWNSEWNONEWORDSUNKEN)Frame	ScrollbarButton)	showerror)color_configc                   8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )AutoHideScrollbar   zhA scrollbar that is automatically hidden when not needed.

Only the grid geometry manager is supported.
c                    > [        U5      S:  d  [        U5      S:  a  U R                  5         OU R                  5         [        TU ]  X5        g )Ng        g      ?)floatgridgrid_removesuperset)selflohi	__class__s      '/usr/lib/python3.13/idlelib/textview.pyr   AutoHideScrollbar.set   s9    9s?eBi#oIIKB    c                 F    [        U R                  R                   S35      e)Nz does not support "pack"r   r   __name__r   kwargss     r    packAutoHideScrollbar.pack   s     $..1122JKLLr"   c                 F    [        U R                  R                   S35      e)Nz does not support "place"r$   r&   s     r    placeAutoHideScrollbar.place   s     $..1122KLMMr"    )
r%   
__module____qualname____firstlineno____doc__r   r(   r+   __static_attributes____classcell__r   s   @r    r   r      s    MN Nr"   r   c                   2   ^  \ rS rSrSr\4U 4S jjrSrU =r$ )ScrollableTextFrame   zDisplay text with scrollbar(s).c                 0  > [         TU ]  " U40 UD6  [        XS9=o@l        UR	                  SS[
        S9  U R                  SSS9  U R                  SSS9  [        U [        SUR                  S9U l        U R                  R	                  SS[        S9  U R                  R                  US'   U[        :X  aX  [        U [        SUR                   S9U l        U R"                  R	                  SS[$        S9  U R"                  R                  US	'   g
S
U l        g
)aY  Create a frame for Textview.

master - master widget for this frame
wrap - type of text wrapping to use ('word', 'char' or 'none')

All parameters except for 'wrap' are passed to Frame.__init__().

The Text widget is accessible via the 'text' attribute.

Note: Changing the wrapping mode of the text widget after
instantiation is not supported.
wrapr   )rowcolumnsticky   )weightF)orient	takefocuscommandyscrollcommandxscrollcommandN)r   __init__r   textr   r
   grid_rowconfiguregrid_columnconfigurer   r   yviewyscrollr   r   r   r   xviewxscrollr	   )r   masterr:   r'   rF   r   s        r    rE   ScrollableTextFrame.__init__"   s    	*6*00y		a$	/q+!!!A!. )h3815= 	a"5!%!1!1 4<,T*7<59ZZADL LL!Ab9%)\\%5%5D!"DLr"   )rF   rL   rJ   )	r%   r.   r/   r0   r1   r   rE   r2   r3   r4   s   @r    r6   r6      s    )$( #  # r"   r6   c                   :   ^  \ rS rSrSrSU 4S jjrSS jrSrU =r$ )	ViewFrameH   z#Display TextFrame and Close button.c                 
  > [         TU ]  U5        Xl        U R                  SU R                  5        U R                  SU R                  5        [        U [        SS9U l        U R                  R                  =o@l        UR                  SU5        UR                  USSS9  [        U5        UR                  5         [        U S	U R                  S
S9=U l        nU R                  R                  SSSS9  UR                  SS9  g)zCreate a frame for viewing text with a "Close" button.

parent - parent widget for this frame
contents - text to display
wrap - type of text wrapping to use ('word', 'char' or 'none')

The Text widget is accessible via the 'text' attribute.
z<Return>z<Escape>i  )reliefheightz1.0r   disabled)r:   highlightthicknessstateCloseFrF   rB   rA   topTbothsideexpandfillbottom)r]   N)r   rE   parentbindokr6   r   	textframerF   insert	configurer   	focus_setr   	button_okr(   )r   ra   contentsr:   rF   rh   r   s         r    rE   ViewFrame.__init__J   s     	 		*dgg&		*dgg&,T&M>>...yE8$DQjIT%+7DGGu&F 	Ft&AH%r"   c                 8    U R                   R                  5         gzDismiss text viewer dialog.N)ra   destroyr   events     r    rc   ViewFrame.okd   s    r"   )rh   ra   rF   rd   )wordN)	r%   r.   r/   r0   r1   rE   rc   r2   r3   r4   s   @r    rP   rP   H   s    )&4 r"   rP   c                   H   ^  \ rS rSrSrS\4SSS.U 4S jjjrS	S jrSrU =r	$ )

ViewWindowi   z%A simple text viewer dialog for IDLE.TF)_htest_utestc                D  > [         TU ]  U5        SU S'   UR                  5       S-   nUR                  5       U(       d  SOS-   n	U R	                  SU SU	 35        U R                  U5        [        XUS9U l        U R                  SU R                  5        [        U S	U R                  S
S9=U l        n
U R                  R                  SSSS9  X@l        U R                  (       a:  U R                  U5        U R                  5         U(       d  U R!                  5         ggg)a  Show the given text in a scrollable window with a 'close' button.

If modal is left True, users cannot interact with other windows
until the textview window is closed.

parent - parent of this dialog
title - string which is title of popup dialog
contents - text to display in dialog
wrap - type of text wrapping to use ('word', 'char' or 'none')
_htest - bool; change box location when running htest.
_utest - bool; don't wait_window when running unittest.
   borderwidth
   d   z	=750x500++r9   WM_DELETE_WINDOWrX   FrY   rZ   Tr[   r\   N)r   rE   winfo_rootxwinfo_rootygeometrytitlerP   	viewframeprotocolrc   r   rh   r(   is_modal	transientgrab_setwait_window)r   ra   r   ri   modalr:   rv   rw   xyrh   r   s              r    rE   ViewWindow.__init__l   s    	 ] 2% fB#>	!AaS)*

5"4=($''2%+Dw48GGu&N 	Nt&A==NN6"MMO  "  r"   c                 f    U R                   (       a  U R                  5         U R                  5         grl   )r   grab_releaserm   rn   s     r    rc   ViewWindow.ok   s    ==r"   )rh   r   r   rr   )
r%   r.   r/   r0   r1   r   rE   rc   r2   r3   r4   s   @r    rt   rt   i   s*    +6: !# !# !#F r"   rt   Fc           	          [        XX#XES9$ )ao  Create text viewer for given text.

parent - parent of this dialog
title - string which is the title of popup dialog
contents - text to display in this dialog
wrap - type of text wrapping to use ('word', 'char' or 'none')
modal - controls if users can interact with other windows while this
        dialog is displayed
_utest - bool; controls wait_window on unittest
r:   rw   )rt   )ra   r   ri   r   r:   rw   s         r    	view_textr      s     fX4OOr"   c           	          [        X#S9 nUR                  5       nSSS5        [        XWXEUS9$ ! , (       d  f       N= f! [         a    [	        SSU< S3U S9   g[
         a  n	[	        S[        U	5      U S9   Sn	A	gSn	A	ff = f)	zCreate text viewer for text in filename.

Return error message if file cannot be read.  Otherwise calls view_text
with contents of the file.
)encodingNr   zFile Load ErrorzUnable to load file z .)r   messagera   zUnicode Decode Error)openreadr   OSErrorr   UnicodeDecodeErrorstr)
ra   r   filenamer   r   r:   rw   fileri   errs
             r    	view_filer      s    ((.$yy{H / % &( 	( /. !)0B?	!   !.c(	! !s/   	A 0A 
>A B	B&A??B__main__)mainzidlelib.idle_test.test_textview   )	verbosityexit)runN)Trq   F) r1   tkinterr   r   r   r   r   r   r	   r
   r   r   r   tkinter.ttkr   r   r   tkinter.messageboxr   idlelib.colorizerr   r   r6   rP   rt   r   r   r%   unittestr   idlelib.idle_test.htestr   r-   r"   r    <module>r      s   ; ; ; ; 0 0 ( *N	 N&& % & R B* *ZP CI0 z	*aeD+
O r"   