/ lib / tkinter / simpledialog.pyc
simpledialog.pyc
  1  o

  2  6�Hc�/�@s�dZddlTddlmZmZddlmZGdd�d�ZGdd�de�Zdd
  3  d�Zdd
�Z	Gdd�de�Z
  4  Gdd�de
  5  �Zdd�ZGdd�de
  6  �Z
dd�ZGdd�de
  7  �Zdd�Zedkredd�Ze�d	Sd	S) a&This modules handles dialog boxes.
  8  
  9  It contains the following public symbols:
 10  
 11  SimpleDialog -- A simple but flexible modal dialog box
 12  
 13  Dialog -- a base class for dialogs
 14  
 15  askinteger -- get an integer from the user
 16  
 17  askfloat -- get a float from the user
 18  
 19  askstring -- get a string from the user
 20  �)�*)�_get_temp_root�_destroy_temp_root)�
 21  messageboxc@sBeZdZdgddddfdd�Zdd�Zdd�Zd	d
 22  �Zdd�ZdS)
�SimpleDialog�NcCs$|r
 23  t||d�|_nt|�|_|r|j�|�|j�|�t|j�t|j|dd�|_|jjdtd�t	|j�|_
 24  |j
 25  ��||_||_||_
|j�d|j�tt|��D]&}||}	t|j
 26  |	||fdd�d	�}
 27  ||krs|
 28  jtd
 29  d�|
 30  jttdd�qU|j�d
|j�|j�|�t|j|�dS)N)�class_i�)�text�aspect�)�expand�fill�<Return>cSs
 31  |�|�S�N)�done��self�num�r�|C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\tkinter\simpledialog.py�<lambda>9s
 32  z'SimpleDialog.__init__.<locals>.<lambda>�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 rr�s�brrr�__init__!s4
 33  
 34  
 35  �zSimpleDialog.__init__cCs.|j��|j��|j��|j��|jSr)r�wait_visibility�grab_set�mainloop�destroyr�rrrr�goAs
 36  
 37  
 38  
 39  
 40  zSimpleDialog.gocC�(|jdur|j��dS|�|j�dSr)r*r�bellr�r�eventrrrr,H�
 41  zSimpleDialog.return_eventcCrBr)r)rrCrr@rrrr4NrFzSimpleDialog.wm_delete_windowcCs||_|j��dSr)rr�quitrrrrrT�zSimpleDialog.done)�__name__�
 42  __module__�__qualname__r;rAr,r4rrrrrrs
 43  � rc@sVeZdZdZddd�Zdd�Zdd�Zd	d
 44  �Zddd�Zdd
d�Z	dd�Z
 45  dd�ZdS)�DialogzZClass to open dialogs.
 46  
 47      This class is intended as a base class for custom dialogs
 48      NcCs�|}|dur	t�}t�||�|��|dur |��r |�|�|r'|�|�t|�||_d|_	t
 49  |�}|�|�|_|j
ddd�|��|jdurN||_|�d|j�t||�|j��|��|��|�|�dS)z�Initialize a dialog.
 50  
 51          Arguments:
 52  
 53              parent -- a parent window (the application window)
 54  
 55              title -- the dialog title
 56          N�)�padx�padyr)rrr;�withdraw�winfo_viewabler5r r"�parent�resultr'�body�
initial_focusr%�	buttonboxr3r)r6�	focus_setr<r=�wait_window)rrRr r7rTrrrr;`s0	
 57  
 58  
 59  
 60  
 61  zDialog.__init__cCsd|_t�|�t|j�dS)zDestroy the windowN)rUrr?rr7r@rrrr?�s
 62  zDialog.destroycC�dS)z�create dialog body.
 63  
 64          return widget that should have initial focus.
 65          This method should be overridden, and is called
 66          by the __init__ method.
 67          Nr)rr7rrrrT��zDialog.bodycCsvt|�}t|dd|jtd�}|jtddd�t|dd|jd�}|jtddd�|�d|j�|�d	|j�|��d
 68  S)z[add standard button box.
 69  
 70          override if you do not want the standard buttons
 71          �OK�
 72  )r	�widthrr*rM)rrNrO�Cancel)r	r]rrz<Escape>N)r'r/�ok�ACTIVEr%r2r)r+)r�box�wrrrrV�szDialog.buttonboxcCsH|��s|j��dS|��|��z|��W|��dS|��wr)�validaterUrWrP�update_idletasks�applyr)rDrrrr_�s
 73  
 74  z	Dialog.okcCs |jdur
 75  |j��|��dSr)rRrWr?rDrrrr)�s
 76  
 77  z
Dialog.cancelcCrY)z�validate the data
 78  
 79          This method is called automatically to validate the data before the
 80          dialog is destroyed. By default, it always validates OK.
 81          rrr@rrrrc�rZzDialog.validatecCrY)z�process the data
 82  
 83          This method is called automatically to process the data, *after*
 84          the dialog is destroyed. By default, it does nothing.
 85          Nrr@rrrre�rZzDialog.applyr)rIrJrK�__doc__r;r?rTrVr_r)rcrerrrrrLYs
 86  3		
 87  
 88  
 89  	rLNc
 90  Cs|��|��|��}|��}|��}|��}|durg|��rg|��|��|d}|�	�|�
 91  �|d}|��}|��}	t
||||�}t||�}t
||	||�}t||	�}|jdkrft|d�}n|��|d}|��|d}|�||�|�d||f�|��dS)N��aqua�z+%d+%d)�wm_withdrawrd�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�
 92  wm_maxsize�wm_geometry�wm_deiconify)
 93  rbrRZminwidthZ	minheight�maxwidthZ	maxheight�x�y�vrootx�vrootyrrrr6�s.
 94  
 95  
 96  
 97  �r6cCs@|jdkr|j�dd|dd�dS|jdkr|�dd�dSdS)	Nrhz!::tk::unsupported::MacWindowStyle�styleZ
moveableModalr�x11z-type�dialog)rx�tk�call�
wm_attributes)rbrrrr"s
 98  
 99  �
100  �r"c@s4eZdZ			d
101  dd�Zdd�Zdd�Zdd	�ZdS)�_QueryDialogNcCs*||_||_||_||_t�|||�dSr)�prompt�minvalue�maxvalue�initialvaluerLr;)rr r�r�r�r�rRrrrr;s
102  z_QueryDialog.__init__cCsd|_t�|�dSr)�entryrLr?r@rrrr?rHz_QueryDialog.destroycCsrt||jtd�}|jddtd�t|dd�|_|jjddttd�|jdur6|j�	d|j�|j�
103  dt�|jS)N)r	�justifyrrM)�rowrN�stickyr�)�namer)�Labelr�r2�grid�W�Entryr��Er��insert�select_range�END)rr7rbrrrrT!s
104  z_QueryDialog.bodycCs�z|��}Wntytjd|jd|d�YdSw|jdur3||jkr3tjdd|j|d�dS|jdurJ||jkrJtjdd|j|d�dS||_d	S)
105  Nz
Illegal valuez
106  Please try again)rRrz	Too smallz2The allowed minimum value is %s. Please try again.z	Too largez2The allowed maximum value is %s. Please try again.r)�	getresult�
107  ValueErrorr�showwarning�errormessager�r�rS)rrSrrrrc/s<������z_QueryDialog.validate)NNNN)rIrJrKr;r?rTrcrrrrr�s
108  �
r�c@�eZdZdZdd�ZdS)�
_QueryIntegerzNot an integer.cC�|�|j���Sr)�getintr��getr@rrrr�T�z_QueryInteger.getresultN�rIrJrKr�r�rrrrr�Q�r�cK�t||fi|��}|jS)z�get an integer from the user
109  
110      Arguments:
111  
112          title -- the dialog title
113          prompt -- the label text
114          **kw -- see SimpleDialog class
115  
116      Return value is an integer
117      )r�rS�r r��kw�drrr�
118  askintegerX�r�c@r�)�_QueryFloatzNot a floating point value.cCr�r)�	getdoubler�r�r@rrrr�jr�z_QueryFloat.getresultNr�rrrrr�gr�r�cKr�)z�get a float from the user
119  
120      Arguments:
121  
122          title -- the dialog title
123          prompt -- the label text
124          **kw -- see SimpleDialog class
125  
126      Return value is a float
127      )r�rSr�rrr�askfloatnr�r�c@s$eZdZdd�Zdd�Zdd�ZdS)�_QueryStringcOs<d|vr
|d|_|d=nd|_tj|g|�Ri|��dS)N�show)�_QueryString__showr�r;)r�argsr�rrrr;~s
128  
129  z_QueryString.__init__cCs(t�||�}|jdur|j|jd�|S)N)r�)r�rTr��	configure)rr7r�rrrrT�s
130  z_QueryString.bodycCs
131  |j��Sr)r�r�r@rrrr��s
132  z_QueryString.getresultN)rIrJrKr;rTr�rrrrr�}sr�cKr�)z�get a string from the user
133  
134      Arguments:
135  
136          title -- the dialog title
137          prompt -- the label text
138          **kw -- see SimpleDialog class
139  
140      Return value is a string
141      )r�rSr�rrr�	askstring�r�r��__main__cCsLt�}|fdd�}t|d|d�}|��t|d|jd�}|��|��dS)NcSs\t|dgd�dddd�}t|���ttddd	d
142  ��ttdddd
d��ttdd��dS)Nz�This is a test dialog.  Would this have been an actual dialog, the buttons below would have been glowing in soft pink light.
143  Do you believe this?)�Yes�Nor^rrgzTest Dialog)r	r8r*r)r �Spamz	Egg count�)r�zEgg weight
144  (in tons)r�d)r�r�z	Egg label)r�printrAr�r�r�)rr�rrr�doit�s�
145  
146  �ztest.<locals>.doit�Testr�Quit)�Tkr/r%rGr>)rr��t�qrrr�test�sr�r)rf�tkinterrrrrrrLr6r"r�r�r�r�r�r�r�rIr�rrrr�<module>s(
147  :
148  
149  C
150  �