Hello I'm new to the forums and I want to ask some questions about grid like operations:
Here I make a grid and set all cellvalues to 0.
import wx
import wx.grid
class TestTable(wx.grid.PyGridTableBase):
def __init__(self):
wx.grid.PyGridTableBase.__init__(self)
self.rowLabels = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]
self.colLabels = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"]
def GetNumberRows(self):
return 10
def GetNumberCols(self):
return 10
def IsEmptyCell(self, row, col):
return False
def GetValue(self, row, col):
return 0
def SetValue(self, row, col, value):
pass
def GetColLabelValue(self, col):
return self.colLabels[col]
def GetRowLabelValue(self, row):
return self.rowLabels[row]
class TestFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title="Grid Table",
size=(500,200))
grid = wx.grid.Grid(self)
table = TestTable()
grid.SetTable(table, True)
app = wx.PySimpleApp()
frame = TestFrame()
frame.Show()
app.MainLoop()
Now I want to make some blocks of cells and these blocks should get another value say 1...
With a result as something like this:
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 1 1 1 1 0 0 0 0
0 0 1 1 1 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 1 1 0 1 1 1 1 0 0
0 1 1 0 1 1 1 1 0 0
0 1 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
My question is how I can make selections of groups of cells by blocks and change the values to say 1. After this I also need to be able to retrieve information of the position and value of these 'separate' blocks...
Some results I want to have are something like this:
Block 1 = [3C-4F] value = 1
Block 2 = [6B-8C] value = 1
Block 3 = [6E-7H] value = 1
I'm kinda new to programming and I'm allready stuck lol...
Anyones help on this would be great.