self.grid = grid = wx.grid.Grid(self)
vsizer.Add(grid, 0, wx.EXPAND, 0)
+ grid.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.OnDClick)
+ grid.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
+
self.InitGrid()
+ grid.SetFocus()
+
+ parent.Bind(wx.EVT_ACTIVATE, self.OnActivate)
+ parent.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus)
+ self.Bind(wx.EVT_ACTIVATE, self.OnActivate)
+ self.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus)
def InitGrid(self):
raise NotImplementedError
+ def OnDClick(self, event):
+ raise NotImplementedError
+
+ def OnKeyDown(self, event):
+ raise NotImplementedError
+
+ def OnActivate(self, event):
+ if event.GetActive():
+ self.grid.SetFocus()
+
+ def OnSetFocus(self, event):
+ self.grid.SetFocus()
+
class GridWindow(AWindow):
def OnInit(self):
AWindow.OnInit(self)
- self.GridPanelClass(self, self.param)
+ self.panel = self.GridPanelClass(self, self.param)
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.param['authors']
author = authors[row]
self.listBooks(row)
def OnKeyDown(self, event):
- if event.GetKeyCode() in (wx.WXK_RETURN, wx.WXK_NUMPAD_ENTER):
+ if event.GetKeyCode() == wx.WXK_ESCAPE:
+ self.Parent.Close()
+ elif event.GetKeyCode() in (wx.WXK_RETURN, wx.WXK_NUMPAD_ENTER):
row = self.grid.GetGridCursorRow()
self.listBooks(row)
else:
grid.AutoSizeColumns()
grid.AutoSizeRows()
+ def OnDClick(self, event):
+ pass
+
+ def OnKeyDown(self, event):
+ if event.GetKeyCode() == wx.WXK_ESCAPE:
+ self.Parent.Close()
+ else:
+ event.Skip()
class ListBooksWindow(GridWindow):