]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/demo/wxGrid.py
Final tweaks for 2.1b1
[wxWidgets.git] / utils / wxPython / demo / wxGrid.py
1
2 from wxPython.wx import *
3
4 #---------------------------------------------------------------------------
5
6 class TestGrid(wxGrid):
7 def __init__(self, parent, log):
8 wxGrid.__init__(self, parent, -1)
9 self.log = log
10
11 self.CreateGrid(16, 16)
12 self.SetColumnWidth(3, 200)
13 self.SetRowHeight(4, 45)
14 self.SetCellValue("First cell", 0, 0)
15 self.SetCellValue("Another cell", 1, 1)
16 self.SetCellValue("Yet another cell", 2, 2)
17 self.SetCellTextFont(wxFont(12, wxROMAN, wxITALIC, wxNORMAL), 0, 0)
18 self.SetCellTextColour(wxRED, 1, 1)
19 self.SetCellBackgroundColour(wxCYAN, 2, 2)
20 self.UpdateDimensions()
21 self.AdjustScrollbars()
22
23 EVT_GRID_SELECT_CELL(self, self.OnSelectCell)
24 EVT_GRID_CELL_CHANGE(self, self.OnCellChange)
25 EVT_GRID_CELL_LCLICK(self, self.OnCellClick)
26 EVT_GRID_LABEL_LCLICK(self, self.OnLabelClick)
27
28
29
30 def OnSelectCell(self, event):
31 self.log.WriteText("OnSelectCell: (%d, %d)\n" % (event.m_row, event.m_col))
32
33 def OnCellChange(self, event):
34 self.log.WriteText("OnCellChange: (%d, %d)\n" % (event.m_row, event.m_col))
35
36 def OnCellClick(self, event):
37 self.log.WriteText("OnCellClick: (%d, %d)\n" % (event.m_row, event.m_col))
38
39 def OnLabelClick(self, event):
40 self.log.WriteText("OnLabelClick: (%d, %d)\n" % (event.m_row, event.m_col))
41
42 #---------------------------------------------------------------------------
43
44 def runTest(frame, nb, log):
45 win = TestGrid(nb, log)
46 return win
47
48 #---------------------------------------------------------------------------
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 overview = """\
69 wxGrid is a class for displaying and editing tabular information.
70
71 wxGrid()
72 -----------------
73
74 wxGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style=0, const wxString& name="grid")
75
76 Constructor. Before using a wxGrid object, you must call CreateGrid to set up the required rows and columns.
77 """