]>
git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/demo/wxGrid.py
2 from wxPython
.wx
import *
4 #---------------------------------------------------------------------------
6 class TestGrid(wxGrid
):
7 def __init__(self
, parent
, log
):
8 wxGrid
.__init
__(self
, parent
, -1)
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()
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
)
30 def OnSelectCell(self
, event
):
31 self
.log
.WriteText("OnSelectCell: (%d, %d)\n" % (event
.m_row
, event
.m_col
))
33 def OnCellChange(self
, event
):
34 self
.log
.WriteText("OnCellChange: (%d, %d)\n" % (event
.m_row
, event
.m_col
))
36 def OnCellClick(self
, event
):
37 self
.log
.WriteText("OnCellClick: (%d, %d)\n" % (event
.m_row
, event
.m_col
))
39 def OnLabelClick(self
, event
):
40 self
.log
.WriteText("OnLabelClick: (%d, %d)\n" % (event
.m_row
, event
.m_col
))
42 #---------------------------------------------------------------------------
44 def runTest(frame
, nb
, log
):
45 win
= TestGrid(nb
, log
)
48 #---------------------------------------------------------------------------
69 wxGrid is a class for displaying and editing tabular information.
74 wxGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style=0, const wxString& name="grid")
76 Constructor. Before using a wxGrid object, you must call CreateGrid to set up the required rows and columns.