Re: [Boa Constr] help with a pygridtablebase
Status: Beta
Brought to you by:
riaan
From: Werner F. B. <wer...@fr...> - 2008-06-23 14:54:59
|
Hi Anthony, Anthony Nutting wrote: > hi all > > i'm really new to programming and python - so forgive my ignorance upfront. > What i would like to do is use a pygridtablebase with boa. how would i > go about this? The issue is that i want to design the whole layout with > boa, put in a placeholder wx.grid.Grid object and then through some code > mangling replace the wx.grid.Grid with a pygridtablebase. Well could > someone post some code as a sample to show me how to do this, or has > someone got a better suggestion to using pygridtablebase with boa. Any > responses will be much appreciated - as i'm really in a jamb. You need to look into how to use custom_classes, this works well for your problem as the standard wx.grid is a widget supported by Boa. Manually insert the custom_classes line, something like this: class dialogCuvee(wx.Dialog): _custom_classes = {'wx.ListCtrl': ['CuveeAllLC'], 'wx.grid.Grid': ['CuveeTableGrid'],} def _init_coll_bsPage_Items(self, parent): # generated method, don't edit Above shows two custom classes of mine, one is based on wx.ListCtrl and the other on a PyGridTableBase. When you want to place the grid, select it normally from the widget tool bar, then in the inspector you will be able to select to either use the normal grid or the CuveeTableGrid (in my case). You then have within the same module the following: class CuveeDataTable(wx.grid.PyGridTableBase): """Grid table base for the cuvee """ def __init__(self, parent): wx.grid.PyGridTableBase.__init__(self) .....etc class CuveeTableGrid(wx.grid.Grid): #, wxGridAutoEditMixin): def __init__(self, parent, id, name, pos, size, style): wx.grid.Grid.__init__(self, parent, -1, size=(-1, -1), style=wx.DOUBLE_BORDER) #wx.GridAutoEditMixin.__init__(self) .....etc self.parent = parent self.table = CuveeDataTable(parent=self) If you write it genericaly (which I did not for my CuveeTableGrid (as I only use it in one place so far), then you would place it in a separate file and import it using this format: from listctrlvirtv3 import * I.e. you can not use "import listctrlvirtv3" as custom_class does not support having something like "{'wx.ListCtrl': ['listctrlvirtv3CuveeAllLC']," Hope this gets you going. Werner |