î Óê[ã@s‰dZddlZddlZddlTddljZddljZ Gdd„de ƒZ e dkr…ddl mZee ƒndS)zKDialog to specify or edit the parameters for a user configured help source.éN)Ú*c@sseZdZddddd„Zdd„Zdd„Zd d „Zd d „Zd dd„Zd dd„Z d S)ÚGetHelpSourceDialogÚFcCsOtj||ƒ|jddƒ|jdtdtƒ|j|ƒ|j|ƒ|jƒ|jd|j ƒ||_ d|_ |j ƒ|j j|ƒ|jj|ƒ|jƒ|jƒ|jd|jƒ|jƒd|jƒd|jƒ|s|jƒd|jƒdnd fƒ|jƒ|jd |jƒ|jƒdS) 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 Ú borderwidthéZheightÚwidthZWM_DELETE_WINDOWNz+%d+%déé–z)ÚToplevelÚ__init__Z configureZ resizableZFALSEÚtitleZ transientZgrab_setZprotocolÚCancelÚparentÚresultÚ CreateWidgetsÚmenuÚsetÚpathZwithdrawZupdate_idletasksZgeometryZ winfo_rootxZ winfo_widthZwinfo_reqwidthZ winfo_rootyZ winfo_heightZwinfo_reqheightZ deiconifyZbindÚOkZ wait_window)Úselfrr ZmenuItemZfilePathZ_htest©rú2/usr/lib/python3.4/idlelib/configHelpSourceEdit.pyr s.           0 zGetHelpSourceDialog.__init__c Csmt|ƒ|_t|ƒ|_t|ƒ|_t|dddtƒ|_|jjdtdt dt ƒt |jdt dt d d ƒ}t|jd |jd d ƒ|_|jjƒt |jdt dt d dƒ}t|jd |jd dƒ|_|jjƒ|jdt ddddƒ|jjdt ddddƒ|jdt ddddƒ|jjdt ddddƒt|jd dd dd|jƒ}|jddƒt|ƒ}|jdtdtƒt|d dd ddtd|jƒ|_|jjddddddddƒt|d dd dd|jƒ|_|jjddddddddƒdS)NrrZreliefZsideÚexpandZfillZanchorZjustifyÚtextz Menu Item:Z textvariableréz,Help File Path: Enter URL or browse for fileé(ZpadxrZpadyéZBrowseéZcommandZOKÚdefaultÚrowrÚcolumnr é)Z StringVarrrZfontSizeZFrameZGROOVEZ frameMainZpackZTOPZTRUEZBOTHZLabelÚWZLEFTZEntryÚ entryMenuÚ focus_setÚ entryPathZButtonÚ browseFileZBOTTOMÚXZACTIVErZbuttonOkZgridr Z buttonCancel)rZ labelMenuZ labelPathZ browseButtonZ frameButtonsrrrr/s<        %z!GetHelpSourceDialog.CreateWidgetscCsdddddg}|jjƒ}|rEtjj|ƒ\}}nsd}tjdd …d kr¬tjjtjjtjƒdƒ}tjj |ƒs¸tj ƒ}q¸n tj ƒ}t j d|d|ƒ}|j d|d|ƒ}|r|jj|ƒndS)Nú HTML Filesú *.htm *.htmlÚTEXTú PDF Filesú*.pdfúWindows Help Filesú*.chmú Text Filesú*.txtú All FilesrrÚwinZDocrÚ filetypesZ initialdirZ initialfile)r(r)r*)r+r,r*)r-r.)r/r0r*)r1r)rÚgetÚosÚsplitÚsysÚplatformÚjoinÚdirnameÚ executableÚisdirÚgetcwdÚ tkFileDialogZOpenZshowr)rr3rÚdirÚbaseZ opendialogÚfilerrrr&Os$ $ zGetHelpSourceDialog.browseFilecCsŸd}|jjƒ}|jƒ|sWtjddddd|ƒ|jjƒd}nDt|ƒdkr›tjdddd d|ƒ|jjƒd}n|S) z3Simple validity check for a sensible menu item nameTr zMenu Item ErrorÚmessagezNo menu item specifiedrFrz(Menu item too long: Limit 30 characters.)rr4ÚstripÚ tkMessageBoxÚ showerrorr#r$Úlen)rZmenuOkrrrrÚMenuOkfs      zGetHelpSourceDialog.MenuOkcCsÚd}|jjƒ}|jƒ|sWtjddddd|ƒ|jjƒd}n|jdƒrinm|d d …d kr’|d d …}ntjj |ƒsÖtjdddd d|ƒ|jjƒd}n|S)z(Simple validity check for menu file pathTr zFile Path ErrorrBzNo help file path specified.rFúwww.ÚhttpNrzfile:zHelp file path does not exist.)rHrI) rr4rCrDrEr%r$Ú startswithr5Úexists)rZpathOkrrrrÚPathOkzs(     zGetHelpSourceDialog.PathOkNcCsª|jƒr¦|jƒr¦|jjƒjƒ|jjƒjƒf|_tjdkr™|jd}|j dƒrsq™t |jƒ|_d||jdr rrTZidlelib.idle_test.htestrXrrrrÚs   š