B À}TÅ€~ ²ã@s°dZddlTddlmZddlZGdd„dƒZGdd„deƒZGd d „d eƒZGd d „d eƒZd d„ZGdd„deƒZ dd„Z Gdd„deƒZ dd„Z e 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 „Zd d „Zd d„Zdd„ZdS)Ú SimpleDialogÚNc Cs|rt||d|_n t|ƒ|_|r:|j |¡|j |¡t|j|dd|_|jjdtdt|jƒ|_ |j  ¡||_ ||_ ||_ |j  d|j¡x\tt|ƒƒD]L}||} t|j | ||fdd„d } ||krÞ| jtd d | jttdd q¢W|j d |j¡| |¡dS)N)Úclass_i)ÚtextZaspecté)ÚexpandÚfillzcSs | |¡S)N)Údone)ÚselfÚnum©rú9/opt/alt/python37/lib64/python3.7/tkinter/simpledialog.pyÚ6óz'SimpleDialog.__init__..)rÚcommandé)ZreliefZ borderwidth)Úsider r ÚWM_DELETE_WINDOW)ÚToplevelÚrootÚtitleZiconnameZMessageÚmessageÚpackZBOTHÚFrameÚframer ÚcancelÚdefaultÚbindÚ return_eventÚrangeÚlenÚButtonZconfigZRIDGEÚLEFTÚprotocolÚwm_delete_windowÚ_set_transient) r ÚmasterrÚbuttonsrrrrr ÚsÚbrrrÚ__init__!s.     zSimpleDialog.__init__çà?ç333333Ó?c Cs|j}| ¡| |¡| ¡| ¡rJ| ¡}| ¡}| ¡}| ¡}n|  ¡}|  ¡}d}}|  ¡} |  ¡} ||| |} ||| |} | | |  ¡kr°|  ¡| } n | dkr¼d} | | |  ¡krÚ|  ¡| } n | dkræd} |  d| | f¡| ¡dS)Nrz+%d+%d)rÚwithdrawÚ transientÚupdate_idletasksZwinfo_ismappedZ winfo_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.|j ¡|j ¡|j ¡|j ¡|jS)N)rÚwait_visibilityÚgrab_setÚmainloopÚdestroyr )r rrrÚgoZs     zSimpleDialog.gocCs&|jdkr|j ¡n | |j¡dS)N)rrÚbellr )r Úeventrrrr as  zSimpleDialog.return_eventcCs&|jdkr|j ¡n | |j¡dS)N)rrr=r )r rrrr&gs  zSimpleDialog.wm_delete_windowcCs||_|j ¡dS)N)r rÚquit)r r rrrr mszSimpleDialog.done)r-r.) Ú__name__Ú __module__Ú __qualname__r,r'r<r r&r rrrrrs rc@sVeZdZdZddd„Zdd„Zdd„Zd d „Zdd d „Zdd d„Z dd„Z dd„Z dS)ÚDialogzZClass to open dialogs. This class is intended as a base class for custom dialogs NcCsàt ||¡| ¡| ¡r&| |¡|r4| |¡||_d|_t|ƒ}|  |¡|_ |j ddd|  ¡|j sv||_ |  d|j¡|jdk r°| d| ¡d| ¡df¡| ¡|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_setr8r9Z wait_window)r rHrrJrrrr,ys.      zDialog.__init__cCsd|_t |¡dS)zDestroy the windowN)rKrr;)r rrrr;«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)r r(rrrrJ³sz Dialog.bodycCsvt|ƒ}t|dd|jtd}|jtdddt|dd|jd}|jtddd| d|j¡| d |j¡| ¡d S) z[add standard button box. override if you do not want the standard buttons ZOKé )rÚwidthrrrD)rrErFÚCancel)rrOrzzN)rr#ÚokZACTIVErr$rr)r ZboxÚwrrrrL¼szDialog.buttonboxcCsB| ¡s|j ¡dS| ¡| ¡z | ¡Wd| ¡XdS)N)ÚvalidaterKrMr/r1Úapplyr)r r>rrrrQÑs  z Dialog.okcCs |jdk r|j ¡| ¡dS)N)rHrMr;)r r>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)r rrrrSé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 rrrrTòsz Dialog.apply)N)N)N) r@rArBÚ__doc__r,r;rJrLrQrrSrTrrrrrCrs 2    rCc@s.eZdZd dd„Zdd„Zdd„Zdd „ZdS) Ú _QueryDialogNcCs4|s tj}||_||_||_||_t |||¡dS)N)ÚtkinterZ _default_rootÚpromptÚminvalueÚmaxvalueÚ initialvaluerCr,)r rrXr[rYrZrHrrrr,sz_QueryDialog.__init__cCsd|_t |¡dS)N)ÚentryrCr;)r rrrr;sz_QueryDialog.destroycCsrt||jtd}|jddtdt|dd|_|jjddttd|jdk rl|j  d|j¡|j  dt ¡|jS)N)rZjustifyrrD)ÚrowrEZstickyr\)Únamer) ZLabelrXr$ZgridÚWZEntryr\ÚEr[ÚinsertZ select_rangeZEND)r r(rRrrrrJs z_QueryDialog.bodycCsžy | ¡}Wn*tk r6tjd|jd|ddSX|jdk rf||jkrftjdd|j|ddS|jdk r”||jkr”tjdd|j|ddS||_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)r rIrrrrS#s0 z_QueryDialog.validate)NNNN)r@rArBr,r;rJrSrrrrrVÿs  rVc@seZdZdZdd„ZdS)Ú _QueryIntegerzNot an integer.cCs| |j ¡¡S)N)Zgetintr\Úget)r rrrrbGsz_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Ú askintegerJs rjc@seZdZdZdd„ZdS)Ú _QueryFloatzNot a floating point value.cCs| |j ¡¡S)N)Z getdoubler\rg)r rrrrbZsz_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]s rlc@s$eZdZdd„Zdd„Zdd„ZdS)Ú _QueryStringcOs6d|kr|d|_|d=nd|_tj|f|ž|ŽdS)NÚshow)Ú_QueryString__showrVr,)r Úargsrhrrrr,ls  z_QueryString.__init__cCs(t ||¡}|jdk r$|j|jd|S)N)rn)rVrJroZ configure)r r(r\rrrrJts  z_QueryString.bodycCs |j ¡S)N)r\rg)r rrrrbzsz_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}s rqÚ__main__cCsLtƒ}|fdd„}t|d|d}| ¡t|d|jd}| ¡| ¡dS)NcSs^t|ddddgdddd}t| ¡ƒttd d d d ƒ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éz Test Dialog)rr)rrrZSpamz Egg counté)r[zEgg weight (in tons)réd)rYrZz Egg label)rÚprintr<rjrlrq)rrirrrÚdoit‘s   ztest..doitZTest)rrZQuit)ZTkr#rr?r:)rrwÚtÚqrrrÚtests rz)rUrWrrrrCrVrfrjrkrlrmrqr@rzrrrrÚs  SF