]> git.phdru.name Git - m_librarian.git/blobdiff - m_librarian/wx/SearchPanel.py
Feat(wx): Catch `Escape` in the grid and close the window
[m_librarian.git] / m_librarian / wx / SearchPanel.py
index 26fb666443812d0f7802724b51518486ac67a8f0..8547c313152fc07f8253e7b0305464ab508db747 100644 (file)
@@ -1,13 +1,18 @@
 # coding: utf-8
 
 import wx
+from ..search import search_authors_raw
+from .ListAuthors import ListAuthorsWindow
+
+
+_search_types = ['start', 'substring', 'full']
 
 
 class SearchPanel(wx.Panel):
 
     def __init__(self, parent):
         wx.Panel.__init__(self, parent)
-        self.search_authors_vsizer = search_authors_vsizer = \
+        search_authors_vsizer = \
             wx.StaticBoxSizer(wx.VERTICAL, self, u'Поиск авторов')
         self.SetSizer(search_authors_vsizer)
 
@@ -31,12 +36,16 @@ class SearchPanel(wx.Panel):
             self, label=u'Различать прописные/строчные')
         search_authors_vsizer.Add(search_case)
 
-        self.search_authors_button = search_authors_button = wx.Button(
-            self, label=u'Искать авторов')
+        search_authors_button = wx.Button(self, label=u'Искать авторов')
         search_authors_vsizer.Add(search_authors_button, 0, wx.ALIGN_CENTER, 0)
         search_authors_button.Bind(wx.EVT_BUTTON, self.SearchAuthors)
 
     def SearchAuthors(self, event):
         search_authors = self.search_authors.GetValue()
-        search_substr = self.search_substr.GetSelection()
+        search_substr = _search_types[self.search_substr.GetSelection()]
         search_case = self.search_case.GetValue()
+        if search_case is False:
+            search_case = None
+        search_authors_results = \
+            search_authors_raw(search_authors, search_substr, search_case)
+        ListAuthorsWindow(self.Parent, search_authors_results)