]> git.phdru.name Git - m_librarian.git/commitdiff
Feat(wx/books): Catch clicks, toggle checkboxes
authorOleg Broytman <phd@phdru.name>
Tue, 9 Jan 2024 17:45:22 +0000 (20:45 +0300)
committerOleg Broytman <phd@phdru.name>
Tue, 9 Jan 2024 17:45:22 +0000 (20:45 +0300)
[skip ci]

m_librarian/wx/ListBooks.py

index 14963c1d5d6806982b0ce06891715b18081e474a..63d2b7ca2bb5817375204215bb21ec2a1592900a 100644 (file)
@@ -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: