]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/demo/wxGrid.py
1. Grid cell defaults are now handled by an internal
[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 self.SetEditInPlace(true)
29 #print self.GetCells()
30
31
32 def OnSelectCell(self, event):
33 self.log.WriteText("OnSelectCell: (%d, %d)\n" % (event.m_row, event.m_col))
34
35 def OnCellChange(self, event):
36 self.log.WriteText("OnCellChange: (%d, %d)\n" % (event.m_row, event.m_col))
37
38 def OnCellClick(self, event):
39 self.log.WriteText("OnCellClick: (%d, %d)\n" % (event.m_row, event.m_col))
40
41 def OnLabelClick(self, event):
42 self.log.WriteText("OnLabelClick: (%d, %d)\n" % (event.m_row, event.m_col))
43 #if event.m_row >= 10:
44 # self.SetLabelValue(wxVERTICAL, 'XX', event.m_row)
45 # self.Refresh()
46 #else:
47 # size = self.GetLabelSize(wxVERTICAL)
48 # print size
49 # self.SetLabelSize(wxVERTICAL, size+10)
50 # self.Refresh()
51
52 #---------------------------------------------------------------------------
53
54 def runTest(frame, nb, log):
55 win = TestGrid(nb, log)
56 return win
57
58 #---------------------------------------------------------------------------
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78 overview = """\
79 wxGrid is a class for displaying and editing tabular information.
80
81 wxGrid()
82 -----------------
83
84 wxGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style=0, const wxString& name="grid")
85
86 Constructor. Before using a wxGrid object, you must call CreateGrid to set up the required rows and columns.
87 """