B „ f�ã@sòdZddlmZmZmZmZmZmZmZm Z m Z m Z m Z ddl mZmZmZddlmZddlmZGdd„deƒZGdd „d eƒZGd d „d eƒZGd d „d eƒZddd„Zddd„ZedkrîddlmZedddd�ddlmZeeƒdS)zSimple text browser for IDLE é) ÚToplevelÚTextÚTclErrorÚ HORIZONTALÚVERTICALÚNSÚEWÚNSEWÚNONEÚWORDÚSUNKEN)ÚFrameÚ ScrollbarÚButton)Ú showerror)Ú color_configcs0eZdZdZ‡fdd„Zdd„Zdd„Z‡ZS)ÚAutoHideScrollbarzpA scrollbar that is automatically hidden when not needed. Only the grid geometry manager is supported. cs<t|ƒdkst|ƒdkr"| ¡n| ¡tƒ ||¡dS)Nggð?)ÚfloatÚgridZ grid_removeÚsuperÚset)ÚselfÚloÚhi)Ú __class__©ú5/opt/alt/python37/lib64/python3.7/idlelib/textview.pyrs zAutoHideScrollbar.setcKst|jj›d�ƒ‚dS)Nz does not support "pack")rrÚ__name__)rÚkwargsrrrÚpackszAutoHideScrollbar.packcKst|jj›d�ƒ‚dS)Nz does not support "place")rrr)rrrrrÚplaceszAutoHideScrollbar.place)rÚ __module__Ú __qualname__Ú__doc__rrr Ú __classcell__rr)rrr s rcs$eZdZdZef‡fdd„ Z‡ZS)ÚScrollableTextFramezDisplay text with scrollbar(s).c sÆtƒj|f|Žt||d�}|_|jddtd�|jddd�|jddd�t|t d|j d�|_ |j jddt d�|j j |d<|tkr¼t|td|jd�|_|jjddtd�|jj |d <nd |_d S) a‘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ÚcolumnZstickyé)ZweightF)ZorientÚ takefocusÚcommandZyscrollcommandZxscrollcommandN)rÚ__init__rÚtextrr Zgrid_rowconfigureZgrid_columnconfigurerrZyviewZyscrollrrr rZxviewZxscrollr)rZmasterr&rr-)rrrr,"s"    zScrollableTextFrame.__init__)rr!r"r#r r,r$rr)rrr%sr%cs,eZdZdZd‡fdd„ Zd dd„Z‡ZS) Ú ViewFramez#Display TextFrame and Close button.Úwordcs²tƒ |¡||_| d|j¡| d|j¡t|tdd�|_|jj}|_|  d|¡|j |ddd�t |ƒ|  ¡t |d |jd d �|_}|jjd d dd�|jdd�dS)aCreate 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. zzi¼)ZreliefZheightz1.0rZdisabled)r&ZhighlightthicknessÚstateÚCloseF)r-r+r*ÚtopTÚboth)ÚsideÚexpandÚfillZbottom)r4N)rr,ÚparentZbindÚokr%r Z textframer-ÚinsertZ configurerZ focus_setrÚ button_okr)rr7Úcontentsr&r-r:)rrrr,Js  zViewFrame.__init__NcCs|j ¡dS)zDismiss text viewer dialog.N)r7Údestroy)rÚeventrrrr8dsz ViewFrame.ok)r/)N)rr!r"r#r,r8r$rr)rrr.Hsr.cs8eZdZdZdefdddœ‡fdd„ Zd dd „Z‡ZS) Ú ViewWindowz%A simple text viewer dialog for IDLE.TF)Ú_htestÚ_utestc sÊtƒ |¡d|d<| ¡d}| ¡|s.dnd} | d|›d| ›�¡| |¡t|||d�|_| d|j ¡t |d |j d d �|_ } |jj d d dd�||_ |j rÆ| |¡| ¡|sÆ| ¡dS)aShow 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. éZ borderwidthé édz =750x500+ú+)r&ZWM_DELETE_WINDOWr1F)r-r+r*r2Tr3)r4r5r6N)rr,Z winfo_rootxZ winfo_rootyZgeometryÚtitler.Z viewframeZprotocolr8rr:rÚis_modalZ transientZgrab_setZ wait_window) rr7rEr;Úmodalr&r?r@ÚxÚyr:)rrrr,ls"    zViewWindow.__init__NcCs|jr| ¡| ¡dS)zDismiss text viewer dialog.N)rFZ grab_releaser<)rr=rrrr8�sz ViewWindow.ok)N)rr!r"r#r r,r8r$rr)rrr>is"r>Tr/FcCst||||||d�S)a�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&r@)r>)r7rEr;rGr&r@rrrÚ view_text–s rJc Csœy&t|d|d��}| ¡}WdQRXWn\tk rPtdd|›d�|d�YnHtk r‚} ztdt| ƒ|d�Wdd} ~ XYnXt||||||d �SdS) z™Create text viewer for text in filename. Return error message if file cannot be read. Otherwise calls view_text with contents of the file. Úr)ÚencodingNzFile Load ErrorzUnable to load file z .)rEÚmessager7zUnicode Decode Error)r&r@)ÚopenÚreadÚOSErrorrÚUnicodeDecodeErrorÚstrrJ) r7rEÚfilenamerLrGr&r@Úfiler;ÚerrrrrÚ view_file¤s   rVÚ__main__)Úmainzidlelib.idle_test.test_textviewé)Ú verbosityÚexit)ÚrunN)Tr/F)Tr/F) r#Ztkinterrrrrrrrr r r r Z tkinter.ttkr rrZtkinter.messageboxrZidlelib.colorizerrrr%r.r>rJrVrZunittestrXZidlelib.idle_test.htestr\rrrrÚs 4  )!-