Yf@sdZddlZddlZddlTddljZddljZ Gddde Z e dkrddl Z e jddd d d dd lmZee dS) zKDialog to specify or edit the parameters for a user configured help source.N)*c@sseZdZdddddZddZddZd d Zd d Zd ddZd ddZ d S)GetHelpSourceDialogFcCsOtj|||jdd|jdtdt|j||j||j|jd|j ||_ d|_ |j |j j||jj||j|j|jd|j|jd|jd|j|s|jd|jdnd f|j|jd |j|jdS) a2Get menu entry and url/ local file location for Additional Help User selects a name for the Help resource and provides a web url or a local file as its source. The user can enter a url or browse for the file. _htest - bool, change box location when running htest borderwidthZheightwidthZWM_DELETE_WINDOWNz+%d+%dz)Toplevel__init__Z configureZ resizableZFALSEtitleZ transientZgrab_setZprotocolcancelparentresultcreate_widgetsmenusetpathZwithdrawZupdate_idletasksZgeometryZ winfo_rootxZ winfo_widthZwinfo_reqwidthZ winfo_rootyZ winfo_heightZwinfo_reqheightZ deiconifyZbindokZ wait_window)selfrr ZmenuItemZfilePathZ_htestrA/opt/alt/python35/lib64/python3.5/idlelib/configHelpSourceEdit.pyr s.           0 zGetHelpSourceDialog.__init__c Csmt||_t||_t||_t|dddt|_|jjdtdt dt t |jdt dt d d }t|jd |jd d |_|jjt |jdt dt d d}t|jd |jd d|_|jj|jdt dddd|jjdt dddd|jdt dddd|jjdt ddddt|jd dd dd|j}|jddt|}|jdtdtt|d dd ddtd|j|_|jjddddddddt|d dd dd|j|_|jjdddddddddS)NrrZreliefZsideexpandZfillZanchorZjustifytextz Menu Item:Z textvariablerz,Help File Path: Enter URL or browse for file(ZpadxrZpadyZBrowseZcommandZOKdefaultrowrcolumnZCancel)Z StringVarrrZfontSizeZFrameZGROOVEZ frameMainZpackZTOPZTRUEZBOTHZLabelWZLEFTZEntry entryMenu focus_set entryPathZButton browse_fileZBOTTOMXZACTIVErZbuttonOkZgridr Z buttonCancel)rZ labelMenuZ labelPathZ browseButtonZ frameButtonsrrrr/s<        %z"GetHelpSourceDialog.create_widgetscCsdddddg}|jj}|rEtjj|\}}npd}tjdd d krtjjtjjtjd}tjj |stj }n tj }t j d|d|}|j d|d|}|r|jj|dS)N HTML Files *.htm *.htmlTEXT PDF Files*.pdfWindows Help Files*.chm Text Files*.txt All FilesrrwinZDocr filetypesZ initialdirZ initialfile)r(r)r*)r+r,r*)r-r.)r/r0r*)r1r)rgetossplitsysplatformjoindirname executableisdirgetcwd tkFileDialogZOpenZshowr)rr3rdirbaseZ opendialogfilerrrr&Os$ $ zGetHelpSourceDialog.browse_filecCsd}|jj}|j|sWtjddddd||jjd}nAt|dkrtjdddd d||jjd}|S) z3Simple validity check for a sensible menu item nameTr zMenu Item ErrormessagezNo menu item specifiedrFrz(Menu item too long: Limit 30 characters.)rr4strip tkMessageBox showerrorr#r$len)rmenu_okrrrrrGfs     zGetHelpSourceDialog.menu_okcCsd}|jj}|j|sWtjddddd||jjd}ny|jdring|d d d kr|d d }tjj |stjdddd d||jjd}|S)z(Simple validity check for menu file pathTr zFile Path ErrorrBzNo help file path specified.rFwww.httpNrzfile:zHelp file path does not exist.)rHrI) rr4rCrDrEr%r$ startswithr5exists)rpath_okrrrrrLzs(    zGetHelpSourceDialog.path_okNcCs|jr|jr|jjj|jjjf|_tjdkr|jd}|j drsn#t |j|_d||jd<|j dS) Ndarwinr!wwwfile:http:https:zfile://)rNrOrPrQ) rGrLrr4rCrrr7r8rJlistdestroy)reventrrrrrs zGetHelpSourceDialog.okcCsd|_|jdS)N)rrS)rrTrrrr s zGetHelpSourceDialog.cancel) __name__ __module__ __qualname__r rr&rGrLrr rrrrr s $   r__main__z"idlelib.idle_test.test_config_help verbosityrexitF)run)__doc__r5r7ZtkinterZtkinter.messageboxZ messageboxrDZtkinter.filedialogZ filedialogr>r rrUZunittestmainZidlelib.idle_test.htestr[rrrrs