The Renderer does the auto wrap nicely when loading the grid, how can I force it to do it after changing a cell? Is there some GridTableMessage or similar for this?
I also have a problem that when I try to use both Renderer and Editor I get a hard crash without any exception.
I use the following code to set them
def GetAttr(self, row, col, other):
"""Set attributes for a particular cell, e.g. readonly
"""
if col in self.readOnlyColumns:
attr =wx.grid.GridCellAttr()
attr.SetReadOnly(True)
attr.SetTextColour(wx.BLUE)
return attr
elif col == 2:
# aligment for quantity column
attr = wx.grid.GridCellAttr()
attr.SetAlignment(wx.ALIGN_RIGHT, -1)
return attr
elif col == 5:
attr = wx.grid.GridCellAttr()
attr.SetRenderer(wx.grid.GridCellAutoWrapStringRenderer())
attr.SetEditor(wx.grid.GridCellAutoWrapStringEditor())
return attr
return
I am on python 2.6 and wxPython 2.8.11.0 on Windows 7 64bit.
The Renderer does the auto wrap nicely when loading the grid, how can I force it to do it after changing a cell? Is there some GridTableMessage or similar for this?
Doing this in the OnCellChange event is doing the trick.
# force autosize, need to use CallAfter otherwise it crashes
wx.CallAfter(self.AutoSizeRows)
I also have a problem that when I try to use both Renderer and Editor I get a hard crash without any exception.
My guess is that it has something to do with the reference counting scheme that the Grid classes use. Try calling IncRef on the editor and renderer. Another thing to try is to create the attribute object in the __init__ and then use the same instance each time GetAttr is called for col 5. You'll need to call IncRef on the attribute object before returning it in that case.
···
On 9/24/10 1:52 AM, werner wrote:
The Renderer does the auto wrap nicely when loading the grid, how can I
force it to do it after changing a cell? Is there some GridTableMessage
or similar for this?
I also have a problem that when I try to use both Renderer and Editor I
get a hard crash without any exception.
I use the following code to set them
def GetAttr(self, row, col, other):
"""Set attributes for a particular cell, e.g. readonly
"""
if col in self.readOnlyColumns:
attr =wx.grid.GridCellAttr()
attr.SetReadOnly(True)
attr.SetTextColour(wx.BLUE)
return attr
elif col == 2:
# aligment for quantity column
attr = wx.grid.GridCellAttr()
attr.SetAlignment(wx.ALIGN_RIGHT, -1)
return attr
elif col == 5:
attr = wx.grid.GridCellAttr()
attr.SetRenderer(wx.grid.GridCellAutoWrapStringRenderer())
attr.SetEditor(wx.grid.GridCellAutoWrapStringEditor())
return attr