ó |G_Tc@sdZddlmZmZmZmZmZmZmZdd d„ƒYZ e dkr{ddl Z e j ddd ƒndS( sBDefine SearchDialogBase used by Search, Replace, and Grep dialogs.iÿÿÿÿ(tTopleveltFrametEntrytLabeltButtont Checkbuttont RadiobuttontSearchDialogBasecBseZdZdZdZdZd„Zdd„Zdd„Z d„Z d„Z d „Z dd „Z d „Zd „Zd d„Zd„ZRS(sCreate most of a 3 or 4 row, 3 column search dialog. The left and wide middle column contain: 1 or 2 labeled text entry lines (make_entry, create_entries); a row of standard Checkbuttons (make_frame, create_option_buttons), each of which corresponds to a search engine Variable; a row of dialog-specific Check/Radiobuttons (create_other_buttons). The narrow right column contains command buttons (make_button, create_command_buttons). These are bound to functions that execute the command. Except for command buttons, this base class is not limited to items common to all three subclasses. Rather, it is the Find dialog minus the "Find Next" command and its execution function. The other dialogs override methods to replace and add widgets. s Search DialogtSearchicCs||_||_d|_dS(sçInitialize root, engine, and top attributes. top (level widget): set in create_widgets() called from open(). text (Text being searched): set in open(), only used in subclasses(). ent (ry): created in make_entry() called from create_entry(). row (of grid): 0 in create_widgets(), +1 in make_entry/frame(). title (of dialog): class attribute, override in subclasses. icon (of dialog): ditto, use unclear if cannot minimize dialog. N(troottenginetNonettop(tselfR R ((s4/usr/local/lib/python2.7/idlelib/SearchDialogBase.pyt__init__s  cCs©||_|js|jƒn|jjƒ|jjƒ|rh|jjddƒ|jjd|ƒn|jjƒ|jj ddƒ|jj dƒ|jj ƒdS(s6Make dialog visible on top of others and ready to use.itendN( ttextR tcreate_widgetst deiconifyttkraisetenttdeletetinsertt focus_settselection_rangeticursortgrab_set(R Rt searchphrase((s4/usr/local/lib/python2.7/idlelib/SearchDialogBase.pytopen,s      cCs*|jr&|jjƒ|jjƒndS(sPut dialog away for later use.N(R t grab_releasetwithdraw(R tevent((s4/usr/local/lib/python2.7/idlelib/SearchDialogBase.pytclose<s  cCsät|jƒ}|jd|jƒ|jd|jƒ|jd|jƒ|j|jƒ|j|j ƒ||_ d|_ |j j dddddƒ|j j dddd d dd ƒ|j ƒ|jƒ|jƒ|jƒd S( s¹Create basic 3 row x 3 col search (find) dialog. Other dialogs override subsidiary create_x methods as needed. Replace and Find-in-Files add another entry row. sstWM_DELETE_WINDOWitpaditweightitminsizeidN(RR tbindtdefault_commandR tprotocoltwm_titlettitlet wm_iconnameticonR trowtgrid_columnconfiguretcreate_entriestcreate_option_buttonstcreate_other_buttonstcreate_command_buttons(R R ((s4/usr/local/lib/python2.7/idlelib/SearchDialogBase.pyRBs  "   cCs‚t|jd|ƒ}|jd|jddddƒt|jd|ddƒ}|jd|jdd dd ƒ|jd |_|S( sReturn gridded labeled Entry.RR,tcolumnitstickytnwt textvariabletexportselectionitnwe(RR tgridR,R(R tlabeltvartlte((s4/usr/local/lib/python2.7/idlelib/SearchDialogBase.pyt make_entryYs cCs|jd|jjƒ|_dS(s/Create one or more entry lines with make_entry.sFind:N(R=R tpatvarR(R ((s4/usr/local/lib/python2.7/idlelib/SearchDialogBase.pyR.bsc Cs…|r=t|jd|ƒ}|jd|jddddƒnt|jƒ}|jd|jdddddd ƒ|jd|_|S( s9Return gridded labeled Frame for option or other buttons.RR,R2iR3R4it columnspanR7(RR R8R,R(R t labeltextR;tf((s4/usr/local/lib/python2.7/idlelib/SearchDialogBase.pyt make_framefs"%cCsw|jdƒ}t|ddd|jjddƒ}|jddd d ƒ|jjƒre|jƒnt|ddd|jjdd ƒ}|jddd d ƒ|jjƒr»|jƒnt|ddd|jj dd ƒ}|jddd d ƒ|jj ƒr|jƒn|j rst|ddd|jj dd ƒ}|jddd d ƒ|jj ƒrs|jƒqsndS(s?Fill frame with Checkbuttons bound to SearchEngine booleanvars.tOptionstanchortwtvariableRsRegular expressiontsidetlefttfilltboths Match cases Whole words Wrap aroundN(RBRR trevartpacktisretselecttcasevartiscasetwordvartiswordtneedwrapbuttontwrapvartiswrap(R RAtbtn((s4/usr/local/lib/python2.7/idlelib/SearchDialogBase.pyR/ps4            c CsË|jdƒ}t|ddd|jjddddƒ}|jd d d d ƒ|jjƒrk|jƒnt|ddd|jjdd ddƒ}|jd d d d ƒ|jjƒsÇ|jƒndS(s.Fill frame with buttons tied to other options.t DirectionRDRERFtvalueiRtUpRGRHRIRJitDownN(RBRR tbackvarRLtisbackRN(R RARV((s4/usr/local/lib/python2.7/idlelib/SearchDialogBase.pyR0‘s   ic Cst|jd|d|d|r$dp'dƒ}|jjƒ\}}|jddd|d d d d ƒ|jjd |dƒ|S(s/Return command button gridded in command frame.RtcommandtdefaulttactivetnormaltpadyiR,R2iR3tewtrowspan(Rt buttonframet grid_sizeR8(R R9R]tisdeftbtcolstrows((s4/usr/local/lib/python2.7/idlelib/SearchDialogBase.pyt make_button£s  "c Csgt|jƒ}|_|jddddddddddddƒ|jd |jƒ}|jƒd S( s9Place buttons in vertical command frame gridded on right.R,iR2itpadxRatipadxtipadyR N(RR RdR8RjR tlower(R RARg((s4/usr/local/lib/python2.7/idlelib/SearchDialogBase.pyR1­s.N(t__name__t __module__t__doc__R)R+RSRR RR RR=R.RBR/R0RjR1(((s4/usr/local/lib/python2.7/idlelib/SearchDialogBase.pyRs      !  t__main__Ns'idlelib.idle_test.test_searchdialogbaset verbosityi(( RqtTkinterRRRRRRRRRotunittesttmain(((s4/usr/local/lib/python2.7/idlelib/SearchDialogBase.pyts 4¯