GridSizer::GetRows()

GridSizer::GetRows() doesn't seem to get the actual number of rows in
the grid, just what you've set it to initially. The docs say that if
you set the number of rows to zero, the appropriate number of rows
will be created based on the number of items you add to the sizer.
But GetRows still returns zero in that case. Is there a way to get
the actual number of rows?

Sample code:

import wx
app = wx.PySimpleApp()
frame = wx.Frame(None, -1, "test")
gs = wx.FlexGridSizer(rows=0, cols=2, hgap=10, vgap=10)
gs.Add(wx.StaticText(frame, -1, "row 1"))
gs.Add(wx.StaticText(frame, -1, "row 1"))
gs.Add(wx.StaticText(frame, -1, "row 2"))
gs.Add(wx.StaticText(frame, -1, "row 2"))
gs.Add(wx.StaticText(frame, -1, "row 3"))
gs.Add(wx.StaticText(frame, -1, "row 3"))
print gs.GetRows()

0

Thanks,
Joe Winter

Joe Winter wrote:

GridSizer::GetRows() doesn't seem to get the actual number of rows in
the grid, just what you've set it to initially. The docs say that if
you set the number of rows to zero, the appropriate number of rows
will be created based on the number of items you add to the sizer. But GetRows still returns zero in that case. Is there a way to get
the actual number of rows?

Sample code:

import wx
app = wx.PySimpleApp()
frame = wx.Frame(None, -1, "test")
gs = wx.FlexGridSizer(rows=0, cols=2, hgap=10, vgap=10)
gs.Add(wx.StaticText(frame, -1, "row 1"))
gs.Add(wx.StaticText(frame, -1, "row 2"))
gs.Add(wx.StaticText(frame, -1, "row 3"))
print gs.GetRows()

Something like this:

  num = len(gs.GetChildren())
  cols = gs.GetCols()
  rows = (num + cols - 1) / cols

I'll add a method that can calculate the rows/cols like this the same way as it is done internal to the grid sizers.

···

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

Great, that's what I was looking for.

Thanks!
Joe

···

On 2/20/06, Robin Dunn <robin@alldunn.com> wrote:

Something like this:

        num = len(gs.GetChildren())
        cols = gs.GetCols()
        rows = (num + cols - 1) / cols