Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib64/python3.4/tkinter/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/tkinter/__pycache__/simpledialog.cpython-34.pyc

�
h f�,�@s�dZddlTddlmZddlZGdd�d�ZGdd�de�ZGd	d
�d
e�ZGdd�de�Zd
d�ZGdd�de�Z	dd�Z
Gdd�de�Zdd�Ze
dkr�dd�Ze�ndS)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
�)�*)�
messageboxNc@speZdZdgdddddd�Zdddd�Zd	d
�Zdd�Zd
d�Zdd�ZdS)�SimpleDialog�Nc
Cs�|rt|d|�|_nt|�|_|rV|jj|�|jj|�nt|jd|dd�|_|jjdddt�t|j�|_	|j	j�||_
||_||_|jj
d|j�x�tt|��D]x}||}	t|j	d|	d	||d
d��}
||krL|
jdtd
d�n|
jdtdtdd�q�W|jjd|j�|j|�dS)N�class_�textZaspecti��expand�Zfillz<Return>�commandcSs
|j|�S)N)�done)�self�num�r�9/opt/alt/python34/lib64/python3.4/tkinter/simpledialog.py�<lambda>6sz'SimpleDialog.__init__.<locals>.<lambda>ZreliefZborderwidth��side�WM_DELETE_WINDOW)�Toplevel�root�titleZiconnameZMessage�message�packZBOTH�FrameZframer
�cancel�default�bind�return_event�range�len�Button�configZRIDGE�LEFT�protocol�wm_delete_window�_set_transient)r�masterr�buttonsrrrrr
�s�brrr�__init__!s.
			
 zSimpleDialog.__init__g�?g333333�?c
Csh|j}|j�|j|�|j�|j�ri|j�}|j�}|j�}|j�}n"|j	�}|j
�}d}}|j�}	|j�}
|||	|}|||
|}||	|j	�kr�|j	�|	}n|dkrd}n||
|j
�kr.|j
�|
}n|dkrCd}n|j
d||f�|j�dS)Nrz+%d+%d)r�withdraw�	transient�update_idletasksZwinfo_ismappedZwinfo_widthZwinfo_height�winfo_rootx�winfo_rootyZwinfo_screenwidthZwinfo_screenheightZwinfo_reqwidthZwinfo_reqheight�geometry�	deiconify)
rr&ZrelxZrelyZwidgetZm_widthZm_heightZm_xZm_yZw_widthZw_height�x�yrrrr%=s4	



		zSimpleDialog._set_transientcCs;|jj�|jj�|jj�|jj�|jS)N)r�wait_visibility�grab_set�mainloop�destroyr
)rrrr�goZs




zSimpleDialog.gocCs3|jdkr|jj�n|j|j�dS)N)rr�bellr)r�eventrrrraszSimpleDialog.return_eventcCs3|jdkr|jj�n|j|j�dS)N)rrr9r)rrrrr$gszSimpleDialog.wm_delete_windowcCs||_|jj�dS)N)r
r�quit)rr
rrrrms	zSimpleDialog.done)	�__name__�
__module__�__qualname__r*r%r8rr$rrrrrrsrc@seZdZdZddd�Zdd�Zdd�Zd	d
�Zddd�Zdd
d�Z	dd�Z
dd�ZdS)�DialogzZClass to open dialogs.

    This class is intended as a base class for custom dialogs
    NcCs=tj||�|j�|j�r6|j|�n|rL|j|�n||_d|_t|�}|j	|�|_
|jdddd�|j�|j
s�||_
n|j
d|j�|jdk	r|jd|j�d|j�df�n|j�|j
j�|j�|j�|j|�dS)z�Initialize a dialog.

        Arguments:

            parent -- a parent window (the application window)

            title -- the dialog title
        N�padx��padyrz+%d+%d�2)rr*r+Zwinfo_viewabler,r�parent�resultr�body�
initial_focusr�	buttonboxr#rr0r.r/r1�	focus_setr4r5Zwait_window)rrDrrFrrrr*ys.

		
	



zDialog.__init__cCsd|_tj|�dS)zDestroy the windowN)rGrr7)rrrrr7�s	zDialog.destroycCsdS)z�create dialog body.

        return widget that should have initial focus.
        This method should be overridden, and is called
        by the __init__ method.
        Nr)rr&rrrrF�szDialog.bodyc
Cs�t|�}t|ddddd|jdt�}|jdtdd	d
d	�t|ddddd|j�}|jdtdd	d
d	�|jd|j�|jd
|j�|j�dS)z[add standard button box.

        override if you do not want the standard buttons
        rZOK�width�
r
rrr@rArB�Cancelz<Return>z<Escape>N)rr �okZACTIVErr"rr)rZbox�wrrrrH�s'!zDialog.buttonboxc
CsQ|j�s|jj�dS|j�|j�z|j�Wd|j�XdS)N)�validaterGrIr+r-�applyr)rr:rrrrM�s


z	Dialog.okcCs-|jdk	r|jj�n|j�dS)N)rDrIr7)rr:rrrr�sz
Dialog.cancelcCsdS)z�validate the data

        This method is called automatically to validate the data before the
        dialog is destroyed. By default, it always validates OK.
        r	r)rrrrrO�szDialog.validatecCsdS)z�process the data

        This method is called automatically to process the data, *after*
        the dialog is destroyed. By default, it does nothing.
        Nr)rrrrrP�szDialog.apply)r<r=r>�__doc__r*r7rFrHrMrrOrPrrrrr?rs2	
	r?c@sLeZdZdddddd�Zdd�Zdd�Zdd	�ZdS)
�_QueryDialogNcCsM|stj}n||_||_||_||_tj|||�dS)N)�tkinterZ
_default_root�prompt�minvalue�maxvalue�initialvaluer?r*)rrrTrWrUrVrDrrrr*s				z_QueryDialog.__init__cCsd|_tj|�dS)N)�entryr?r7)rrrrr7s	z_QueryDialog.destroycCs�t|d|jdt�}|jdddddt�t|dd	�|_|jjdd
dddtt�|jdk	r�|jj	d|j�|jj
dt�n|jS)NrZjustify�rowrr@rAZsticky�namerXr	)ZLabelrTr"Zgrid�WZEntryrX�ErW�insertZselect_rangeZEND)rr&rNrrrrFs#z_QueryDialog.bodyc
Cs�y|j�}Wn3tk
rEtjd|jdd|�dSYnX|jdk	r�||jkr�tjdd|jd|�dS|jdk	r�||jkr�tjdd|jd|�dS||_d	S)
Nz
Illegal valuez
Please try againrDrz	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�errormessagerUrVrE)rrErrrrO#s0

	

	z_QueryDialog.validate)r<r=r>r*r7rFrOrrrrrR�s
rRc@s"eZdZdZdd�ZdS)�
_QueryIntegerzNot an integer.cCst|jj��S)N)�intrX�get)rrrrr^Gsz_QueryInteger.getresultN)r<r=r>rar^rrrrrbEsrbcKst|||�}|jS)z�get an integer from the user

    Arguments:

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

    Return value is an integer
    )rbrE)rrT�kw�drrr�
askintegerJsrgc@s"eZdZdZdd�ZdS)�_QueryFloatzNot a floating point value.cCst|jj��S)N)�floatrXrd)rrrrr^Zsz_QueryFloat.getresultN)r<r=r>rar^rrrrrhXsrhcKst|||�}|jS)z�get a float from the user

    Arguments:

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

    Return value is a float
    )rhrE)rrTrerfrrr�askfloat]srjc@s4eZdZdd�Zdd�Zdd�ZdS)�_QueryStringcOsCd|kr#|d|_|d=n	d|_tj|||�dS)N�show)�_QueryString__showrRr*)r�argsrerrrr*ls


	z_QueryString.__init__cCs;tj||�}|jdk	r7|jd|j�n|S)Nrl)rRrFrmZ	configure)rr&rXrrrrFtsz_QueryString.bodycCs
|jj�S)N)rXrd)rrrrr^zsz_QueryString.getresultN)r<r=r>r*rFr^rrrrrkksrkcKst|||�}|jS)z�get a string from the user

    Arguments:

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

    Return value is a string
    )rkrE)rrTrerfrrr�	askstring}sro�__main__cCsmt�}|dd�}t|ddd|�}|j�t|ddd|j�}|j�|j�dS)NcSs�t|ddddddgddd	d
dd�}t|j��ttd
ddd��ttd
ddddd��ttd
d��dS)Nrz�This 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?r'ZYesZNorLrrr�rzTest DialogZSpamz	Egg countrW�zEgg weight
(in tons)rUr	rV�dz	Egg label�)r�printr8rgrjro)rrfrrr�doit�s		
ztest.<locals>.doitrZTestr
ZQuit)ZTkr rr;r6)rrv�t�qrrr�test�s	

ry)rQrSrrrr?rRrbrgrhrjrkror<ryrrrr�<module>s
S�F