On Tuesday, August 03, 2010 08:51:09 pm Paul McNett wrote:
> On 8/3/10 8:17 PM, Bronwyn Woods wrote:
> > Hi,
> > I have what I hope is a simple question. I have a dGrid with a column of
> > checkboxes with DataType "bool". I would like to call code when the user
> > checks or unchecks a check box, but I haven't been able to figure out how
> > to bind an event to a checkbox within a column of a grid.
> >
> > The code I have to create the grid and the column is
> >
> > class selMovesGrid(dabo.ui.dGrid):
> > def afterInit(self):
> > self.addColumn(Name="incl", Caption="Includes", Width=60,
> >
> > DataType="bool", Sortable=True, DataField =
> > "incl", Searchable=False, Editable=True,
> > Resizable=False)
> >
> > class selMoves(dabo.ui.dPanel):
> > def afterInit(self):
> > [...]
> > self.selGrid = selMovesGrid(self)
> > [...]
> >
> > I'm not sure if I need to bind the event to the column or the instance of
> > the grid or what.
>
> You are treading on an area that Dabo hasn't fully wrapped. Try:
>
> grid.bindEvent(dabo.dEvents.GridCellEditorHit, yourHitMethod)
>
> As it stands, this should only be called when a grid editor checkbox has
> been toggled, but I'm not sure if your event handler will be able to find
> out *which* checkbox has been toggled, without looking at the grid's
> current row and column.
>
> Paul
This totally untested but I think I would try to sub-class something like
this:
class SpecialBoolCellRenderer(wx.grid.GridCellBoolRenderer):
def Draw(self, grid, attr, dc, rect, row, col, isSelected):
self.super()
do what ever is needed!
You have access to the row, col to determine value.
you might have to do:
def Clone(self):
return SpecialBoolCellRenderer()
Don't forget do something like
col.CustomRendererClass = SpecialBoolCellRenderer
Like I said this has not been tested and I could be way off with my thinking.
Johnf
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message:
http://leafe.com/archives/byMID/[email protected]