[Boa Constr] wxGrid in Boa
Status: Beta
Brought to you by:
riaan
From: Lynndon H. <lyn...@ec...> - 2001-08-20 11:01:58
|
Hi all I have been trying to get a grid to work within Boa, and be contained within a panel. My steps were: 1 Create simple Boa app and frame 2 put panel and button on frame (unless another control is on the frame, the panel grabs the whole frame. 3 Insert wxGrid object within panel. 4 Insert code for a grid (which works as a module) into the wxFrame1 code. 5 Change the reference in the original Boa code to refer to the new grid class (dbGrid). When running this I get "TypeError: __init__() got an unexpected keyword argument ....... message from the self.grid1=...... (line 62). Any help would be greatly appreciated. Actually I find the whole wxPython grid a bit of a maze, and would appreciate any help in deciding which class of grid is best suited for which application. TIA Lynndon Harnell Code is as follows: #Boa:Frame:wxFrame1 from wxPython.wx import * from wxPython.grid import * ColHeaders=["PipeID", "Len(m)", "Dia(mm)", "WT(mm)", "Gr", "SYMS(MPa)", "Vol(m3)"] RowHeaders=["1","2"] NCols=len(ColHeaders) NRows=len(RowHeaders) class dbGrid(wxGrid): def __init__(self,parent): wxGrid.__init__(self,parent,-1, style= wxSIMPLE_BORDER|wxSUNKEN_BORDER) self.CreateGrid(NRows,NCols) self.SetGridLineColour(wxColour(128,128,128)) self.EnableEditing(false) self.SetSelectionMode(wxGrid.wxGridSelectColumns) self.SetDefaultCellAlignment(wxRIGHT,wxCENTER) self.SetRowLabelAlignment(wxCENTER,wxCENTER) self.SetColLabelAlignment(wxCENTER,wxCENTER) self.SetColLabelSize(20) self.SetRowLabelSize(10) self.SetCellHighlightColour(wxBLACK) # set cell values self.SetCellValue(0, 0, "1") self.SetCellValue(0, 1, "2120") self.SetCellValue(0, 2, "114.3") self.SetCellValue(0, 3, "4.8") self.SetCellValue(0, 4, "B") for i in range(NCols): self.SetColLabelValue(i,ColHeaders[i]) self.SetColSize(i,50) for i in range(NRows): self.SetRowLabelValue(i,RowHeaders[i]) def SetData(self,data): for row in range(len(data)): for col in range(len(data[row])): self.SetCellValue(row,col,data[row][col]) #--------------------------------------------------------------------------- def create(parent): return wxFrame1(parent) [wxID_WXFRAME1, wxID_WXFRAME1BUTTON1, wxID_WXFRAME1GRID1, wxID_WXFRAME1PANEL1] = map(lambda _init_ctrls: wxNewId(), range(4)) class wxFrame1(wxFrame): def _init_utils(self): pass def _init_ctrls(self, prnt): wxFrame.__init__(self, id = wxID_WXFRAME1, name = '', parent = prnt, pos = wxPoint(196, 126), size = wxSize(377, 232), style = wxDEFAULT_FRAME_STYLE, title = 'wxFrame1') self._init_utils() self.panel1 = wxPanel(id = wxID_WXFRAME1PANEL1, name = 'panel1', parent = self, pos = wxPoint(0, 0), size = wxSize(288, 120), style = wxTAB_TRAVERSAL) # self.grid1 = wxGrid(id = wxID_WXFRAME1GRID1, name = 'grid1', parent = self.panel1, pos = wxPoint(104, 24), size = wxSize(136, 80), style = wxTHICK_FRAME | wxSUNKEN_BORDER) self.grid1 = dbGrid(id = wxID_WXFRAME1GRID1, name = 'grid1', parent = self.panel1, pos = wxPoint(104, 24), size = wxSize(136, 80), style = wxTHICK_FRAME | wxSUNKEN_BORDER) self.button1 = wxButton(id = wxID_WXFRAME1BUTTON1, label = 'button1', name = 'button1', parent = self, pos = wxPoint(168, 176), size = wxSize(75, 23), style = 0) def __init__(self, parent): self._init_ctrls(parent) Lynndon Harnell |