o ­=?hé-ã@sÎdZddlTddlmZmZddlmZGdd„dƒZGdd„deƒZdd d „Zd d „Z Gdd„deƒZ Gdd„de ƒZ dd„Z Gdd„de ƒZ dd„ZGdd„de ƒZdd„Zedkredd„Zeƒd Sd S) 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 é)Ú*)Ú_get_temp_rootÚ_destroy_temp_root)Ú messageboxc@sBeZdZdgddddfdd„Zdd„Zdd„Zd d „Zd d „ZdS) Ú SimpleDialogÚNc Cs$|r t||d|_nt|ƒ|_|r|j |¡|j |¡t|jƒt|j|dd|_|jjdtdt |jƒ|_ |j  ¡||_ ||_ ||_ |j d|j¡tt|ƒƒD]&}||} t|j | ||fdd„d } ||krs| jtd d | jttdd qU|j d |j¡|j |¡t|j|ƒdS)N)Úclass_i)ÚtextZaspecté)ÚexpandÚfillúcSs | |¡S©N)Údone©ÚselfÚnum©rú;/opt/alt/python310/lib64/python3.10/tkinter/simpledialog.pyÚ9s 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Ú transientÚ _place_window) rÚmasterr Úbuttonsr$r#rrrÚsÚbrrrÚ__init__!s4       ÿ zSimpleDialog.__init__cCs.|j ¡|j ¡|j ¡|j ¡|jSr)rÚwait_visibilityÚgrab_setÚmainloopÚdestroyr©rrrrÚgoAs    zSimpleDialog.gocCó(|jdur |j ¡dS| |j¡dSr)r$rÚbellr©rZeventrrrr&Hó zSimpleDialog.return_eventcCr:r)r#rr;rr8rrrr,Nr=zSimpleDialog.wm_delete_windowcCs||_|j ¡dSr)rrÚquitrrrrrTózSimpleDialog.done)Ú__name__Ú __module__Ú __qualname__r3r9r&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Ü|}|dur tƒ}t ||¡| ¡|dur | ¡r | |¡|r'| |¡t|ƒ||_d|_ t |ƒ}|  |¡|_ |j ddd| ¡|j durN||_ | d|j¡t||ƒ|j  ¡| ¡| ¡| |¡dS)z˜Initialize a dialog. Arguments: parent -- a parent window (the application window) title -- the dialog title Né)ÚpadxÚpadyr)rrr3ÚwithdrawZwinfo_viewabler-rrÚparentÚresultr!ÚbodyÚ initial_focusr Ú buttonboxr+r#r.Ú focus_setr4r5Z wait_window)rrHrr/rJrrrr3`s0        zDialog.__init__cCsd|_t |¡t|jƒdS)zDestroy the windowN)rKrr7rr/r8rrrr7“s zDialog.destroycCódS)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œóz 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$rD)rrErFÚCancel)r rQrr zN)r!r)ÚokZACTIVEr r*r#r%)rZboxÚwrrrrL¥s zDialog.buttonboxcCsH| ¡s |j ¡dS| ¡| ¡z | ¡W| ¡dS| ¡wr)ÚvalidaterKrMrGÚupdate_idletasksÚapplyr#r<rrrrSºs  z Dialog.okcCs |jdur |j ¡| ¡dSr)rHrMr7r<rrrr#Ès   z Dialog.cancelcCrN)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 rr8rrrrUÒrOzDialog.validatecCrN)z¡process the data This method is called automatically to process the data, *after* the dialog is destroyed. By default, it does nothing. Nrr8rrrrWÛrOz Dialog.applyr) r@rArBÚ__doc__r3r7rJrLrSr#rUrWrrrrrCYs 3    rCNc Cs| ¡| ¡| ¡}| ¡}| ¡}| ¡}|durg| ¡rg| ¡| ¡|d}|  ¡|  ¡|d}|  ¡}|  ¡} t ||||ƒ}t||ƒ}t || ||ƒ}t|| ƒ}|jdkrft|dƒ}n| ¡|d}| ¡|d}| ||¡| d||f¡| ¡dS)NéÚaquaéz+%d+%d)Z wm_withdrawrVZwinfo_reqwidthZwinfo_reqheightZwinfo_vrootwidthZwinfo_vrootheightZwinfo_ismappedZ winfo_rootxZ winfo_widthZ winfo_rootyZ winfo_heightZ winfo_vrootxZ winfo_vrootyÚminÚmaxÚ_windowingsystemZwinfo_screenwidthZwinfo_screenheightZ wm_maxsizeZ wm_geometryZ wm_deiconify) rTrHZminwidthZ minheightZmaxwidthZ maxheightÚxÚyZvrootxZvrootyrrrr.çs.    €  r.cCs@|jdkr|j dd|dd¡dS|jdkr| dd¡dSdS) NrZz!::tk::unsupported::MacWindowStyleZstyleZ moveableModalrZx11z-typeZdialog)r^ZtkZcallZ wm_attributes)rTrrrrs  ÿ ÿrc@s4eZdZ   d dd„Zdd„Zdd„Zdd „ZdS) Ú _QueryDialogNcCs*||_||_||_||_t |||¡dSr)ÚpromptÚminvalueÚmaxvalueÚ initialvaluerCr3)rrrbrercrdrHrrrr3s z_QueryDialog.__init__cCsd|_t |¡dSr)ÚentryrCr7r8rrrr7r?z_QueryDialog.destroycCsrt||jtd}|jddtdt|dd|_|jjddttd|jdur6|j  d|j¡|j  dt ¡|jS)N)r ZjustifyrrD)ÚrowrEZstickyrf)Únamer ) ZLabelrbr*ZgridÚWZEntryrfÚEreÚinsertZ select_rangeZEND)rr/rTrrrrJ!s z_QueryDialog.bodycCsžz| ¡}Wntytjd|jd|dYdSw|jdur3||jkr3tjdd|j|ddS|jdurJ||jkrJtjdd|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Ú errormessagercrdrI)rrIrrrrU/s<  ýúÿüÿüz_QueryDialog.validate)NNNN)r@rArBr3r7rJrUrrrrras ý  rac@óeZdZdZdd„ZdS)Ú _QueryIntegerzNot an integer.cCó| |j ¡¡Sr)ZgetintrfÚgetr8rrrrlTóz_QueryInteger.getresultN©r@rArBrorlrrrrrqQó rqcKót||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 )rqrI©rrbÚkwÚdrrrÚ askintegerXó r{c@rp)Ú _QueryFloatzNot a floating point value.cCrrr)Z getdoublerfrsr8rrrrljrtz_QueryFloat.getresultNrurrrrr}grvr}cKrw)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 )r}rIrxrrrÚaskfloatnr|r~c@s$eZdZdd„Zdd„Zdd„ZdS)Ú _QueryStringcOs<d|vr |d|_|d=nd|_tj|g|¢Ri|¤ŽdS)NÚshow)Ú_QueryString__showrar3)rÚargsryrrrr3~s  z_QueryString.__init__cCs(t ||¡}|jdur|j|jd|S)N)r€)rarJrZ configure)rr/rfrrrrJ†s  z_QueryString.bodycCs |j ¡Sr)rfrsr8rrrrlŒs z_QueryString.getresultN)r@rArBr3rJrlrrrrr}s rcKrw)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 )rrIrxrrrÚ askstringr|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?)ZYesZNorRrrYz Test Dialog)r r0r$r#rZSpamz Egg counté)rezEgg weight (in tons)r éd)rcrdz Egg label)rÚprintr9r{r~rƒ)rrzrrrÚdoit£s÷  ÿztest..doitZTestrZQuit)ZTkr)r r>r6)rrˆÚtÚqrrrÚtest¡s  r‹r)rXZtkinterrrrrrrCr.rrarqr{r}r~rrƒr@r‹rrrrÚs(  :  C æ