]>
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
)
28 self
.SetEditInPlace(true
)
29 #print self.GetCells()
32 def OnSelectCell(self
, event
):
33 self
.log
.WriteText("OnSelectCell: (%d, %d)\n" % (event
.m_row
, event
.m_col
))
35 def OnCellChange(self
, event
):
36 self
.log
.WriteText("OnCellChange: (%d, %d)\n" % (event
.m_row
, event
.m_col
))
38 def OnCellClick(self
, event
):
39 self
.log
.WriteText("OnCellClick: (%d, %d)\n" % (event
.m_row
, event
.m_col
))
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)
47 # size = self.GetLabelSize(wxVERTICAL)
49 # self.SetLabelSize(wxVERTICAL, size+10)
52 #---------------------------------------------------------------------------
54 def runTest(frame
, nb
, log
):
55 win
= TestGrid(nb
, log
)
58 #---------------------------------------------------------------------------
79 wxGrid is a class for displaying and editing tabular information.
84 wxGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style=0, const wxString& name="grid")
86 Constructor. Before using a wxGrid object, you must call CreateGrid to set up the required rows and columns.