Can't get wxGrid to work

GrayGeek jkrepsBEAR at FISHneb.rr.com
Tue Nov 4 02:21:31 CET 2003


Using Boa-constructor and wxGrids.
When the grid control is dropped onto the form Boa-C creates the following
code in wxFRAME:

self.gridPart2 = wxGrid(id=wxID_WXHAP2004GRIDPART2, name='gridPart2',
                parent=self.pnlPersInfo, pos=wxPoint(280, 104), size=wxSize(112,
                176), style=wxSIMPLE_BORDER)
        self.gridPart2.SetRowLabelSize(50)
        self.gridPart2.SetDefaultColSize(60)
        self.gridPart2.SetColLabelSize(15)
        self.gridPart2.SetDefaultRowSize(15)
        self.gridPart2.EnableEditing(False)

I have code behind a button that does the following:

    def OnBtnvniButton(self, event):
        if  self.txtRemarks.GetValue() <> 'VALID NO INCOME':
            self.txtRemarks.SetValue('VALID NO INCOME')
            self.txtPersinfoAppstatus.SetValue('')
            ZeroPartOne(self)
            ZeroPartTwo(self)
        else:
            self.txtRemarks.SetValue('')

and it works, causing both ZeroPartOne and ZeroPartTwo to be called.
What doesn't work is the code in the two 'zero' functions.

def ZeroPartTwo(self):
    # zero gridPart2 values and gridWorksheet values
    self.gridPart2.EnableEditing(False)
    for j in range(2):
        for k in range(10):
            self.gridPart2.SetReadOnly(j,k,False)
    self.gridPart2.SetColLabelValue(0,"Line")
    self.gridPart2.SetColLabelValue(0,"Amount")
    self.gridPart2.SetCellValue(0,0,"Line 1 ")
    self.gridPart2.SetCellValue(0,1,"Line 2 ")
    self.gridPart2.SetCellValue(0,2,"Line 3 ")
    self.gridPart2.SetCellValue(0,3,"Line 4 ")
        ....

Nothing shows up in the grid. I can't assign values to any cells, nor can
column labels be assigned.  The grid doesn't respond to anything.
This code is essentially from one of the examples in wxPython.
-
GrayGeek




More information about the Python-list mailing list