]> git.phdru.name Git - m_librarian.git/commitdiff
Feat(wx/search): Catch Enter and double-click, open books window
authorOleg Broytman <phd@phdru.name>
Sat, 6 Jan 2024 15:27:46 +0000 (18:27 +0300)
committerOleg Broytman <phd@phdru.name>
Sat, 6 Jan 2024 16:20:44 +0000 (19:20 +0300)
[skip ci]

m_librarian/wx/ListAuthors.py
m_librarian/wx/ListBooks.py [new file with mode: 0644]

index cdbf134fc17ecf06e3c47de5b9af75f08811298d..96f5e8ba56e942bf8977adc2c8beda5b5097a3f4 100644 (file)
@@ -4,6 +4,7 @@ import wx, wx.grid  # noqa: E401 multiple imports on one line
 from ..compat import string_type, unicode_type
 from ..translations import translations
 from .AWindow import AWindow
+from .ListBooks import ListBooksWindow
 
 
 class ListAuthorsWindow(AWindow):
@@ -59,3 +60,22 @@ class ListAuthorsPanel(wx.Panel):
                 grid.SetCellValue(row, col, value)
         grid.AutoSizeColumns()
         grid.AutoSizeRows()
+
+        grid.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.OnDClick)
+        grid.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
+
+    def listBooks(self, row):
+        authors = self.search_authors_results['authors']
+        author = authors[row]
+        ListBooksWindow(self, author)
+
+    def OnDClick(self, event):
+        row = event.GetRow()
+        self.listBooks(row)
+
+    def OnKeyDown(self, event):
+        if event.GetKeyCode() in (wx.WXK_RETURN, wx.WXK_NUMPAD_ENTER):
+            row = self.grid.GetGridCursorRow()
+            self.listBooks(row)
+        else:
+            event.Skip()
diff --git a/m_librarian/wx/ListBooks.py b/m_librarian/wx/ListBooks.py
new file mode 100644 (file)
index 0000000..97f8826
--- /dev/null
@@ -0,0 +1,14 @@
+# coding: utf-8
+
+import wx
+from .AWindow import AWindow
+
+
+class ListBooksWindow(AWindow):
+
+    session_config_section_name = 'list_books'
+    window_title = u"m_Librarian: Список книг"
+
+    def __init__(self, parent, author):
+        self.author = author
+        AWindow.__init__(self, parent)