title: Mini Search engine Python(File finder and keyword finder)
body: <p>I'm working on a search engine but I'm facing problems,I want like words from notepad to show on my 'search results', but it's not showing anything, and if you could help me doing like how many times the keyword that I'm searching for got repeated I would appreciate it  this is the code:</p>
  <pre><code>from tkinter import *
  import os
  from tkinter.filedialog import askdirectory
  from tkinter import messagebox
  import subprocess 
  def content_analyser(pat):
      with open(pat,'r') as f:
         try:
          for line in f:
              if search in line:
                  d.update()
                  d.insert(END, pat)
                  break
      except:
          pass
  def smali_finder(pat):
  
      
  try:
      for file in os.listdir(pat):
          spat=pat+'/'+file 
          if os.path.isdir(spat):
              smali_finder(spat)
          else:
              if file.endswith(&quot;.smali&quot;):
                  content_analyser(spat)
  except Exception as e:    
      print (&quot;Error:::&quot;,pat,e)
  def fing(path):
   global search
   if search_word.get()=='':
       var=messagebox.showwarning(message=&quot;Please a search word&quot;)
      
  else:
      search=search_word.get()
      smali_finder(path)
  def save_list():
    with open(&quot;saved_result&quot;,&quot;w&quot;) as sfile:
       sfile.write('\n'.join(d.get(0,END)))
    var=messagebox.showwarning(message=&quot;File names are saved as {}&quot;.format(&quot;saved_result.txt&quot;))
  
  def chose_folder():
    global path
    foldername = askdirectory() 
    path=foldername
    folder_name.delete(0,END)
    folder_name.update()
    folder_name.insert(END, path)    
  
  if __name__==&quot;__main__&quot;:
    parent=Tk()
    parent.title('File Finder')
    Label(parent,text=&quot;Folder name: &quot;).grid(row=0,column=0,sticky='e')
    folder_name=Entry(parent,width=20)
    folder_name.grid(row=0,column=1,padx=2,pady=2,sticky='we',columnspan=9)
    Label(parent,text=&quot;Search word: &quot;).grid(row=1,column=0,sticky='e')
    search_word=Entry(parent,width=20)
    search_word.grid(row=1,column=1,padx=2,pady=2,sticky='we',columnspan=9)
    Label(parent,text=&quot;Search Results: &quot;).grid(row=3,column=0,sticky='e')
    d=Listbox(parent,width=125,height=20)
    d.grid(row=4,column=3,padx=2,pady=2,sticky='we',columnspan=9)
  </code></pre>
  <p>Button(parent,text=&quot;Folder&quot;,command=lambda:chose_folder()).grid(row=0,column=10,sticky='e'+'w',padx=2,pady=2,)
  start=Button(parent,text=&quot;Start&quot;,command=lambda:fing(path)).grid(row=1,column=10,sticky='e'+'w',padx=2,pady=2,)
  save=Button(parent,text=&quot;Save&quot;,command=lambda:save_list())
  save.grid(row=2,column=10,sticky='e'+'w',padx=2,pady=2)
  Button(parent,text=&quot;Exit&quot;,command=parent.destroy).grid(row=3,column=10,sticky='e'+'w',padx=2,pady=2)</p>
  <p>parent.mainloop()</p>