mς
­fIc           @   s  d  Z  d k Td k Z d e f d     YZ d e f d     YZ d e f d     YZ d	   Z d
 e f d     YZ d   Z	 d e f d     YZ
 d   Z e d j oW e   Z e i   e d d d d d GHe	 d d d d d d GHe d d  GHn d S(   sϊ   Dialog boxes

This module handles dialog boxes. It contains the following
public symbols:

Dialog -- a base class for dialogs

askinteger -- get an integer from the user

askfloat -- get a float from the user

askstring -- get a string from the user
(   t   *Nt   Dialogc           B   s_   t  Z d  Z e d  Z d   Z d   Z d   Z e d  Z e d  Z	 d   Z
 d   Z RS(	   sZ   Class to open dialogs.

    This class is intended as a base class for custom dialogs
    c         C   s   t  i |  |  |  i |  | o |  i |  n | |  _ d |  _ t |   } |  i	 |  |  _
 | i d d d d  |  i   |  i   |  i   |  i
 p |  |  _
 n |  i d |  i  |  i d j	 o/ |  i d | i   d | i   d f  n |  i
 i   |  i |   d S(   s   Initialize a dialog.

        Arguments:

            parent -- a parent window (the application window)

            title -- the dialog title
        t   padxi   t   padyt   WM_DELETE_WINDOWs   +%d+%di2   N(   t   Toplevelt   __init__t   selft   parentt	   transientt   titlet   Nonet   resultt   Framet   bodyt   initial_focust   packt	   buttonboxt   wait_visibilityt   grab_sett   protocolt   cancelt   geometryt   winfo_rootxt   winfo_rootyt	   focus_sett   wait_window(   R   R   R
   R   (    (    t2   /mit/python/lib/python2.4/lib-tk/tkSimpleDialog.pyR   &   s(    	 		



/c         C   s   d |  _ t i |   d S(   s   Destroy the windowN(   R   R   R   R   t   destroy(   R   (    (    R   R   P   s     	c         C   s   d S(   s«   create dialog body.

        return widget that should have initial focus.
        This method should be overridden, and is called
        by the __init__ method.
        N(    (   R   t   master(    (    R   R   X   s    c      
   C   sΐ   t  |   } t | d d d d d |  i d t } | i d t d d	 d
 d	  t | d d d d d |  i	 } | i d t d d	 d
 d	  |  i
 d |  i  |  i
 d |  i	  | i   d S(   s[   add standard button box.

        override if you do not want the standard buttons
        t   textt   OKt   widthi
   t   commandt   defaultt   sideR   i   R   t   Cancels   <Return>s   <Escape>N(   R   R   t   boxt   Buttont   okt   ACTIVEt   wR   t   LEFTR   t   bind(   R   R%   R)   (    (    R   R   a   s     '!c         C   sN   |  i   p |  i i   d  Sn |  i   |  i   |  i   |  i   d  S(   N(   R   t   validateR   R   t   withdrawt   update_idletaskst   applyR   (   R   t   event(    (    R   R'   v   s    


c         C   s/   |  i d  j	 o |  i i   n |  i   d  S(   N(   R   R   R   R   R   (   R   R0   (    (    R   R      s    c         C   s   d S(   s¨   validate the data

        This method is called automatically to validate the data before the
        dialog is destroyed. By default, it always validates OK.
        i   N(    (   R   (    (    R   R,      s     c         C   s   d S(   s‘   process the data

        This method is called automatically to process the data, *after*
        the dialog is destroyed. By default, it does nothing.
        N(    (   R   (    (    R   R/      s    (   t   __name__t
   __module__t   __doc__R   R   R   R   R   R'   R   R,   R/   (    (    (    R   R      s    *				
		t   _QueryDialogc           B   s8   t  Z d  d  d  d  d  Z d   Z d   Z d   Z RS(   Nc         C   sX   | p d  k } | i } n | |  _ | |  _ | |  _ | |  _ t i	 |  | |  d  S(   N(   R   t   Tkintert   _default_roott   promptR   t   minvaluet   maxvaluet   initialvalueR   R   R
   (   R   R
   R7   R:   R8   R9   R   R5   (    (    R   R   ₯   s    					c         C   s   d  |  _ t i |   d  S(   N(   R   R   t   entryR   R   (   R   (    (    R   R   Ά   s    	c         C   s­   t  | d |  i d t } | i d d d d d t  t | d d	 |  _	 |  i	 i d d
 d d d t t
  |  i o- |  i	 i d |  i  |  i	 i d t  n |  i	 S(   NR   t   justifyt   rowi    R   i   t   stickyt   nameR;   i   (   t   LabelR   R   R7   R*   R)   t   gridt   Wt   EntryR;   t   ER:   t   insertt   select_ranget   END(   R   R   R)   (    (    R   R   Ί   s    #
c         C   sη   d  k  } y |  i   } Wn4 t j
 o( | i d |  i d d |  d Sn X|  i d  j	 o5 | |  i j  o% | i d d |  i d |  d Sn |  i	 d  j	 o5 | |  i	 j o% | i d d |  i	 d |  d Sn | |  _ d	 S(
   Ns   Illegal values   
Please try againR   i    s	   Too smalls2   The allowed minimum value is %s. Please try again.s	   Too larges2   The allowed maximum value is %s. Please try again.i   (
   t   tkMessageBoxR   t	   getresultR   t
   ValueErrort   showwarningt   errormessageR8   R   R9   (   R   RH   R   (    (    R   R,   Θ   s(    		

	 	

 	

	(   R1   R2   R   R   R   R   R,   (    (    (    R   R4   £   s   		t   _QueryIntegerc           B   s   t  Z d Z d   Z RS(   Ns   Not an integer.c         C   s   t  |  i i    S(   N(   t   intR   R;   t   get(   R   (    (    R   RI   ο   s    (   R1   R2   RL   RI   (    (    (    R   RM   ν   s   c         K   s   t  |  | |  } | i S(   sΌ   get an integer from the user

    Arguments:

        title -- the dialog title
        prompt -- the label text
        **kw -- see SimpleDialog class

    Return value is an integer
    N(   RM   R
   R7   t   kwt   dR   (   R
   R7   RP   RQ   (    (    R   t
   askintegerς   s    
 t   _QueryFloatc           B   s   t  Z d Z d   Z RS(   Ns   Not a floating point value.c         C   s   t  |  i i    S(   N(   t   floatR   R;   RO   (   R   (    (    R   RI     s    (   R1   R2   RL   RI   (    (    (    R   RS      s   c         K   s   t  |  | |  } | i S(   sΆ   get a float from the user

    Arguments:

        title -- the dialog title
        prompt -- the label text
        **kw -- see SimpleDialog class

    Return value is a float
    N(   RS   R
   R7   RP   RQ   R   (   R
   R7   RP   RQ   (    (    R   t   askfloat  s    
 t   _QueryStringc           B   s#   t  Z d   Z d   Z d   Z RS(   Nc         O   sH   | i d  o | d |  _ | d =n
 d  |  _ t i |  | |  d  S(   Nt   show(   RP   t   has_keyR   t   _QueryString__showR   R4   R   t   args(   R   RZ   RP   (    (    R   R     s
    	c         C   s=   t  i |  |  } |  i d  j	 o | i d |  i  n | S(   NRW   (   R4   R   R   R   R;   RY   R   t	   configure(   R   R   R;   (    (    R   R     s    c         C   s   |  i i   S(   N(   R   R;   RO   (   R   (    (    R   RI   "  s    (   R1   R2   R   R   RI   (    (    (    R   RV     s   		c         K   s   t  |  | |  } | i S(   sΈ   get a string from the user

    Arguments:

        title -- the dialog title
        prompt -- the label text
        **kw -- see SimpleDialog class

    Return value is a string
    N(   RV   R
   R7   RP   RQ   R   (   R
   R7   RP   RQ   (    (    R   t	   askstring%  s    
 t   __main__t   Spams	   Egg countR:   i   s   Egg weight
(in tons)R8   i   R9   id   s	   Egg label(   R3   R5   t   osR   R   R4   RM   RR   RS   RU   RV   R\   R1   t   Tkt   roott   update(
   R4   RV   RR   Ra   RU   R\   RS   RM   R   R_   (    (    R   t   ?   s    	J				
