From 74e25a3ef07da5268107f1b246e6b466f178b524 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sat, 6 Jan 2024 18:27:46 +0300 Subject: [PATCH] Feat(wx/search): Catch Enter and double-click, open books window [skip ci] --- m_librarian/wx/ListAuthors.py | 20 ++++++++++++++++++++ m_librarian/wx/ListBooks.py | 14 ++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 m_librarian/wx/ListBooks.py diff --git a/m_librarian/wx/ListAuthors.py b/m_librarian/wx/ListAuthors.py index cdbf134..96f5e8b 100644 --- a/m_librarian/wx/ListAuthors.py +++ b/m_librarian/wx/ListAuthors.py @@ -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 index 0000000..97f8826 --- /dev/null +++ b/m_librarian/wx/ListBooks.py @@ -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) -- 2.39.2