Right justify cols in Grid?

Jerry LeVan wrote:

I wanted to try to right justify some columns without specifying the
grid attributes for *every* cell as GetAttr would do

With the proc renamed to GetAttrJHL (so it is never called ) I had hoped that the first
fragment might right justify column 2. Alas that does not happen.

Can someone hit me with a clue stick...

It works for me in the demo with the patch below. You are aware that the column numbers are zero-based, so col 2 will actually be the 3rd one, right?

Index: GridHugeTable.py

ยทยทยท

===================================================================
RCS file: /pack/cvsroots/wxwidgets/wxWidgets/wxPython/demo/GridHugeTable.py,v
retrieving revision 1.10
diff -u -4 -r1.10 GridHugeTable.py
--- GridHugeTable.py 2005/04/04 22:52:29 1.10
+++ GridHugeTable.py 2007/05/10 20:32:41
@@ -14,12 +14,12 @@
          self.odd.SetBackgroundColour("sky blue")
          self.even=gridlib.GridCellAttr()
          self.even.SetBackgroundColour("sea green")

- def GetAttr(self, row, col, kind):
- attr = [self.even, self.odd][row % 2]
- attr.IncRef()
- return attr
+## def GetAttr(self, row, col, kind):
+## attr = [self.even, self.odd][row % 2]
+## attr.IncRef()
+## return attr

      # This is all it takes to make a custom data table to plug into a
@@ -57,8 +57,14 @@
          # table and will destroy it when done. Otherwise you would need to keep
          # a reference to it and call it's Destroy method later.
          self.SetTable(table, True)

+ self.ca = wx.grid.GridCellAttr()
+ self.ca.SetAlignment(wx.ALIGN_RIGHT,wx.ALIGN_CENTRE)
+ self.SetColAttr(2,self.ca)
+ self.ca.IncRef()
+ self.SetDefaultCellOverflow(False)
+
          self.Bind(gridlib.EVT_GRID_CELL_RIGHT_CLICK, self.OnRightDown)

      def OnRightDown(self, event):
          print "hello"

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!