f _c@sddlmZmZmZmZmZmZmZmZm Z m Z m Z ddl m Z mZmZddlmZddlmZGdddeZGddde ZGd d d e ZGd d d eZdddZdddZedkrddlmZeddddddlmZeedS)) ToplevelTextTclError HORIZONTALVERTICALNSEWNSEWNONEWORDSUNKEN)Frame ScrollbarButton) showerror) color_configcs,eZdZfddZddZddZZS)AutoHideScrollbarcs<t|dkst|dkr"|n|t||dS)Ngg?)ZfloatgridZ grid_removesuperset)selfZloZhi __class__)/usr/lib64/python3.10/idlelib/textview.pyrs zAutoHideScrollbar.setcKt|jjddS)Nz does not support "pack"rr__name__rkwargsrrrpackzAutoHideScrollbar.packcKr)Nz does not support "place"rrrrrplacer zAutoHideScrollbar.place)r __module__ __qualname__rrr! __classcell__rrrrr s rcs eZdZeffdd ZZS)ScrollableTextFramec stj|fi|t||d}|_|jddtd|jddd|jdddt|t d|j d|_ |j jddt d|j j |d<|tkrt|td|jd|_|jjddtd|jj |d <nd|_dS) Nwrapr)ZrowZcolumnZstickyi)ZweightF)Zorient takefocuscommandZyscrollcommandZxscrollcommand)r__init__rtextrrZgrid_rowconfigureZgrid_columnconfigurerrZyviewZyscrollrrr rZxviewZxscrollr)rZmasterr'rr+rrrr*"s&  zScrollableTextFrame.__init__)rr"r#r r*r$rrrrr%sr%cs(eZdZdfdd ZdddZZS) ViewFramewordcst|||_|d|j|d|jt|tdd|_|jj}|_| d||j |dddt || t |d |jd d |_}|jjd d dd|jdddS)Nzzi)ZreliefZheightz1.0rZdisabled)r'ZhighlightthicknessZstateCloseFr+r)r(topTbothsideZexpandZfillZbottom)r3)rr*parentZbindokr%r Z textframer+ZinsertZ configurerZ focus_setr button_okr)rr4contentsr'r+r6rrrr*Js   zViewFrame.__init__NcCs|jdSN)r4destroyrZeventrrrr5dsz ViewFrame.ok)r-r8)rr"r#r*r5r$rrrrr,Hsr,cs4eZdZdefdddfdd Zd ddZZS) ViewWindowTF)_htest_utestc st|d|d<|d}||s.dnd} |d|d| ||t|||d|_|d|j t |d |j d d |_ } |jj d d dd||_ |j r||||s|dS)NiZ borderwidthi idz =750x500+z+r&ZWM_DELETE_WINDOWr.Fr/r0Tr1r2)rr*Z winfo_rootxZ winfo_rootyZgeometrytitler,Z viewframeZprotocolr5rr6ris_modalZ transientZgrab_setZ wait_window) rr4r>r7modalr'r<r=ZxZyr6rrrr*ls$     zViewWindow.__init__NcCs|jr||dSr8)r?Z grab_releaser9r:rrrr5sz ViewWindow.okr8)rr"r#r r*r5r$rrrrr;is#r;Tr-FcCst||||||dS)Nr'r=)r;)r4r>r7r@r'r=rrr view_texts rBc Csz:t|d|d}|}Wdn1s.0YWn\tybtdd|d|dYnJty} ztdt| |dWYd} ~ nd} ~ 00t||||||dSdS) NZr)encodingzFile Load ErrorzUnable to load file z .)r>Zmessager4zUnicode Decode ErrorrA)ZopenZreadZOSErrorrZUnicodeDecodeErrorZstrrB) r4r>ZfilenamerCr@r'r=Zfiler7Zerrrrr view_files"*    rDZ__main__)mainzidlelib.idle_test.test_textviewi)Z verbosityZexit)runNTr-FrG)Ztkinterrrrrrrrrr r r Z tkinter.ttkr r rZtkinter.messageboxrZidlelib.colorizerrrr%r,r;rBrDrZunittestrEZidlelib.idle_test.htestrFrrrrZs4  )!-