o =?h@sdZddlmZmZmZmZmZmZmZm Z m Z m Z m Z ddl mZmZmZddlmZddlmZGdddeZGdd d eZGd d d eZGd d d eZdddZ  dddZedkr{ddlmZeddddddlmZeedSdS)zSimple text browser for IDLE ) ToplevelTextTclError HORIZONTALVERTICALNSEWNSEWNONEWORDSUNKEN)Frame ScrollbarButton) showerror) color_configcs0eZdZdZfddZddZddZZS)AutoHideScrollbarzpA scrollbar that is automatically hidden when not needed. Only the grid geometry manager is supported. cs<t|dks t|dkr|n|t||dS)Ngg?)floatgridZ grid_removesuperset)selflohi __class__7/opt/alt/python310/lib64/python3.10/idlelib/textview.pyrs zAutoHideScrollbar.setcKt|jjd)Nz does not support "pack"rr__name__rkwargsrrrpackzAutoHideScrollbar.packcKr)Nz does not support "place"rr!rrrplacer$zAutoHideScrollbar.place)r __module__ __qualname____doc__rr#r% __classcell__rrrrr s  rcs$eZdZdZeffdd ZZS)ScrollableTextFramezDisplay text with scrollbar(s).c stj|fi|t||d}|_|jddtd|jddd|jdddt|t d|j d|_ |j jddt d|j j |d<|tkrat|td|jd|_|jjddtd|jj |d <d Sd |_d S) aCreate 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)rowcolumnZsticky)ZweightF)Zorient takefocuscommandZyscrollcommandZxscrollcommandN)r__init__rtextrr Zgrid_rowconfigureZgrid_columnconfigurerrZyviewZyscrollrrr rZxviewZxscrollr)rZmasterr,r"r3rrrr2"s&   zScrollableTextFrame.__init__)r r&r'r(r r2r)rrrrr*sr*cs,eZdZdZdfdd Zd ddZZS) ViewFramez#Display TextFrame and Close button.wordcst|||_|d|j|d|jt|tdd|_|jj}|_| d||j |dddt || t |d |jd d |_}|jjd d dd|jdddS)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,ZhighlightthicknessstateCloseFr3r1r0topTbothsideexpandZfillZbottom)r<N)rr2parentZbindokr*r Z textframer3insertZ configurerZ focus_setr button_okr#)rr>contentsr,r3rArrrr2Js    zViewFrame.__init__NcCs|jdSzDismiss text viewer dialog.N)r>destroyrZeventrrrr?dsz ViewFrame.ok)r5N)r r&r'r(r2r?r)rrrrr4Hsr4cs8eZdZdZdefdddfdd Zd dd ZZS) ViewWindowz%A simple text viewer dialog for IDLE.TF)_htest_utestc st|d|d<|d}||sdnd} |d|d| ||t|||d|_|d|j t |d |j d d |_ } |jj d d dd||_ |j re||||sg|dSdSdS)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_WINDOWr7Fr8r9Tr:r;N)rr2Z winfo_rootxZ winfo_rootyZgeometrytitler4Z viewframeZprotocolr?rrAr#is_modalZ transientZgrab_setZ wait_window) rr>rNrBmodalr,rHrIxyrArrrr2ls(      zViewWindow.__init__NcCs|jr||dSrC)rOZ grab_releaserDrErrrr?s z ViewWindow.okrF)r r&r'r(r r2r?r)rrrrrGis #rGTr5FcCst||||||dS)aCreate 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,rI)rG)r>rNrBrPr,rIrrr view_texts rTc Cszt|d|d }|}Wdn1swYWn0ty2tdd|d|dYdStyM} ztdt| |dWYd} ~ dSd} ~ wwt||||||d S) zCreate 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 .)rNmessager>zUnicode Decode ErrorrS)openreadOSErrorrUnicodeDecodeErrorstrrT) r>rNfilenamerVrPr,rIfilerBerrrrr view_files,     r`__main__)mainzidlelib.idle_test.test_textview) verbosityexit)runN)Tr5F) r(Ztkinterrrrrrrrr r r r Z tkinter.ttkr rrZtkinter.messageboxrZidlelib.colorizerrrr*r4rGrTr`r ZunittestrbZidlelib.idle_test.htestrfrrrrs&4  )! -