³ò  Z]Gc @s dZddkTddkZdefd„ƒYZdefd„ƒYZdefd „ƒYZd „Zd efd „ƒYZd „Z defd„ƒYZ d„Z e djoSe ƒZeiƒeddddƒGHe ddddddƒGHe ddƒGHndS(súDialog boxes This module handles dialog boxes. It contains the following public symbols: 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 iÿÿÿÿ(t*NtDialogcBs_eZdZd d„Zd„Zd„Zd„Zd d„Zd d„Z d„Z d„Z RS( sZClass to open dialogs. This class is intended as a base class for custom dialogs cCs1ti||ƒ|iƒo|i|ƒn|o|i|ƒn||_d|_t|ƒ}|i |ƒ|_ |i ddddƒ|i ƒ|i ƒ|iƒ|i p ||_ n|id|iƒ|idj o/|id|iƒd|iƒdfƒn|i iƒ|i|ƒdS(s˜Initialize a dialog. Arguments: parent -- a parent window (the application window) title -- the dialog title tpadxitpadytWM_DELETE_WINDOWs+%d+%di2N(tToplevelt__init__twinfo_viewablet transientttitletparenttNonetresulttFrametbodyt initial_focustpackt buttonboxtwait_visibilitytgrab_settprotocoltcanceltgeometryt winfo_rootxt winfo_rootyt focus_sett wait_window(tselfR R R((stkSimpleDialog.pycR&s*           cCsd|_ti|ƒdS(sDestroy the windowN(R RRtdestroy(R((stkSimpleDialog.pycRUs cCsdS(s«create dialog body. return widget that should have initial focus. This method should be overridden, and is called by the __init__ method. N((Rtmaster((stkSimpleDialog.pycR]sc CsÀt|ƒ}t|ddddd|idtƒ}|idtdd d d ƒt|dd ddd|iƒ}|idtdd d d ƒ|id |iƒ|id |iƒ|iƒdS(s[add standard button box. override if you do not want the standard buttons ttexttOKtwidthi tcommandtdefaulttsideRiRtCancelssN(R tButtontoktACTIVERtLEFTRtbind(Rtboxtw((stkSimpleDialog.pycRfs '!cCsV|iƒp|iiƒdSn|iƒ|iƒz|iƒWd|iƒXdS(N(tvalidateRRtwithdrawtupdate_idletaskstapplyR(Rtevent((stkSimpleDialog.pycR&{s    cCs/|idj o|iiƒn|iƒdS(N(R R RR(RR0((stkSimpleDialog.pycR‰scCsdS(s¨validate the data This method is called automatically to validate the data before the dialog is destroyed. By default, it always validates OK. i((R((stkSimpleDialog.pycR,“scCsdS(s¡process the data This method is called automatically to process the data, *after* the dialog is destroyed. By default, it does nothing. N((R((stkSimpleDialog.pycR/œsN( t__name__t __module__t__doc__R RRRRR&RR,R/(((stkSimpleDialog.pycRs /    t _QueryDialogcBs8eZddddd„Zd„Zd„Zd„ZRS(cCs[|pddk}|i}n||_||_||_||_ti|||ƒdS(Niÿÿÿÿ(tTkintert _default_roottprompttminvaluetmaxvaluet initialvalueRR(RR R7R:R8R9R R5((stkSimpleDialog.pycR«s      cCsd|_ti|ƒdS(N(R tentryRR(R((stkSimpleDialog.pycR¼s cCs­t|d|idtƒ}|idddddtƒt|dd ƒ|_|iidd dddttƒ|io-|ii d|iƒ|ii dt ƒn|iS( NRtjustifytrowiRitstickytnameR;i( tLabelR7R(tgridtWtEntryR;tER:tinsertt select_rangetEND(RRR+((stkSimpleDialog.pycRÀs# c Csêddk}y|iƒ}Wn4tj o(|id|idd|ƒdSnX|idj o5||ijo%|idd|id|ƒdSn|idj o5||ijo%|idd |id|ƒdSn||_d S( Niÿÿÿÿs Illegal values Please try againR is Too smalls2The allowed minimum value is %s. Please try again.s Too larges2The allowed maximum value is %s. Please try again.i( t tkMessageBoxt getresultt ValueErrort showwarningt errormessageR8R R9R (RRHR ((stkSimpleDialog.pycR,Îs2        N(R1R2R RRRR,(((stkSimpleDialog.pycR4©s    t _QueryIntegercBseZdZd„ZRS(sNot an integer.cCst|iiƒƒS(N(tintR;tget(R((stkSimpleDialog.pycRIõs(R1R2RLRI(((stkSimpleDialog.pycRMóscKst|||}|iS(s¼get an integer from the user Arguments: title -- the dialog title prompt -- the label text **kw -- see SimpleDialog class Return value is an integer (RMR (R R7tkwtd((stkSimpleDialog.pyct askintegerøs t _QueryFloatcBseZdZd„ZRS(sNot a floating point value.cCst|iiƒƒS(N(tfloatR;RO(R((stkSimpleDialog.pycRIs(R1R2RLRI(((stkSimpleDialog.pycRSscKst|||}|iS(s¶get a float from the user Arguments: title -- the dialog title prompt -- the label text **kw -- see SimpleDialog class Return value is a float (RSR (R R7RPRQ((stkSimpleDialog.pyctaskfloat s t _QueryStringcBs#eZd„Zd„Zd„ZRS(cOsH|idƒo|d|_|d=n d|_ti|||ŽdS(Ntshow(thas_keyt_QueryString__showR R4R(RtargsRP((stkSimpleDialog.pycRs    cCs=ti||ƒ}|idj o|id|iƒn|S(NRW(R4RRYR t configure(RRR;((stkSimpleDialog.pycR"scCs |iiƒS(N(R;RO(R((stkSimpleDialog.pycRI(s(R1R2RRRI(((stkSimpleDialog.pycRVs  cKst|||}|iS(s¸get a string from the user Arguments: title -- the dialog title prompt -- the label text **kw -- see SimpleDialog class Return value is a string (RVR (R R7RPRQ((stkSimpleDialog.pyct askstring+s t__main__tSpams Egg countR:i sEgg weight (in tons)R8iR9ids Egg labeli(R3R5tosRRR4RMRRRSRURVR\R1tTktroottupdate(((stkSimpleDialog.pycss   ŠJ