o
    ǋ|c-                     @   s   d Z ddlT ddlmZmZ ddlmZ G dd dZG dd deZdd
dZdd Z	G dd deZ
G dd de
Zdd ZG dd de
Zdd ZG dd de
Zdd Zedkred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                   @   sB   e Zd Zdg ddddfddZdd Zdd Zd	d
 Zdd ZdS )SimpleDialog Nc                 C   s$  |r
t ||d| _nt || _|r| j| | j| t| j t| j|dd| _| jjdtd t	| j| _
| j
  || _|| _|| _| jd| j tt|D ]&}|| }	t| j
|	| |fddd	}
||krs|
jtd
d |
jttdd qU| jd| j | j| t| j| d S )N)class_i  )textZaspect   )expandfill<Return>c                 S   s
   |  |S N)doneselfnum r   &  /home/conda/feedstock_root/build_artifacts/python-split_1669104742391/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/lib/python3.10/tkinter/simpledialog.py<lambda>9   s   
 z'SimpleDialog.__init__.<locals>.<lambda>r	   command   )ZreliefZborderwidth)sider   r   WM_DELETE_WINDOW)ToplevelroottitleZiconname_setup_dialogZMessagemessagepackZBOTHFrameframer   canceldefaultbindreturn_eventrangelenButtonZconfigZRIDGELEFTprotocolwm_delete_window	transient_place_window)r   masterr	   buttonsr$   r#   r   r   r   sbr   r   r   __init__!   s4   


zSimpleDialog.__init__c                 C   s.   | j   | j   | j   | j   | jS r   )r   wait_visibilitygrab_setmainloopdestroyr   r   r   r   r   goA   s
   



zSimpleDialog.goc                 C   (   | j d u r| j  d S | | j  d S r   )r$   r   bellr   r   eventr   r   r   r&   H      
zSimpleDialog.return_eventc                 C   r:   r   )r#   r   r;   r   r8   r   r   r   r,   N   r>   zSimpleDialog.wm_delete_windowc                 C   s   || _ | j  d S r   )r   r   quitr   r   r   r   r   T      zSimpleDialog.done)__name__
__module____qualname__r3   r9   r&   r,   r   r   r   r   r   r      s    
 r   c                   @   sV   e Zd ZdZdddZdd Zdd Zd	d
 ZdddZdddZ	dd Z
dd ZdS )DialogzZClass to open dialogs.

    This class is intended as a base class for custom dialogs
    Nc                 C   s   |}|du r	t  }t| | |   |dur | r | | |r'| | t|  || _d| _	t
| }| || _|jddd |   | jdu rN| | _| 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   r3   withdrawZwinfo_viewabler-   r   r   parentresultr!   bodyinitial_focusr    	buttonboxr+   r#   r.   	focus_setr4   r5   Zwait_window)r   rI   r   r/   rK   r   r   r   r3   `   s0   	




zDialog.__init__c                 C   s   d| _ t|  t| j dS )zDestroy the windowN)rL   r   r7   r   r/   r8   r   r   r   r7      s   
zDialog.destroyc                 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.
        Nr   )r   r/   r   r   r   rK         zDialog.bodyc                 C   sv   t | }t|dd| jtd}|jtddd t|dd| jd}|jtddd | d| j | d	| j |  d
S )z[add standard button box.

        override if you do not want the standard buttons
        ZOK
   )r	   widthr   r$   rE   )r   rF   rG   Cancel)r	   rR   r   r   z<Escape>N)r!   r)   okZACTIVEr    r*   r#   r%   )r   Zboxwr   r   r   rM      s   zDialog.buttonboxc                 C   sH   |   s| j  d S |   |   z|   W |   d S |   w r   )validaterL   rN   rH   update_idletasksapplyr#   r<   r   r   r   rT      s   

z	Dialog.okc                 C   s    | j d ur
| j   |   d S r   )rI   rN   r7   r<   r   r   r   r#      s   

zDialog.cancelc                 C   rO   )zvalidate the data

        This method is called automatically to validate the data before the
        dialog is destroyed. By default, it always validates OK.
        r
   r   r8   r   r   r   rV      rP   zDialog.validatec                 C   rO   )zprocess the data

        This method is called automatically to process the data, *after*
        the dialog is destroyed. By default, it does nothing.
        Nr   r8   r   r   r   rX      rP   zDialog.applyr   )rA   rB   rC   __doc__r3   r7   rK   rM   rT   r#   rV   rX   r   r   r   r   rD   Y   s    
3		


	rD   Nc           
      C   s  |    |   |  }|  }|  }|  }|d urg| rg| | | d  }|	 |
 | d  }|  }|  }	t||| | }t||}t||	| | }t||	}| jdkrft|d}n|  | d }|  | d }| || | d||f  |   d S )N   aqua   z+%d+%d)Zwm_withdrawrW   Zwinfo_reqwidthZwinfo_reqheightZwinfo_vrootwidthZwinfo_vrootheightZwinfo_ismappedZwinfo_rootxZwinfo_widthZwinfo_rootyZwinfo_heightZwinfo_vrootxZwinfo_vrootyminmax_windowingsystemZwinfo_screenwidthZwinfo_screenheightZ
wm_maxsizeZwm_geometryZwm_deiconify)
rU   rI   ZminwidthZ	minheightZmaxwidthZ	maxheightxyZvrootxZvrootyr   r   r   r.      s.   



r.   c                 C   s@   | j dkr| jdd| dd d S | j dkr| dd d S d S )	Nr[   z!::tk::unsupported::MacWindowStylestyleZmoveableModalr   Zx11z-typeZdialog)r_   ZtkcallZwm_attributes)rU   r   r   r   r     s   


r   c                   @   s4   e Zd Z			d
ddZdd Zdd Zdd	 ZdS )_QueryDialogNc                 C   s*   || _ || _|| _|| _t| || d S r   )promptminvaluemaxvalueinitialvaluerD   r3   )r   r   re   rh   rf   rg   rI   r   r   r   r3     s
   z_QueryDialog.__init__c                 C   s   d | _ t|  d S r   )entryrD   r7   r8   r   r   r   r7     r@   z_QueryDialog.destroyc                 C   sr   t || jtd}|jddtd t|dd| _| jjddtt d | jd ur6| j	d| j | j
dt | jS )N)r	   Zjustifyr   rE   )rowrF   Zstickyri   )namer
   )ZLabelre   r*   ZgridWZEntryri   Erh   insertZselect_rangeZEND)r   r/   rU   r   r   r   rK   !  s   
z_QueryDialog.bodyc                 C   s   z|   }W n ty   tjd| jd | d Y dS w | jd ur3|| jk r3tjdd| j | d dS | jd urJ|| jkrJtjdd| j | d dS || _d	S )
NzIllegal valuez
Please try again)rI   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errormessagerf   rg   rJ   )r   rJ   r   r   r   rV   /  s<   z_QueryDialog.validate)NNNN)rA   rB   rC   r3   r7   rK   rV   r   r   r   r   rd     s    
rd   c                   @      e Zd ZdZdd ZdS )_QueryIntegerzNot an integer.c                 C      |  | j S r   )Zgetintri   getr8   r   r   r   ro   T     z_QueryInteger.getresultNrA   rB   rC   rr   ro   r   r   r   r   rt   Q      rt   c                 K      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
    )rt   rJ   r   re   kwdr   r   r   
askintegerX     r~   c                   @   rs   )_QueryFloatzNot a floating point value.c                 C   ru   r   )Z	getdoubleri   rv   r8   r   r   r   ro   j  rw   z_QueryFloat.getresultNrx   r   r   r   r   r   g  ry   r   c                 K   rz   )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   rJ   r{   r   r   r   askfloatn  r   r   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )_QueryStringc                 O   s<   d|v r|d | _ |d= nd | _ tj| g|R i | d S )Nshow)_QueryString__showrd   r3   )r   argsr|   r   r   r   r3   ~  s
   
z_QueryString.__init__c                 C   s(   t | |}| jd ur|j| jd |S )N)r   )rd   rK   r   Z	configure)r   r/   ri   r   r   r   rK     s   
z_QueryString.bodyc                 C   s
   | j  S r   )ri   rv   r8   r   r   r   ro     s   
z_QueryString.getresultN)rA   rB   rC   r3   rK   ro   r   r   r   r   r   }  s    r   c                 K   rz   )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   rJ   r{   r   r   r   	askstring  r   r   __main__c                  C   sL   t  } | fdd}t| d|d}|  t| d|jd}|  |  d S )Nc                 S   s\   t | dg ddddd}t|  ttddd	d
 ttd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?)ZYesZNorS   r   rZ   zTest Dialog)r	   r0   r$   r#   r   ZSpamz	Egg count   )rh   zEgg weight
(in tons)r
   d   )rf   rg   z	Egg label)r   printr9   r~   r   r   )r   r}   r   r   r   doit  s   

ztest.<locals>.doitZTestr   ZQuit)ZTkr)   r    r?   r6   )r   r   tqr   r   r   test  s   r   r   )rY   tkinterr   r   r   r   r   rD   r.   r   rd   rt   r~   r   r   r   r   rA   r   r   r   r   r   <module>   s(   
: 

C
