U Ä:âe¶,ã@s¬dZddlTddlmZmZGdd„dƒZGdd„deƒZGdd „d eƒZGd d „d eƒZd d „Z Gdd„deƒZ dd„Z Gdd„deƒZ dd„Z edkr¨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 é)Ú*)Ú messageboxÚ_get_default_rootc@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¡tt|ƒƒD]L}||} t|j | ||fdd„d } ||krÜ| jtd d | jttdd q |j d |j¡| |¡dS)N)Úclass_i)ÚtextZaspecté)ÚexpandÚfillúcSs | |¡S©N)Údone©ÚselfÚnum©rú9/usr/local/python38/lib/python3.8/tkinter/simpledialog.pyÚ5ó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Úbuttonsr#r"rrrÚsÚbrrrÚ__init__ s0      ÿzSimpleDialog.__init__çà?ç333333Ó?c Cs|j}| ¡| |¡| ¡| ¡rJ| ¡}| ¡}| ¡}| ¡}n|  ¡}|  ¡}d}}|  ¡} |  ¡} ||| |} ||| |} | | |  ¡kr°|  ¡| } n | dkr¼d} | | |  ¡krÚ|  ¡| } n | dkræd} |  d| | f¡| ¡dS)Nrú+%d+%d)rÚwithdrawÚ transientÚupdate_idletasksZwinfo_ismappedZ winfo_widthZ winfo_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.|j ¡|j ¡|j ¡|j ¡|jSr )rÚwait_visibilityÚgrab_setÚmainloopÚdestroyr©rrrrÚgoYs     zSimpleDialog.gocCs&|jdkr|j ¡n | |j¡dSr )r#rÚbellr©rÚeventrrrr%`s  zSimpleDialog.return_eventcCs&|jdkr|j ¡n | |j¡dSr )r"rrDrrBrrrr+fs  zSimpleDialog.wm_delete_windowcCs||_|j ¡dSr )rrÚquitrrrrrlszSimpleDialog.done)r2r3) Ú__name__Ú __module__Ú __qualname__r1r,rCr%r+rrrrrrsþ  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ö|}|stdƒ}t ||¡| ¡|dk r>| ¡r>| |¡|rL| |¡||_d|_t |ƒ}|  |¡|_ |j ddd|  ¡|j sŽ||_ | d|j¡|dk rÆ| d| ¡d| ¡df¡| ¡|j  ¡| ¡| ¡| |¡dS)z˜Initialize a dialog. Arguments: parent -- a parent window (the application window) title -- the dialog title zcreate dialog windowNé)ÚpadxÚpadyrr4é2)rrr1r5Zwinfo_viewabler6rÚparentÚresultr ÚbodyÚ initial_focusrÚ buttonboxr*r"r:r8r9r;Ú focus_setr>r?Z wait_window)rrPrr-rRrrrr1xs6      ÿ zDialog.__init__cCsd|_t |¡dS)zDestroy the windowN)rSrrArBrrrrA­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-rrrrRµ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Úwidthrr#rL)rrMrNÚCancel)rrWrr zN)r r(ÚokZACTIVErr)r"r$)rZboxÚwrrrrT¾szDialog.buttonboxcCsB| ¡s|j ¡dS| ¡| ¡z | ¡W5| ¡XdSr )ÚvalidaterSrUr5r7r"ÚapplyrErrrrYÓs  z Dialog.okcCs |jdk r|j ¡| ¡dSr )rPrUrArErrrr"á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. r rrBrrrr[ë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. NrrBrrrr\ôsz Dialog.apply)N)N)N) rHrIrJÚ__doc__r1rArRrTrYr"r[r\rrrrrKqs 5    rKc@s.eZdZd dd„Zdd„Zdd„Zdd „ZdS) Ú _QueryDialogNcCs*||_||_||_||_t |||¡dSr )ÚpromptÚminvalueÚmaxvalueÚ initialvaluerKr1)rrr_rbr`rarPrrrr1s z_QueryDialog.__init__cCsd|_t |¡dSr )ÚentryrKrArBrrrrAsz_QueryDialog.destroycCsrt||jtd}|jddtdt|dd|_|jjddttd|jdk rl|j  d|j¡|j  dt ¡|jS)N)rZjustifyrrL)ÚrowrMZstickyrc)Únamer ) ZLabelr_r)ZgridÚWZEntryrcÚErbÚinsertZ select_rangeZEND)rr-rZrrrrRs z_QueryDialog.bodycCs z | ¡}Wn,tk r8tjd|jd|dYdSX|jdk rh||jkrhtjdd|j|ddS|jdk r–||jkr–tjdd|j|ddS||_d S) Nz Illegal valuez Please try again)rPrz 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Ú errormessager`rarQ)rrQrrrr["s: ýÿüÿüz_QueryDialog.validate)NNNN)rHrIrJr1rArRr[rrrrr^sý r^c@seZdZdZdd„ZdS)Ú _QueryIntegerzNot an integer.cCs| |j ¡¡Sr )ZgetintrcÚgetrBrrrriGsz_QueryInteger.getresultN©rHrIrJrlrirrrrrmDsrmcKst||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 )rmrQ©rr_ÚkwÚdrrrÚ askintegerKs rsc@seZdZdZdd„ZdS)Ú _QueryFloatzNot a floating point value.cCs| |j ¡¡Sr )Z getdoublercrnrBrrrri]sz_QueryFloat.getresultNrorrrrrtZsrtcKst||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 )rtrQrprrrÚaskfloatas ruc@s$eZdZdd„Zdd„Zdd„ZdS)Ú _QueryStringcOs6d|kr|d|_|d=nd|_tj|f|ž|ŽdS)NÚshow)Ú_QueryString__showr^r1)rÚargsrqrrrr1qs  z_QueryString.__init__cCs(t ||¡}|jdk r$|j|jd|S)N)rw)r^rRrxZ configure)rr-rcrrrrRys  z_QueryString.bodycCs |j ¡Sr )rcrnrBrrrrisz_QueryString.getresultN)rHrIrJr1rRrirrrrrvpsrvcKst||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 )rvrQrprrrÚ askstringƒs rzÚ__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?ZYesZNorXréz Test Dialog)rr.r#r"rZSpamz Egg counté)rbzEgg weight (in tons)r éd)r`raz Egg label)rÚprintrCrsrurz)rrrrrrÚdoit–s÷  ÿztest..doitZTestrZQuit)ZTkr(rrGr@)rr€ÚtÚqrrrÚtest”s rƒN)r]ÚtkinterrrrrrKr^rmrsrtrurvrzrHrƒrrrrÚ sSC