Sindbad~EG File Manager
3
\�,�@s�dZddlTddlmZddlZGdd�d�ZGdd�de�ZGd d
�d
e�ZGdd�de�Zd
d�ZGdd�de�Z dd�Z
Gdd�de�Zdd�Ze
dkr�dd�Ze�dS)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@sLeZdZdgddddfdd�Zddd�Zd d
�Zdd�Zd
d�Zdd�ZdS)�SimpleDialog�NcCs|rt||d�|_n
t|�|_|r:|jj|�|jj|�t|j|dd�|_|jjdtd�t|j�|_ |j j�||_
||_||_|jj
d|j�x\tt|��D]L}||} t|j | ||fdd�d �}
||kr�|
jtd
d�|
jttdd�q�W|jjd
|j�|j|�dS)N)�class_i�)�textZaspect�)�expand�fillz<Return>cSs
|j|�S)N)�done)�self�num�r�,/usr/lib64/python3.6/tkinter/simpledialog.py�<lambda>6sz'SimpleDialog.__init__.<locals>.<lambda>)r�command�)ZreliefZborderwidth)�sider
r �WM_DELETE_WINDOW)�Toplevel�root�titleZiconnameZMessage�message�packZBOTH�Frame�framer
�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__��?�333333�?c
Cs|j}|j�|j|�|j�|j�rJ|j�}|j�}|j�}|j�}n|j �}|j
�}d}}|j�} |j�}
||| |}|||
|}|| |j �kr�|j �| }n|dkr�d}||
|j
�kr�|j
�|
}n|dkr�d}|j
d||f�|j�dS)Nrz+%d+%d)r�withdraw� transient�update_idletasksZwinfo_ismappedZwinfo_widthZwinfo_height�winfo_rootx�winfo_rootyZwinfo_screenwidthZwinfo_screenheightZwinfo_reqwidthZwinfo_reqheight�geometry� deiconify)
rr(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
)rrrr�goZs
zSimpleDialog.gocCs&|jdkr|jj�n|j|j�dS)N)rr�bellr)r�eventrrrras
zSimpleDialog.return_eventcCs&|jdkr|jj�n|j|j�dS)N)rrr=r)rrrrr&gs
zSimpleDialog.wm_delete_windowcCs||_|jj�dS)N)r
r�quit)rr
rrrrmszSimpleDialog.done)r-r.) �__name__�
__module__�__qualname__r,r'r<rr&rrrrrrs
rc@sVeZdZdZddd�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�r&|j|�|r4|j|�||_d|_t|�}|j |�|_
|jddd�|j�|j
sv||_
|j
d|j�|jdk r�|jd|j�d|j�df�|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_viewabler0r�parent�resultr�body�
initial_focusr� buttonboxr%rr4r2r3r5� focus_setr8r9Zwait_window)rrHrrJrrrr,ys.
zDialog.__init__cCsd|_tj|�dS)zDestroy the windowN)rKrr;)rrrrr;�szDialog.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)rr(rrrrJ�szDialog.bodycCsvt|�}t|dd|jtd�}|jtddd�t|dd|jd�}|jtddd�|jd|j�|jd |j�|j�d
S)z[add standard button box.
override if you do not want the standard buttons
ZOK�
)r�widthrrrD)rrErF�Cancel)rrOrz<Return>z<Escape>N)rr"�okZACTIVErr$rr)rZbox�wrrrrL�szDialog.buttonboxc
CsB|j�s|jj�dS|j�|j�z|j�Wd|j�XdS)N)�validaterKrMr/r1�applyr)rr>rrrrQ�s
z Dialog.okcCs |jdk r|jj�|j�dS)N)rHrMr;)rr>rrrr�s
z
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.
rr)rrrrrS�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)rrrrrT�szDialog.apply)N)N)N)r@rArB�__doc__r,r;rJrLrQrrSrTrrrrrCrs
2
rCc@s.eZdZd
dd�Zdd�Zdd�Zdd �ZdS)�_QueryDialogNcCs4|s
tj}||_||_||_||_tj|||�dS)N)�tkinterZ
_default_root�prompt�minvalue�maxvalue�initialvaluerCr,)rrrXr[rYrZrHrrrr,sz_QueryDialog.__init__cCsd|_tj|�dS)N)�entryrCr;)rrrrr;sz_QueryDialog.destroycCsrt||jtd�}|jddtd�t|dd�|_|jjddttd�|jdk rl|jj d|j�|jj
dt�|jS)N)rZjustifyrrD)�rowrEZstickyr\)�namer)ZLabelrXr$Zgrid�WZEntryr\�Er[�insertZselect_rangeZEND)rr(rRrrrrJs
z_QueryDialog.bodyc
Cs�y|j�}Wn*tk
r6tjd|jd|d�dSX|jdk rf||jkrftjdd|j|d�dS|jdk r�||jkr�tjdd|j|d�dS||_d S)
Nz
Illegal valuez
Please try again)rHrz 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�errormessagerYrZrI)rrIrrrrS#s0z_QueryDialog.validate)NNNN)r@rArBr,r;rJrSrrrrrV�s
rVc@seZdZdZdd�ZdS)�
_QueryIntegerzNot an integer.cCs|j|jj��S)N)Zgetintr\�get)rrrrrbGsz_QueryInteger.getresultN)r@rArBrerbrrrrrfEsrfcKst||f|�}|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
)rfrI)rrX�kw�drrr�
askintegerJsrjc@seZdZdZdd�ZdS)�_QueryFloatzNot a floating point value.cCs|j|jj��S)N)Z getdoubler\rg)rrrrrbZsz_QueryFloat.getresultN)r@rArBrerbrrrrrkXsrkcKst||f|�}|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
)rkrI)rrXrhrirrr�askfloat]srlc@s$eZdZdd�Zdd�Zdd�ZdS)�_QueryStringcOs6d|kr|d|_|d=nd|_tj|f|�|�dS)N�show)�_QueryString__showrVr,)r�argsrhrrrr,ls
z_QueryString.__init__cCs(tj||�}|jdk r$|j|jd�|S)N)rn)rVrJroZ configure)rr(r\rrrrJts
z_QueryString.bodycCs
|jj�S)N)r\rg)rrrrrbzsz_QueryString.getresultN)r@rArBr,rJrbrrrrrmksrmcKst||f|�}|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
)rmrI)rrXrhrirrr� askstring}srq�__main__cCsLt�}|fdd�}t|d|d�}|j�t|d|jd�}|j�|j�dS)NcSs^t|ddddgdddd�}t|j��ttd d
dd��ttd d
ddd��ttd d��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.
Do you believe this?ZYesZNorPr�zTest Dialog)rr)rrrZSpamz Egg count�)r[zEgg weight
(in tons)r�d)rYrZz Egg label�)r�printr<rjrlrq)rrirrr�doit�s
ztest.<locals>.doitZTest)rrZQuit)ZTkr"rr?r:)rrx�t�qrrr�test�sr{)rUrWrrrrCrVrfrjrkrlrmrqr@r{rrrr�<module>s SF
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists