25 import wx |
25 import wx |
26 import wx.grid |
26 import wx.grid |
27 |
27 |
28 class CustomGrid(wx.grid.Grid): |
28 class CustomGrid(wx.grid.Grid): |
29 |
29 |
30 if wx.VERSION < (2, 6, 0): |
|
31 def Bind(self, event, function, id = None): |
|
32 if id is not None: |
|
33 event(self, id, function) |
|
34 else: |
|
35 event(self, function) |
|
36 |
|
37 def __init__(self, *args, **kwargs): |
30 def __init__(self, *args, **kwargs): |
38 wx.grid.Grid.__init__(self, *args, **kwargs) |
31 wx.grid.Grid.__init__(self, *args, **kwargs) |
39 |
32 |
40 self.Editable = True |
33 self.Editable = True |
41 |
34 |
48 self.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL, False, 'Sans')) |
41 self.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL, False, 'Sans')) |
49 self.SetSelectionBackground(wx.WHITE) |
42 self.SetSelectionBackground(wx.WHITE) |
50 self.SetSelectionForeground(wx.BLACK) |
43 self.SetSelectionForeground(wx.BLACK) |
51 self.DisableDragRowSize() |
44 self.DisableDragRowSize() |
52 |
45 |
53 if wx.VERSION >= (2, 6, 0): |
46 self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnSelectCell) |
54 self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnSelectCell) |
47 self.Bind(wx.grid.EVT_GRID_EDITOR_HIDDEN, self.OnEditorHidden) |
55 self.Bind(wx.grid.EVT_GRID_EDITOR_HIDDEN, self.OnEditorHidden) |
|
56 else: |
|
57 wx.grid.EVT_GRID_SELECT_CELL(self, self.OnSelectCell) |
|
58 self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) |
48 self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) |
59 |
49 |
60 def SetDefaultValue(self, default_value): |
50 def SetDefaultValue(self, default_value): |
61 self.DefaultValue = default_value |
51 self.DefaultValue = default_value |
62 |
52 |