Maximizing ListCtrl

I'd like to have a ListCtrl report where, when window is resized,
columns resize too. I've tried this:

class VirtualListPanel(wx.Panel):
     def __init__(self, parent):
    wx.Panel.__init__(self, parent, -1)

    width = self.GetParent().GetClientSize().width/5
    coches = vehiculos()

    gris = wx.Color(220,220,220)

    self.lista = wx.ListCtrl(self, style=wx.LC_REPORT|wx.LC_HRULES|
wx.LC_VRULES)
    self.lista.InsertColumn(0, "Matricula", width=width)
    self.lista.InsertColumn(1, "Tipo", width=width)
    self.lista.InsertColumn(2, "Fecha Matriculacion", width=width)
    self.lista.InsertColumn(3, "Fecha Ult. ITV", width=width)
    self.lista.InsertColumn(4, "Fecha Prox. ITV", width=width)
    i = 0

    for data in coches:
      index = self.lista.InsertStringItem(i, data[0])
           self.lista.SetStringItem(index, 1, str(data[1]))
           self.lista.SetStringItem(index, 2, str(data[2]))
      self.lista.SetStringItem(index, 3, str(data[3]))
      self.lista.SetStringItem(index, 4,
str(prox(data[1],data[2],data[3])))
      if((index+1) % 2 == 0):
        self.lista.SetItemBackgroundColour(index,gris)
      i += 1

    self.sizer = wx.BoxSizer(wx.HORIZONTAL)
    self.sizer.Add(self.lista, 1, wx.EXPAND|wx.ALL)
    self.SetSizer(self.sizer)
    self.Bind(wx.EVT_SIZE, self.OnResize)
  def OnResize(self, event):
          width = self.GetParent().GetClientSize().width/5
    self.lista.SetColumnWidth(0, width)
    self.lista.SetColumnWidth(1, width)
    self.lista.SetColumnWidth(2, width)
    self.lista.SetColumnWidth(3, width)
    self.lista.SetColumnWidth(4, width)

This is the panel where listctrl is, and you see the
self.Bind(wx.EVT_SIZE, self.OnResize), that takes to the OnResize
function.
If I ommit Bind, I have a full-screen ListCtrl, but with narrow
columns that don't occupy all panel. But if I put it (like now), panel
gets resized to a small square on top left corner, which is even worse

Thank you in advance!

Hi,

Take a look at the wxPython demo package. It shows how to use the ListCtrlAutoWidthMixin, which is what I think you want.

  • Mike

My problem was that I missed event.Skip(). Somebody on another forum
answered me.

ListCtrlAutoWidthMixin, as I seen, only maximizes last column, but
thanks anyway

···

On 7 mayo, 16:30, Mike Driscoll <kyoso...@gmail.com> wrote:

Hi,

Take a look at the wxPython demo package. It shows how to use the
ListCtrlAutoWidthMixin, which is what I think you want.

- Mike