ó {fc@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(syCreate 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, its execution function, and the default_command attribute needed in create_widgets. The other dialogs override attributes and methods, the latter 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 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(). default_command: set in subclasses, used in create_widgers(). title (of dialog): class attribute, override in subclasses. icon (of dialog): ditto, use unclear if cannot minimize dialog. N(troottenginetNonettop(tselfR R ((s0/usr/lib64/python2.7/idlelib/SearchDialogBase.pyt__init__s  cCs¿||_|js|jƒn|jjƒ|jjƒ|jj|jƒƒ|r~|jjddƒ|jj d|ƒn|jj ƒ|jj ddƒ|jj dƒ|jj ƒdS(s6Make dialog visible on top of others and ready to use.itendN(ttextR tcreate_widgetst deiconifyttkraiset transienttwinfo_topleveltenttdeletetinsertt focus_settselection_rangeticursortgrab_set(R Rt searchphrase((s0/usr/lib64/python2.7/idlelib/SearchDialogBase.pytopen/s      cCs:|jr6|jjƒ|jjdƒ|jjƒndS(sPut dialog away for later use.tN(R t grab_releaseRtwithdraw(R tevent((s0/usr/lib64/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 ((s0/usr/lib64/python2.7/idlelib/SearchDialogBase.pyRGs  "   cCsˆt|jd|ƒ}|jd|jddddƒt|jd|ddƒ}|jd|jdd dd ƒ|jd |_||fS( sŒReturn (entry, label), . entry - gridded labeled Entry for text entry. label - Label widget, returned for testing. RR/tcolumnitstickytnwt textvariabletexportselectionitnwe(RR tgridR/R(R t label_texttvartlabeltentry((s0/usr/lib64/python2.7/idlelib/SearchDialogBase.pyt make_entry^s cCs#|jd|jjƒd|_dS(s/Create one or more entry lines with make_entry.sFind:iN(R@R tpatvarR(R ((s0/usr/lib64/python2.7/idlelib/SearchDialogBase.pyR1ksc Cs‘|r=t|jd|ƒ}|jd|jddddƒnd}t|jƒ}|jd|jddd ddd ƒ|jd|_||fS( s—Return (frame, label). frame - gridded labeled Frame for option or other buttons. label - Label widget, returned for testing. RR/R5iR6R7Rit columnspanR:(RR R;R/R(R t labeltextR>tframe((s0/usr/lib64/python2.7/idlelib/SearchDialogBase.pyt make_frameos"%c CsÖ|jdƒd}|j}|jdf|jdf|jdfg}|jrh|j|jdfƒnxa|D]Y\}}t|ddd |d |ƒ}|j d d d dƒ|j ƒro|j ƒqoqoW||fS(sReturn (filled frame, options) for testing. Options is a list of SearchEngine booleanvar, label pairs. A gridded frame from make_frame is filled with a Checkbutton for each pair, bound to the var, with the corresponding label. tOptionsisRegular expressions Match cases Whole words Wrap aroundtanchortwtvariableRtsidetlefttfilltboth( RER trevartcasevartwordvartneedwrapbuttontappendtwrapvarRtpacktgettselect(R RDR toptionsR=R>tbtn((s0/usr/lib64/python2.7/idlelib/SearchDialogBase.pyR2s     c Cs¥|jdƒd}|jj}ddg}xm|D]e\}}t|ddd|d |d |ƒ}|jd d d dƒ|jƒ|kr2|jƒq2q2W||fS(s£Return (frame, others) for testing. Others is a list of value, label pairs. A gridded frame from make_frame is filled with radio buttons. t DirectioniitUptDownRGRHRItvalueRRJRKRLRM(iRZ(iR[(RER tbackvarRRTRURV(R RDR=totherstvalR>RX((s0/usr/lib64/python2.7/idlelib/SearchDialogBase.pyR3”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/R5iR6tewtrowspan(Rt buttonframet grid_sizeR;(R R>R`tisdeftbtcolstrows((s0/usr/lib64/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/iR5itpadxRdtipadxtipadyR#N(RR RgR;RmR#tlower(R tfRj((s0/usr/lib64/python2.7/idlelib/SearchDialogBase.pyR4¯s.N(t__name__t __module__t__doc__R,R.RQRR RR#RR@R1RER2R3RmR4(((s0/usr/lib64/python2.7/idlelib/SearchDialogBase.pyRs         t__main__Ns'idlelib.idle_test.test_searchdialogbaset verbosityi(( RutTkinterRRRRRRRRRstunittesttmain(((s0/usr/lib64/python2.7/idlelib/SearchDialogBase.pyts 4±