help with a pygridtablebase

View: New views
2 Messages — Rating Filter:   Alert me  

help with a pygridtablebase

by Anthony Nutting :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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.

Regards

Anthony

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Boa-constructor-users mailing list
Boa-constructor-users@...
https://lists.sourceforge.net/lists/listinfo/boa-constructor-users

Re: help with a pygridtablebase

by Werner F. Bruhin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Boa-constructor-users mailing list
Boa-constructor-users@...
https://lists.sourceforge.net/lists/listinfo/boa-constructor-users