
    d-                        d Z ddlT ddlmZmZ ddlmZ  G d d          Z G d de          Zdd
Zd Z	 G d de          Z
 G d de
          Zd Z G d de
          Zd Z G d de
          Zd Zedk    rd Z e             d	S d	S )a&  This modules handles dialog boxes.

It contains the following public symbols:

SimpleDialog -- A simple but flexible modal dialog box

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
    )*)_get_temp_root_destroy_temp_root)
messageboxc                   :    e Zd Zdg ddddfdZd Zd Zd Zd ZdS )SimpleDialog Nc                    |rt          ||          | _        nt          |          | _        |r4| j                            |           | j                            |           t	          | j                   t          | j        |d          | _        | j                            dt                     t          | j                  | _
        | j
                                         || _        || _        || _        | j                            d| j                   t!          t#          |                    D ]i}||         }	t%          | j
        |	| |fd          }
||k    r|
                    t(          d	
           |
                    t*          t          d           j| j                            d| j                   | j                            |           t3          | j        |           d S )N)class_i  )textaspect   )expandfill<Return>c                 ,    |                      |          S N)doneselfnums     &  /croot/python-split_1694437901252/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/lib/python3.11/tkinter/simpledialog.py<lambda>z'SimpleDialog.__init__.<locals>.<lambda>9   s    499S>>     r   command   )reliefborderwidth)sider   r   WM_DELETE_WINDOW)Toplevelroottitleiconname_setup_dialogMessagemessagepackBOTHFrameframer   canceldefaultbindreturn_eventrangelenButtonconfigRIDGELEFTprotocolwm_delete_window	transient_place_window)r   masterr   buttonsr.   r-   r$   r   r   sbs              r   __init__zSimpleDialog.__init__!   s     	) 777DII ((DI 	&IOOE"""Iu%%%di   tytC@@@...49%%

	z4#4555W&& 	3 	3CAtz,0c I I IL L LAg~~1555FF4F2222	-t/DEEE	F###di(((((r   c                     | j                                          | j                                          | j                                          | j                                          | j        S r   )r#   wait_visibilitygrab_setmainloopdestroyr   r   s    r   gozSimpleDialog.goA   sY    	!!###			xr   c                 ~    | j         | j                                         d S |                     | j                    d S r   )r.   r#   bellr   r   events     r   r0   zSimpleDialog.return_eventH   s<    <INNIIdl#####r   c                 ~    | j         | j                                         d S |                     | j                    d S r   )r-   r#   rH   r   rE   s    r   r8   zSimpleDialog.wm_delete_windowN   s<    ;INNIIdk"""""r   c                 F    || _         | j                                         d S r   )r   r#   quitr   s     r   r   zSimpleDialog.doneT   s!    	r   )__name__
__module____qualname__r?   rF   r0   r8   r    r   r   r   r      su         "d4D) ) ) )@  $ $ $# # #    r   r   c                   H    e Zd ZdZddZd Zd Zd ZddZddZ	d	 Z
d
 ZdS )DialogzZClass to open dialogs.

    This class is intended as a base class for custom dialogs
    Nc                    |}|t                      }t                              | |           |                                  |)|                                r|                     |           |r|                     |           t          |            || _        d| _	        t          |           }|                     |          | _        |                    dd           |                                  | j        | | _        |                     d| j                   t#          | |           | j                                         |                                  |                                  |                     |            dS )zInitialize a dialog.

        Arguments:

            parent -- a parent window (the application window)

            title -- the dialog title
        N   )padxpadyr!   )r   r"   r?   withdrawwinfo_viewabler9   r$   r&   parentresultr+   bodyinitial_focusr)   	buttonboxr7   r-   r:   	focus_setrA   rB   wait_window)r   rZ   r$   r;   r\   s        r   r?   zDialog.__init__`   sh    >#%%F$''' &"7"7"9"9NN6""" 	JJudT{{!YYt__		qq	!!!%!%D($+666dF###$$&&& 	r   c                 p    d| _         t                              |            t          | j                   dS )zDestroy the windowN)r]   r"   rD   r   r;   rE   s    r   rD   zDialog.destroy   s4    !4;'''''r   c                     dS )zcreate dialog body.

        return widget that should have initial focus.
        This method should be overridden, and is called
        by the __init__ method.
        NrQ   )r   r;   s     r   r\   zDialog.body   	     	r   c                    t          |           }t          |dd| j        t                    }|                    t
          dd           t          |dd| j                  }|                    t
          dd           |                     d| j                   |                     d	| j                   |                                 d
S )z[add standard button box.

        override if you do not want the standard buttons
        OK
   )r   widthr   r.   rU   )r    rV   rW   Cancel)r   rg   r   r   z<Escape>N)r+   r3   okACTIVEr)   r6   r-   r/   )r   boxws      r   r^   zDialog.buttonbox   s     Dkk3TTWfMMM	Dqq)))3XREEE	Dqq)))		*dg&&&		*dk***




r   c                 8   |                                  s| j                                         d S |                                  |                                  	 |                                  |                                  d S # |                                  w xY wr   )validater]   r_   rX   update_idletasksapplyr-   rI   s     r   ri   z	Dialog.ok   s    }} 	((***F	JJLLLKKMMMMMDKKMMMMs   B Bc                 n    | j         | j                                          |                                  d S r   )rZ   r_   rD   rI   s     r   r-   zDialog.cancel   s1     ;"K!!###r   c                     dS )zvalidate the data

        This method is called automatically to validate the data before the
        dialog is destroyed. By default, it always validates OK.
        r   rQ   rE   s    r   rn   zDialog.validate   s	     qr   c                     dS )zprocess the data

        This method is called automatically to process the data, *after*
        the dialog is destroyed. By default, it does nothing.
        NrQ   rE   s    r   rp   zDialog.apply   rc   r   r   )rN   rO   rP   __doc__r?   rD   r\   r^   ri   r-   rn   rp   rQ   r   r   rS   rS   Y   s         
1 1 1 1f( ( (    *            r   rS   Nc                    |                                   |                                  |                                 }|                                 }|                                 }|                                 }||                                r|                                |                                |z
  dz  z   }|	                                |
                                |z
  dz  z   }|                                 }|                                 }	t          |||z   |z
            }t          ||          }t          ||	|z   |z
            }t          ||	          }| j        dk    rt          |d          }n4|                                 |z
  dz  }|                                 |z
  dz  }|                     ||           |                     d||fz             |                                  d S )N   aqua   z+%d+%d)wm_withdrawro   winfo_reqwidthwinfo_reqheightwinfo_vrootwidthwinfo_vrootheightwinfo_ismappedwinfo_rootxwinfo_widthwinfo_rootywinfo_heightwinfo_vrootxwinfo_vrootyminmax_windowingsystemwinfo_screenwidthwinfo_screenheight
wm_maxsizewm_geometrywm_deiconify)
rl   rZ   minwidth	minheightmaxwidth	maxheightxyvrootxvrootys
             r   r:   r:      s   MMOOO!!H!!##I!!##H##%%If3355  F$6$6$8$88$C#II  F$7$7$9$9I$E!#KK!!!!6H$x/006NN6I%	1226NN''Ar

A  ""X-!3!!##i/A5LL9%%%MM(aV#$$$NNr   c                     | j         dk    r | j                            dd| dd           d S | j         dk    r|                     dd           d S d S )	Nrw   z!::tk::unsupported::MacWindowStylestylemoveableModalr	   x11z-typedialog)r   tkcallwm_attributes)rl   s    r   r&   r&     sn    V##			5w_b	* 	* 	* 	* 	*	
	u	$	$	***** 
%	$r   c                   .    e Zd Z	 	 	 ddZd Zd Zd ZdS )_QueryDialogNc                 v    || _         || _        || _        || _        t                              | ||           d S r   )promptminvaluemaxvalueinitialvaluerS   r?   )r   r$   r   r   r   r   rZ   s          r   r?   z_QueryDialog.__init__  s=    
   (fe,,,,,r   c                 H    d | _         t                              |            d S r   )entryrS   rD   rE   s    r   rD   z_QueryDialog.destroy  s!    
tr   c                    t          || j        t                    }|                    ddt                     t          |d          | _        | j                            ddt          t          z              | j        @| j        	                    d| j                   | j        
                    dt                     | j        S )N)r   justifyr   rU   )rowrV   stickyr   )namer   )Labelr   r6   gridWEntryr   Er   insertselect_rangeEND)r   r;   rl   s      r   r\   z_QueryDialog.body!  s    &t{D999	11Q'''6000

AAac222(Ja!2333J##As+++zr   c                 l   	 |                                  }n0# t          $ r# t          j        d| j        dz   |            Y dS w xY w| j        ,|| j        k     r!t          j        dd| j        z  |            dS | j        ,|| j        k    r!t          j        dd| j        z  |            dS || _        d	S )
NzIllegal valuez
Please try again)rZ   r   z	Too smallz2The allowed minimum value is %s. Please try again.z	Too largez2The allowed maximum value is %s. Please try again.r   )	getresult
ValueErrorr   showwarningerrormessager   r   r[   )r   r[   s     r   rn   z_QueryDialog.validate/  s
   	^^%%FF 	 	 	"!$88   
 11	 =$$-)?)?"$&*m4	    1=$$-)?)?"$&*m4	    1qs    )AA)NNNN)rN   rO   rP   r?   rD   r\   rn   rQ   r   r   r   r     s`         #-1- - - -        r   r   c                       e Zd ZdZd ZdS )_QueryIntegerzNot an integer.c                 Z    |                      | j                                                  S r   )getintr   getrE   s    r   r   z_QueryInteger.getresultT  s     {{4:>>++,,,r   NrN   rO   rP   r   r   rQ   r   r   r   r   Q  s(        $L- - - - -r   r   c                 ,    t          | |fi |}|j        S )zget an integer from the user

    Arguments:

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

    Return value is an integer
    )r   r[   r$   r   kwds       r   
askintegerr   X  s"     	eV**r**A8Or   c                       e Zd ZdZd ZdS )_QueryFloatzNot a floating point value.c                 Z    |                      | j                                                  S r   )	getdoubler   r   rE   s    r   r   z_QueryFloat.getresultj  s     ~~djnn..///r   Nr   rQ   r   r   r   r   g  s(        0L0 0 0 0 0r   r   c                 ,    t          | |fi |}|j        S )zget a float from the user

    Arguments:

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

    Return value is a float
    )r   r[   r   s       r   askfloatr   n  s"     	E6((R((A8Or   c                        e Zd Zd Zd Zd ZdS )_QueryStringc                 h    d|v r|d         | _         |d= nd | _         t          j        | g|R i | d S )Nshow)_QueryString__showr   r?   )r   argsr   s      r   r?   z_QueryString.__init__~  sM    R<<V*DK6

DKd0T000R00000r   c                     t                               | |          }| j        |                    | j                   |S )N)r   )r   r\   r   	configure)r   r;   r   s      r   r\   z_QueryString.body  s:    !!$//;"OOO---r   c                 4    | j                                         S r   )r   r   rE   s    r   r   z_QueryString.getresult  s    z~~r   N)rN   rO   rP   r?   r\   r   rQ   r   r   r   r   }  sA        1 1 1           r   r   c                 ,    t          | |fi |}|j        S )zget a string from the user

    Arguments:

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

    Return value is a string
    )r   r[   r   s       r   	askstringr     s"     	UF))b))A8Or   __main__c                      t                      } | fd}t          | d|          }|                                 t          | d|j                  }|                                 |                                 d S )Nc                 .   t          | dg dddd          }t          |                                           t          t          ddd	
                     t          t	          dddd                     t          t          dd                     d S )NzThis is a test dialog.  Would this have been an actual dialog, the buttons below would have been glowing in soft pink light.
Do you believe this?)YesNorh   r   rv   zTest Dialog)r   r<   r.   r-   r$   Spamz	Egg count   )r   zEgg weight
(in tons)r   d   )r   r   z	Egg label)r   printrF   r   r   r   )r#   r   s     r   doitztest.<locals>.doit  s    T5
 "9!8!8!" !,	. 	. 	.A !$$&&MMM*V[uEEEFFF(6#:Q$') ) ) * * *)FK0011111r   Testr   Quit)Tkr3   r)   rM   rC   )r#   r   tqs       r   testr     sy    tt 	2 	2 	2 	2  4fd333	4faf555		

r   r   )rt   tkinterr   r   r   r   r"   rS   r:   r&   r   r   r   r   r   r   r   rN   r   rQ   r   r   <module>r      s        6 6 6 6 6 6 6 6      7 7 7 7 7 7 7 7tI I I I IX I I I\   :+ + +@ @ @ @ @6 @ @ @F- - - - -L - - -  0 0 0 0 0, 0 0 0           <      &   z  0 	DFFFFF5 r   