ó
|Nc           @   s¡   d  Z  d d l Z d d l Z d d l Td d l Z d d l Z d e f d „  ƒ  YZ e d k r e	 ƒ  Z
 d „  Z e e
 d d	 d
 e ƒj ƒ  e
 j ƒ  n  d S(   sK   Dialog to specify or edit the parameters for a user configured help source.iÿÿÿÿN(   t   *t   GetHelpSourceDialogc           B   sS   e  Z d  d  d „ Z d „  Z d „  Z d „  Z d „  Z d d „ Z d d „ Z	 RS(	   t    c         C   sC  t  j |  | ƒ |  j d d ƒ |  j d t d t ƒ |  j | ƒ |  j | ƒ |  j ƒ  |  j d |  j	 ƒ | |  _
 d	 |  _ |  j ƒ  |  j j | ƒ |  j j | ƒ |  j ƒ  |  j ƒ  |  j d | j ƒ  | j ƒ  d |  j ƒ  d | j ƒ  | j ƒ  d |  j ƒ  d f ƒ |  j ƒ  |  j d |  j ƒ |  j ƒ  d	 S(
   sô   Get 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.

        t   borderwidthi   t   heightt   widtht   WM_DELETE_WINDOWs   +%d+%di   s   <Return>N(   t   Toplevelt   __init__t	   configuret	   resizablet   FALSEt   titlet	   transientt   grab_sett   protocolt   Cancelt   parentt   Nonet   resultt   CreateWidgetst   menut   sett   patht   withdrawt   update_idletaskst   geometryt   winfo_rootxt   winfo_widtht   winfo_reqwidtht   winfo_rootyt   winfo_heightt   winfo_reqheightt	   deiconifyt   bindt   Okt   wait_window(   t   selfR   R   t   menuItemt   filePath(    (    s1   C:\RCS\Python\lib\idlelib\configHelpSourceEdit.pyR      s,    
		


	
c      
   C   sm  t  |  ƒ |  _ t  |  ƒ |  _ t  |  ƒ |  _ t |  d d d t ƒ|  _ |  j j d t d t	 d t
 ƒ t |  j d t d t d	 d
 ƒ} t |  j d |  j d d ƒ|  _ |  j j ƒ  t |  j d t d t d	 d ƒ} t |  j d |  j d d ƒ|  _ |  j j ƒ  | j d t d d d d ƒ |  j j d t d d d d ƒ | j d t d d d d ƒ |  j j d t d d d d ƒ t |  j d	 d d d d |  j ƒ} | j d d ƒ t |  ƒ } | j d t d t ƒ t | d	 d d d d t d |  j ƒ|  _ |  j j d d d d d d d d ƒ t | d	 d d d d |  j ƒ|  _ |  j j d d d d d d d d ƒ d  S(   NR   i   t   relieft   sidet   expandt   fillt   anchort   justifyt   texts
   Menu Item:t   textvariableR   i   s,   Help File Path: Enter URL or browse for filei(   t   padxi   t   padyi   t   Browsei   t   commandt   OKt   defaultt   rowi    t   columnR   i   (   t	   StringVarR   R   t   fontSizet   Framet   GROOVEt	   frameMaint   packt   TOPt   TRUEt   BOTHt   Labelt   Wt   LEFTt   Entryt	   entryMenut	   focus_sett	   entryPatht   Buttont
   browseFilet   BOTTOMt   Xt   ACTIVER#   t   buttonOkt   gridR   t   buttonCancel(   R%   t	   labelMenut	   labelPatht   browseButtont   frameButtons(    (    s1   C:\RCS\Python\lib\idlelib\configHelpSourceEdit.pyR   ,   s<    		%c         C   sÿ   d d d d d g } |  j  j ƒ  } | rE t j  j | ƒ \ } } nm d  } t j d  d k r¦ t j  j t j  j t j	 ƒ d ƒ } t j  j
 | ƒ s² t j ƒ  } q² n t j ƒ  } t j d |  d | ƒ } | j d | d | ƒ } | rû |  j  j | ƒ n  d  S(   Ns
   HTML Filess   *.htm *.htmlt   TEXTs	   PDF Filess   *.pdfs   Windows Help Filess   *.chms
   Text Filess   *.txts	   All FilesR    i   t   wint   DocR   t	   filetypest
   initialdirt   initialfile(   s
   HTML Filess   *.htm *.htmlRT   (   s	   PDF Filess   *.pdfRT   (   s   Windows Help Filess   *.chm(   s
   Text Filess   *.txtRT   (   s	   All FilesR    (   R   t   gett   ost   splitR   t   syst   platformt   joint   dirnamet
   executablet   isdirt   getcwdt   tkFileDialogt   Opent   showR   (   R%   RW   R   t   dirt   baset
   opendialogt   file(    (    s1   C:\RCS\Python\lib\idlelib\configHelpSourceEdit.pyRI   L   s$    	$c         C   sŸ   t  } |  j j ƒ  } | j ƒ  | sW t j d d d d d |  ƒ |  j j ƒ  t } nD t	 | ƒ d k r› t j d d d d d |  ƒ |  j j ƒ  t } n  | S(   s3   Simple validity check for a sensible menu item nameR   s   Menu Item Errort   messages   No menu item specifiedR   i   s(   Menu item too long:
Limit 30 characters.(
   t   TrueR   RZ   t   stript   tkMessageBoxt	   showerrorRE   RF   t   Falset   len(   R%   t   menuOkR   (    (    s1   C:\RCS\Python\lib\idlelib\configHelpSourceEdit.pyt   MenuOkc   s     
		c         C   sÎ   t  } |  j j ƒ  } | j ƒ  | sW t j d d d d d |  ƒ |  j j ƒ  t } ns | j	 d ƒ ri na | d  d	 k r† | d } n  t
 j j | ƒ sÊ t j d d d d
 d |  ƒ |  j j ƒ  t } n  | S(   s(   Simple validity check for menu file pathR   s   File Path ErrorRk   s   No help file path specified.R   s   www.t   httpi   s   file:s   Help file path does not exist.(   s   www.s   http(   Rl   R   RZ   Rm   Rn   Ro   RG   RF   Rp   t
   startswithR[   t   exists(   R%   t   pathOkR   (    (    s1   C:\RCS\Python\lib\idlelib\configHelpSourceEdit.pyt   PathOkw   s(    
		c         C   sª   |  j  ƒ  r¦ |  j ƒ  r¦ |  j j ƒ  j ƒ  |  j j ƒ  j ƒ  f |  _ t j d k r™ |  j d } | j	 d ƒ rs q™ t
 |  j ƒ |  _ d | |  j d <n  |  j ƒ  n  d  S(   Nt   darwini   t   wwws   file:s   http:s   file://(   s   wwws   file:s   http:(   Rs   Rx   R   RZ   Rm   R   R   R]   R^   Ru   t   listt   destroy(   R%   t   eventR   (    (    s1   C:\RCS\Python\lib\idlelib\configHelpSourceEdit.pyR#      s    c         C   s   d  |  _ |  j ƒ  d  S(   N(   R   R   R|   (   R%   R}   (    (    s1   C:\RCS\Python\lib\idlelib\configHelpSourceEdit.pyR      s    	N(
   t   __name__t
   __module__R   R   RI   Rs   Rx   R   R#   R   (    (    (    s1   C:\RCS\Python\lib\idlelib\configHelpSourceEdit.pyR   
   s   !	 			t   __main__c          C   s!   d }  t  t d ƒ } | j GHd  S(   NR   s   Get Help Source(   R   t   rootR   (   t   keySeqt   dlg(    (    s1   C:\RCS\Python\lib\idlelib\configHelpSourceEdit.pyt   run¤   s    R.   t   DialogR3   (   t   __doc__R[   R]   t   TkinterRn   Rd   R   R   R~   t   TkR   R„   RH   R=   t   mainloop(    (    (    s1   C:\RCS\Python\lib\idlelib\configHelpSourceEdit.pyt   <module>   s   
—		