3 2a\ @sddlmZddlmZddlmZddZddZdd Zd d Z Gd d d eZ ddZ e dkrddl mZeddddddlmZee dS))TclError) searchengine)SearchDialogBasecCs.|j}tj|}t|ds(t|||_|jS)N _searchdialog)Z_rootrgethasattr SearchDialogr)textrootenginer +/opt/alt/python36/lib64/python3.6/search.py_setups    rcCs|jdd}t|j||S)Nz sel.firstzsel.last)rropen)r patr r r finds rcCst|j|S)N)r find_again)r r r r rsrcCst|j|S)N)rfind_selection)r r r r rsrc@s.eZdZddZd ddZddZdd ZdS) rcCstj||jd|jddS)Nz Find Next)rcreate_widgetsZ make_buttondefault_command)selfr r r rs zSearchDialog.create_widgetsNcCs|jjsdS|j|jdS)N)r getprogrr )rZeventr r r r"s zSearchDialog.default_commandc Cs|jjs|j|dS|jjs&dS|jj|}|r|\}}|j\}}d||f}d||f}y4|jd} |jd} | |kr| |kr|jdSWntk rYnX|j ddd|j d|||j d|jj r|p||j dd S|jdSdS) NFz%d.%dz sel.firstzsel.lastselz1.0endinsertT)r ZgetpatrrZ search_textspanindexZbellr tag_removetag_addZmark_setZisbackZsee) rr reslinemijfirstZlastZselfirstZsellastr r r r's4          zSearchDialog.find_againcCs&|jdd}|r|jj||j|S)Nz sel.firstzsel.last)rr Z setcookedpatr)rr rr r r rDs  zSearchDialog.find_selection)N)__name__ __module__ __qualname__rrrrr r r r rs rc sddlm}m}ddlm}||}|jdtt|jj ddd\}}|jd||df||d d j j d d d fdd}||d|d}|j dS)Nr)ToplevelText)ButtonzTest SearchDialog+rz+%d+%dZgray)ZinactiveselectbackgroundrzThis is a sample string. cs.jdddtjjddddS)Nrz1.0r)rrrrr )r r r show_findXsz!_search_dialog..show_findzSearch (selection ignored))r Zcommand) tkinterr)r*Z tkinter.ttkr+titlemapintZgeometrysplitpackr) parentr)r*r+Zboxxyr/Zbuttonr )r r _search_dialogKs     r9__main__)mainzidlelib.idle_test.test_searchF) verbosityexit)runN)r0rZidlelibrZidlelib.searchbaserrrrrrr9r&Zunittestr;Zidlelib.idle_test.htestr?r r r r s   /