[ @sdZddlTddljZGdddeZdddZddd d Ze d krddl Z e j d d dddddl m Z e endS)zSimple text browser for IDLE )*Nc@sCeZdZdZddddZddZdd d ZdS) TextViewerz*A simple text viewer dialog for IDLE TFcCs)tj|||jdd|jddd|jd|j|sQdndfd|_d |_|j|j ||j d |j ||_ |j j|jd |j |jd |j |j jd ||j jdt|r%|j||j|jndS)aHShow the given text in a scrollable window with a 'close' button If modal option set to False, user can interact with other windows, otherwise they will be unable to interact with other windows until the textview window is closed. _htest - bool; change box location when running htest. Z borderwidthz =%dx%d+%d+%diqi dz#ffffffz#000000ZWM_DELETE_WINDOWzzgstateN)Toplevel__init__Z configureZgeometryZ winfo_rootxZ winfo_rootybgfg CreateWidgetstitleZprotocolOkparenttextViewZ focus_setZbindinsertconfigZDISABLEDZ transientZgrab_setZ wait_window)selfrr textmodalZ_htestr&/usr/lib/python3.4/idlelib/textView.pyr s(  !        zTextViewer.__init__c CsCt|dtdd}t|}t|ddd|jdt|_t|dtdtd d |_t |d t d d d |j d |j |_ |jjd|j j|j jd|jj|jj|jjdtdt|j jdtdtdt|jdtdt|jdtdtdtdS)NZreliefZheightirZCloseZcommandZ takefocusZorientZhighlightthicknessrZwrapr r ZyscrollcommandZsideZfillexpand)ZFrameZSUNKENZButtonrZFALSEZbuttonOkZ ScrollbarZVERTICALZ scrollbarViewZTextZWORDr r rrZyviewsetZpackZRIGHTYZLEFTZTRUEZBOTHZBOTTOMXZTOP)rZ frameTextZ frameButtonsrrrr /s  zTextViewer.CreateWidgetsNcCs|jdS)N)Zdestroy)rZeventrrrr@sz TextViewer.Ok)__name__ __module__ __qualname____doc__r r rrrrrrs # rTcCst||||S)N)r)rr rrrrr view_textDsr cCszy.t|dd|}|j}WdQXWn2tk rbtjdddd|d|YnXt||||SdS)Nrencodingr zFile Load ErrormessagezUnable to load file %r .r)openreadIOError tkMessageBoxZ showerrorr )rr filenamer"rfilecontentsrrr view_fileGs   r+__main__zidlelib.idle_test.test_textview verbosityexitF)run)rZtkinterZtkinter.messageboxZ messageboxr'rrr r+rZunittestmainZidlelib.idle_test.htestr0rrrrs <