a ÕDOgí-ã@s´dZddlTddlmZmZGdd„dƒZGdd„deƒZdd „ZGd d „d eƒZGd d „d eƒZ dd„Z Gdd„deƒZ dd„Z Gdd„deƒZ dd„Zedkr°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ƒ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ú,/usr/lib64/python3.9/tkinter/simpledialog.pyÚ8óz'SimpleDialog.__init__..©rÚcommandé)ZreliefZ borderwidth)Úsider r ÚWM_DELETE_WINDOW)ÚToplevelÚrootÚtitleZiconnameÚ _setup_dialogZMessageÚ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__ s2       ÿ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Úgo\s     zSimpleDialog.gocCs&|jdur|j ¡n | |j¡dSr )r$rÚbellr©rÚeventrrrr&cs  zSimpleDialog.return_eventcCs&|jdur|j ¡n | |j¡dSr )r#rrErrCrrrr,is  zSimpleDialog.wm_delete_windowcCs||_|j ¡dSr )rrÚquitrrrrroszSimpleDialog.done)r3r4) Ú__name__Ú __module__Ú __qualname__r2r-rDr&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 ||¡| ¡|dur>| ¡r>| |¡|rL| |¡t|ƒ||_d|_ t |ƒ}|  |¡|_ |j ddd| ¡|j s–||_ | d|j¡|durÎ| 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Úpadyrr5é2)rrr2r6Zwinfo_viewabler7rrÚparentÚresultr!ÚbodyÚ initial_focusr Ú buttonboxr+r#r;r9r:r<Ú focus_setr?r@Z wait_window)rrQrr.rSrrrr2{s8      ÿ zDialog.__init__cCsd|_t |¡dS)zDestroy the windowN)rTrrBrCrrrrB²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.rrrrSº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$rM)rrNrOÚCancel)rrXrr zN)r!r)ÚokZACTIVEr r*r#r%)rZboxÚwrrrrUÃszDialog.buttonboxcCsJ| ¡s|j ¡dS| ¡| ¡z| ¡W| ¡n | ¡0dSr )ÚvalidaterTrVr6r8Úapplyr#rFrrrrZØs  z Dialog.okcCs |jdur|j ¡| ¡dSr )rQrVrBrFrrrr#æ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 rrCrrrr\ð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. NrrCrrrr]ùsz Dialog.apply)N)N)N) rIrJrKÚ__doc__r2rBrSrUrZr#r\r]rrrrrLts 7    rLcCs:|jdkr |j dd|dd¡n|jdkr6| dd¡dS) NZaquaz!::tk::unsupported::MacWindowStyleÚstyleZ moveableModalrZx11z-typeZdialog)Z_windowingsystemZtkÚcallZ wm_attributes)r[rrrrs   ÿ rc@s.eZdZd dd„Zdd„Zdd„Zdd „ZdS) Ú _QueryDialogNcCs*||_||_||_||_t |||¡dSr )ÚpromptÚminvalueÚmaxvalueÚ initialvaluerLr2)rrrbrercrdrQrrrr2s z_QueryDialog.__init__cCsd|_t |¡dSr )ÚentryrLrBrCrrrrBsz_QueryDialog.destroycCsrt||jtd}|jddtdt|dd|_|jjddttd|jdurl|j  d|j¡|j  dt ¡|jS)N)rZjustifyrrM)ÚrowrNZstickyrf)Únamer ) ZLabelrbr*ZgridÚWZEntryrfÚEreÚinsertZ select_rangeZEND)rr.r[rrrrS s z_QueryDialog.bodycCsžz | ¡}Wn*ty6tjd|jd|dYdS0|jdurf||jkrftjdd|j|ddS|jdur”||jkr”tjdd|j|ddS||_d S) Nz Illegal valuez Please try again)rQrz 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Ú errormessagercrdrR)rrRrrrr\.s:  ýÿüÿüz_QueryDialog.validate)NNNN)rIrJrKr2rBrSr\rrrrra sý rac@seZdZdZdd„ZdS)Ú _QueryIntegerzNot an integer.cCs| |j ¡¡Sr )ZgetintrfÚgetrCrrrrlSsz_QueryInteger.getresultN©rIrJrKrorlrrrrrpPsrpcKst||fi|¤Ž}|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 )rprR©rrbÚkwÚdrrrÚ askintegerWs rvc@seZdZdZdd„ZdS)Ú _QueryFloatzNot a floating point value.cCs| |j ¡¡Sr )Z getdoublerfrqrCrrrrlisz_QueryFloat.getresultNrrrrrrrwfsrwcKst||fi|¤Ž}|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 )rwrRrsrrrÚaskfloatms rxc@s$eZdZdd„Zdd„Zdd„ZdS)Ú _QueryStringcOs<d|vr|d|_|d=nd|_tj|g|¢Ri|¤ŽdS)NÚshow)Ú_QueryString__showrar2)rÚargsrtrrrr2}s  z_QueryString.__init__cCs(t ||¡}|jdur$|j|jd|S)N)rz)rarSr{Z configure)rr.rfrrrrS…s  z_QueryString.bodycCs |j ¡Sr )rfrqrCrrrrl‹sz_QueryString.getresultN)rIrJrKr2rSrlrrrrry|srycKst||fi|¤Ž}|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 )ryrRrsrrrÚ askstrings r}Ú__main__cCsLtƒ}|fdd„}t|d|d}| ¡t|d|jd}| ¡| ¡dS)NcSs\t|dgd¢dddd}t| ¡ƒttddd d ƒttdd d 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. Do you believe this?)ZYesZNorYréz Test Dialog)rr/r$r#rZSpamz Egg counté)rezEgg weight (in tons)r éd)rcrdz Egg label)rÚprintrDrvrxr})rrurrrÚdoit¢s÷  ÿztest..doitZTestrZQuit)ZTkr)r rHrA)rrƒÚtÚqrrrÚtest s r†N)r^ÚtkinterrrrrrLrrarprvrwrxryr}rIr†rrrrÚ s V C