Cell Alignment with wxGrid

After reading about cell alignment on a wxGrid here: http://docs.wxwidgets.org/stable/wx_wxgrid.html#wxgridsetcellalignment I’m kinda confused on the usage.

The above link shows usage as:

SetCellAlignment(**int **row, **int **col, **int **horiz, **int **vert)

Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or wxALIGN_RIGHT.

I’ve got an instance of a wxGrid created, I’m able to put data in the cells, but I can’t set the cell alignment to, say, right aligned. Here’s the code:

myGrid.SetCellAlignment(1,1, wxALIGN_RIGHT, wxALIGN_CENTRE)

I get a NameError error message: “NameError: global name ‘wxALIGN_RIGHT’ is not defined”

The SetCellAlignment statement requires an “int” for horizontal and vertical alignment, but “Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or wxALIGN_RIGHT.” How do I know what it’s looking for? Better yet, how do I give it what it requires?

Many thanks from a mushy brain,

Adrian

PS I’m not very smart, but I can lift heavy things.

but I can't set the cell alignment to, say, right
aligned. Here's the code:

myGrid.SetCellAlignment(1,1, wxALIGN_RIGHT, wxALIGN_CENTRE)

I get a NameError error message: "NameError: global
name 'wxALIGN_RIGHT' is not defined"

You"re reading a C++ spec and you have to do a little translation:

    wx.ALIGN_RIGHT, wx.ALIGN_CENTRE

The dots, man, the dots.

paul

Hi Adrian,

After reading about cell alignment on a wxGrid here: http://docs.wxwidgets.org/stable/wx_wxgrid.html#wxgridsetcellalignmentI’m kinda confused on the usage.

The above link shows usage as:

*SetCellAlignment*(*int */row/, *int */col/, *int */horiz/, *int */vert/)
Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or wxALIGN_RIGHT.

I've got an instance of a wxGrid created, I'm able to put data in the cells, but I can't set the cell alignment to, say, right aligned. Here's the code:

myGrid.SetCellAlignment(1,1, wxALIGN_RIGHT, wxALIGN_CENTRE)

This is an easy one. You forgot the dot! It should look like this:

myGrid.SetCellAlignment(1,1, wx.ALIGN_RIGHT, wx.ALIGN_CENTRE)

I get a NameError error message: "NameError: global name 'wxALIGN_RIGHT' is not defined"

The SetCellAlignment statement requires an "int" for horizontal and vertical alignment, but "Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or wxALIGN_RIGHT." How do I know what it's looking for? Better yet, how do I give it what it requires?

Many thanks from a mushy brain,
Adrian

PS I'm not very smart, but I can lift heavy things.

Have fun!

···

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org