From: Oleg Broytman Date: Tue, 9 Jan 2024 17:45:22 +0000 (+0300) Subject: Feat(wx/books): Catch clicks, toggle checkboxes X-Git-Tag: 0.3.0~9^2~4 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=9305df13fd2c3a935b2de82a28eea4cb6989e8e8;p=m_librarian.git Feat(wx/books): Catch clicks, toggle checkboxes [skip ci] --- 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: