
”àW§  ã               @   s„   d  Z  d d l Td d l j Z Gd d „  d e ƒ Z e d k r€ d d l Z e j	 d d d	 d
 d ƒd d l
 m Z e e ƒ d S)a   
Dialog that allows user to specify a new config file section name.
Used to get new highlight theme and keybinding set names.
The 'return value' for the dialog, used two placed in configDialog.py,
is the .result attribute set in the Ok and Cancel methods.
é    )Ú*Nc               @   sU   e  Z d  Z d d d „ Z d d „  Z d d „  Z d d	 d
 „ Z d d d „ Z d S)ÚGetCfgSectionNameDialogFc             C   sA  t  j |  | ƒ |  j d d ƒ |  j d t d t ƒ |  j | ƒ |  j | ƒ |  j ƒ  |  j d |  j	 ƒ | |  _
 | |  _ | |  _ |  j ƒ  |  j ƒ  |  j ƒ  |  j j d |  j j ƒ  ƒ |  j d | j ƒ  | j ƒ  d |  j ƒ  d | j ƒ  | s| j ƒ  d |  j ƒ  d n d f ƒ |  j ƒ  |  j ƒ  d	 S)
zÒ
        message - string, informational message to display
        used_names - string collection, names already in use for validity check
        _htest - bool, change box location when running htest
        Úborderwidthé   ZheightÚwidthZWM_DELETE_WINDOWz+%d+%dé   éd   N)ÚToplevelÚ__init__Z	configureZ	resizableÚFALSEÚtitleZ	transientZgrab_setÚprotocolÚCancelÚparentÚmessageÚ
used_namesÚcreate_widgetsZwithdrawZupdate_idletasksÚmessageInfoÚconfigÚ	frameMainZwinfo_reqwidthZgeometryZwinfo_rootxZwinfo_widthZwinfo_rootyZwinfo_heightZwinfo_reqheightZ	deiconifyZwait_window)Úselfr   r   r   r   Z_htest© r   úL/afs/.cs/s/python-3.5.2/amd64_ubu14/lib/python3.5/configSectionNameDialog.pyr
      s,    
			


		0
z GetCfgSectionNameDialog.__init__c             C   sˆ  t  |  j ƒ |  _ t  |  j ƒ |  _ t |  d d d t ƒ|  _ |  j j d t d t	 d t
 ƒ t |  j d t d t d	 d
 d d
 d |  j ƒ|  _ t |  j d |  j d d ƒ} | j ƒ  |  j j d	 d
 d d
 ƒ | j d	 d
 d d
 ƒ t |  d d ƒ} | j d t ƒ t | d d d d d |  j ƒ|  _ |  j j d t d	 d
 ƒ t | d d d d d |  j ƒ|  _ |  j j d t d	 d
 ƒ d  S)Nr   r   ZreliefZsideÚexpandÚfillZanchorZjustifyZpadxr   ZpadyÚtextZtextvariabler   é   ÚOké   Zcommandr   )Z	StringVarr   ÚnameZfontSizeZFrameZSUNKENr   ÚpackZTOPÚTRUEZBOTHZMessageÚWZLEFTr   r   ZEntryZ	focus_setZBOTTOMZButtonr   ZbuttonOkr   ZbuttonCancelZRIGHT)r   Z	entryNameZframeButtonsr   r   r   r   +   s$    
z&GetCfgSectionNameDialog.create_widgetsc             C   sª   |  j  j ƒ  j ƒ  } | s: t j d d d d d |  ƒ nl t | ƒ d k ru t j d d d d d d |  ƒ d	 } n1 | |  j k r¦ t j d d d d
 d |  ƒ d	 } | S)z‹ After stripping entered name, check that it is a  sensible
        ConfigParser file section name. Return it if it is, '' if not.
        r   z
Name Errorr   zNo name specified.r   r   z)Name too long. It should be no more than z30 characters.Ú zThis name is already in use.)r   ÚgetÚstripÚtkMessageBoxZ	showerrorÚlenr   )r   r   r   r   r   Úname_ok@   s    	zGetCfgSectionNameDialog.name_okNc             C   s)   |  j  ƒ  } | r% | |  _ |  j ƒ  d  S)N)r(   ÚresultÚdestroy)r   Úeventr   r   r   r   r   S   s    	zGetCfgSectionNameDialog.Okc             C   s   d |  _  |  j ƒ  d  S)Nr#   )r)   r*   )r   r+   r   r   r   r   Y   s    	zGetCfgSectionNameDialog.Cancel)Ú__name__Ú
__module__Ú__qualname__r
   r   r(   r   r   r   r   r   r   r   
   s
    r   Ú__main__z"idlelib.idle_test.test_config_nameÚ	verbosityr   ÚexitF)Úrun)Ú__doc__ÚtkinterZtkinter.messageboxZ
messageboxr&   r	   r   r,   ZunittestÚmainZidlelib.idle_test.htestr2   r   r   r   r   Ú<module>   s   
S