def eventHandler(self, dlg, event, name):
  if lbc.IsCloseEvent(event) or (name==self.btn_cancel.GetName() and lbc.IsButtonEvent(event)): return globals.destroy(self)
  if name==self.btn_brf.GetName(): format=0
  if name==self.btn_daisy.GetName(): format=1
  if lbc.IsButtonEvent(event): #must be one of the formats available
   globals.download(self.result, format)
   return self.Destroy()
 def eventHandler(self, dlg, event, name):
  result=self.lst_results.GetSelection()
  if lbc.IsCloseEvent(event) or (name==self.btn_close.GetName() and lbc.IsButtonEvent(event)): return globals.destroy(self, self.lst_results.GetName(), [self.lst_results.GetName()])
  elif name==self.lst_results.GetName() and (lbc.IsFocusEvent(event) or lbc.IsListChangeEvent(event)):
   #update info box with current item when user changes selection or lands on list
   self.memo_info.SetValue(self.getInfo(self, self.results[result], ["longSynopsis"]))
  elif self.favoriteable and name==self.btn_favorite.GetName() and lbc.IsButtonEvent(event): #save this search to the favorites section of config
   globals.config['favorites'][self.searchName]=[str(self.searchTerms), self.searchType, self.category, self.grade]
   try:
    globals.config.write()
    return AlertDialog("Success", "The favorite has been saved.")
   except:
    return ErrorDialog("Error", "There was an error trying to save the favorite. Please try closing the program and re-launching it, then search again.")
  elif name==self.btn_download.GetName() and lbc.IsButtonEvent(event):
   if globals.config['settings']['format']!=str(globals.prompt[1]): #download book in preferred format
    globals.download(self.results[result])
   else: return DownloadDialog(self.results[result])
  elif name==self.btn_moreInfo.GetName() and lbc.IsButtonEvent(event): #use an api call to show all info about the book
   return BookInfoDialog(self.results[result])
  elif name==self.btn_prev.GetName() and lbc.IsButtonEvent(event):
   if globals.canSpeak: globals.output("Loading previous "+str(globals.limit)+" results, please wait.", 1)
   self.results.prevPage()
   self.Destroy()
   return SearchResultsDialog(searchTerms=self.searchTerms, searchType=self.searchType, results=self.results, category=self.category, grade=self.grade)
  elif name==self.btn_next.GetName() and lbc.IsButtonEvent(event):
   if globals.canSpeak: globals.output("Loading next "+str(globals.limit)+" results, please wait.", 1)
   self.results.nextPage()
   self.Destroy()
   return SearchResultsDialog(searchTerms=self.searchTerms, searchType=self.searchType, results=self.results, category=self.category, grade=self.grade)
  elif name==self.btn_first.GetName() and lbc.IsButtonEvent(event):
   if globals.canSpeak: globals.output("Loading first "+str(globals.limit)+" results, please wait.", 1)
   self.results.getPage(1, True)
   self.Destroy()
   return SearchResultsDialog(searchTerms=self.searchTerms, searchType=self.searchType, results=self.results, category=self.category, grade=self.grade)
  elif name==self.btn_last.GetName() and lbc.IsButtonEvent(event):
   if globals.canSpeak: globals.output("Loading final results, please wait.", 1)
   self.results.getPage(self.results.pages, True)
   self.Destroy()
   return SearchResultsDialog(searchTerms=self.searchTerms, searchType=self.searchType, results=self.results, category=self.category, grade=self.grade)
  elif name==self.btn_author.GetName() and lbc.IsButtonEvent(event):
   if len(self.results[result].authorList)>1: author=lbc.DialogPick(title="Choose Author", names=self.results[result].authorList, values=self.results[result].authorList)
   else: author=self.results[result].authorList[0]
   if globals.canSpeak: globals.output("Searching for all books by "+author+", please wait.", 1)
   try:
    results=globals.searchTypes[globals.search_author](author, category=self.category, grade=self.grade) #search for the text
   except pybookshare.ApiError, e:
    return ErrorDialog("Error!", e)
   return SearchResultsDialog(searchTerms=author, searchType=globals.searchTypes.keys()[1], results=results, category=self.category, grade=self.grade)