Can't get wxGrid to work

G

GrayGeek

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
 
E

Erik Lechak

Hello,

self.gridPart2 = wxGrid(id=wxID_WXHAP2004GRIDPART2, name='gridPart2',
parent=self.pnlPersInfo, pos=wxPoint(280, 104), size=wxSize(112,
176), style=wxSIMPLE_BORDER)

Don't forget to self.gridPar2.CreateGrid(rows,cols)

wxGrid isn't as dynamic or intuitive or whatever you want to call it.
You have to explicitly tell it how many rows and cols you have. Look
at AppendRows, AppendCols, DeleteRows, and DeleteCols. Dont try to
CreateGrid more than once.

Hope this helps,
Erik Lechak
 
G

GrayGeek

Erik said:
Hello,



Don't forget to self.gridPar2.CreateGrid(rows,cols)

wxGrid isn't as dynamic or intuitive or whatever you want to call it.
You have to explicitly tell it how many rows and cols you have. Look
at AppendRows, AppendCols, DeleteRows, and DeleteCols. Dont try to
CreateGrid more than once.

Hope this helps,
Erik Lechak

Thanks, Erik. I had already read the documention on wxGRID but the problem
is that in Boa-Constructor the statement that creates the class
'self.gridPart2' is in the part of the wxFRAME class that has "auto
generated - do not edit" in the __DOC__ section.

The class is created by draging and dropping a widget from the tool bar onto
the frame. I could create the class manually, but what the use of a GUI
RAD if you have to revert to manually coding controls?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top