[wxpython-users] How to set grid default col alignment.

1,012 views
Skip to first unread message

Jorge

unread,
Mar 13, 2009, 6:49:46 PM3/13/09
to wxpytho...@lists.wxwidgets.org
Hi,
I starting to play with grids and my problem (so far)
is to find a way of setting a default alignment for the colums,
I try "wXPython in Action" pag. 443~444, also the wiki
but without results.

Thank in advance for your help.

Marcelo Fernández

unread,
Mar 13, 2009, 9:13:50 PM3/13/09
to wxpytho...@lists.wxwidgets.org
Jorge escribió:

Uhm... You'll have to set the alignment cell by cell with the
SetCellAlignment(row, col, horiz, vert) method.

Take a look at this little example:

self.CreateGrid(5, 3)
col_h_alignment = (wx.ALIGN_LEFT, wx.ALIGN_CENTRE, wx.ALIGN_RIGHT)
col_v_alignment = (wx.ALIGN_TOP, wx.ALIGN_CENTRE, wx.ALIGN_BOTTOM)

for row in range(5):
for col in range(3):
self.SetCellValue(row, col, "Column %i" % col)
self.SetCellAlignment(row, col, col_h_alignment[col],
col_h_alignment[col])


The complete version is here: http://pastebin.com/f227735d4

Regards,
Marcelo
--
Marcelo F. Fernández
Buenos Aires, Argentina
Licenciado en Sistemas - CCNA

E-Mail: fernan...@yahoo.com.ar
Jabber ID: fernan...@jabber.org
Public Key ID: 5C990A6C 111C3661
Blog: http://marcelosoft.blogspot.com

Robin Dunn

unread,
Mar 17, 2009, 12:01:08 AM3/17/09
to wxpytho...@lists.wxwidgets.org

Create a GridCellAttr object, set the alignment flags on the attr object
and then pass the attr to SetColAttr.


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

Jorge

unread,
Apr 5, 2009, 6:23:02 AM4/5/09
to wxpytho...@lists.wxwidgets.org
Thank you.



_______________________________________________
wxpython-users mailing list
wxpytho...@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

rathaus

unread,
Apr 24, 2011, 12:10:06 PM4/24/11
to wxpytho...@googlegroups.com
To set the default grid cell alignment after creating the grid
enter the following line:

grid.SetDefaultCellAlignment(WX.CENTRE, wx.CENTRE)

My previous post left out the second 'wx.'

--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/How-to-set-grid-default-col-alignment-tp2372996p4336562.html
Sent from the wxPython-users mailing list archive at Nabble.com.

Reply all
Reply to author
Forward
0 new messages