From 9305df13fd2c3a935b2de82a28eea4cb6989e8e8 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Tue, 9 Jan 2024 20:45:22 +0300 Subject: [PATCH] Feat(wx/books): Catch clicks, toggle checkboxes [skip ci] --- m_librarian/wx/ListBooks.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/m_librarian/wx/ListBooks.py b/m_librarian/wx/ListBooks.py index 14963c1..63d2b7c 100644 --- a/m_librarian/wx/ListBooks.py +++ b/m_librarian/wx/ListBooks.py @@ -129,9 +129,27 @@ class ListBooksPanel(GridPanel): row += 1 grid.AutoSizeColumns() grid.AutoSizeRows() + grid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnClick) + + def toggleCB(self, row): + value = self.grid.GetCellValue(row, 0) + if value: + value = '' + else: + value = '1' + self.grid.SetCellValue(row, 0, value) + + def OnClick(self, event): + if event.GetCol() > 0: + return + row = event.GetRow() + self.toggleCB(row) def OnDClick(self, event): - pass + if event.GetCol() == 0: + return + row = event.GetRow() + self.toggleCB(row) def OnKeyDown(self, event): if event.GetKeyCode() == wx.WXK_ESCAPE: -- 2.39.2