Update of /cvsroot/pythoncard/PythonCard/samples/iacGrid
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25077
Modified Files:
iacGrid.py
Log Message:
turned off cell editing and added dynamic grid expansion
these don't seem to be causing a crash, so the earlier problem
might have been the ansi version of wxPython
renamed the main class to IacGrid
removed self.log and some extra comments
Index: iacGrid.py
===================================================================
RCS file: /cvsroot/pythoncard/PythonCard/samples/iacGrid/iacGrid.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** iacGrid.py 28 Jul 2006 22:05:38 -0000 1.6
--- iacGrid.py 29 Jul 2006 13:25:42 -0000 1.7
***************
*** 20,37 ****
! class Minimal(model.Background):
def on_initialize(self, event):
- self.log = sys.stdout
-
self.mygrid = mygrid = self.components.mygrid
# KEA 2006-07-28
- # until we figure out dynamic resizing of the grid
- # we could set the initial grid to a reasonably large
- # value for in memory tests
# to support very large arbitrary size data sets will
# require the use of a wx.GridTableBase
! mygrid.CreateGrid(30, 6)
self.populate_cells_from_file()
--- 20,36 ----
! class IacGrid(model.Background):
def on_initialize(self, event):
self.mygrid = mygrid = self.components.mygrid
+ self.rowcnt = 0
+ self.colcnt = 0
# KEA 2006-07-28
# to support very large arbitrary size data sets will
# require the use of a wx.GridTableBase
! mygrid.CreateGrid(5, 5)
!
! mygrid.EnableEditing(False)
self.populate_cells_from_file()
***************
*** 46,57 ****
self.panel.Layout()
- # KEA 2006-07-27
- # apparently there is a bug, probably a race condition when the control
- # is first created in wxWidgets on the Mac which requires that this call
- # be done late rather than immediately after the grid creation
- # on Windows, even this caused a crash, so commenting it out until
- # I can figure out the problem
- ## mygrid.EnableEditing(False)
-
def populate_cells_from_file(self, filename='jets.txt'):
--- 45,48 ----
***************
*** 60,76 ****
for row, line in enumerate(open(filename)):
fields = line.rstrip().split()
! # KEA 2006-07-28
! # in order to dynamically size the grid
! # according to the docs it looks like we would use AppendRows
! # and AppendCols but this also appears to cause a crash
! ## if row >= mygrid.GetNumberRows():
! ## print "adding row"
! ## mygrid.AppendRows()
for col, value in enumerate(fields):
print row, col, value
mygrid.SetCellValue(row, col, value)
self.rowcnt = row + 1
self.colcnt = col + 1
! print self.rowcnt, self.colcnt
--- 51,66 ----
for row, line in enumerate(open(filename)):
fields = line.rstrip().split()
! if row == mygrid.GetNumberRows():
! print "adding row", row
! mygrid.AppendRows()
for col, value in enumerate(fields):
+ if col == mygrid.GetNumberCols():
+ print "adding column", col
+ mygrid.AppendCols()
print row, col, value
mygrid.SetCellValue(row, col, value)
self.rowcnt = row + 1
self.colcnt = col + 1
! print "self.rowcnt: %d, self.colcnt: %d" % (self.rowcnt, self.colcnt)
***************
*** 111,117 ****
def on_mygrid_rangeSelect(self, event):
if event.Selecting():
- self.log.write("rangeSelect: top-left %s, bottom-right %s\n" %
- (event.GetTopLeftCoords(), event.GetBottomRightCoords()))
-
result = []
for row, col in self.getSelectedCells():
--- 101,104 ----
***************
*** 126,131 ****
def on_mygrid_selectCell(self, event):
- self.log.write("selectCell: (%d,%d) %s\n" %
- (event.row, event.column, event.position))
if event.Selecting():
result = [self.mygrid.GetCellValue(event.row, event.column)]
--- 113,116 ----
***************
*** 150,153 ****
if __name__ == '__main__':
! app = model.Application(Minimal)
app.MainLoop()
--- 135,138 ----
if __name__ == '__main__':
! app = model.Application(IacGrid)
app.MainLoop()
|