Trying to delete a row in a grid actually appends one

I have implemented this in my wx.grid.PyGridTableBase:

  def DeleteRows(self, pos = 0, num_rows = 1, update = True):
    del self.data[pos:pos + num_rows]
    msg = wx.grid.GridTableMessage(self,
      wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, num_rows)
    self.GetView().ProcessTableMessage(msg)
    print self.data

The methods gets called because I see less rows in my table. However, the number of rows is increased, even though it is the same code as for adding rows with the event message changed. Why?

···

--
Grzegorz Adam Hankiewicz, Jefe de producto de TeraVial
Rastertech España S.A. Tel: +34 918 467 390, ext 18.
http://www.rastertech.es/ ghankiewicz@rastertech.es

Grzegorz Adam Hankiewicz wrote:

I have implemented this in my wx.grid.PyGridTableBase:

    def DeleteRows(self, pos = 0, num_rows = 1, update = True):
        del self.data[pos:pos + num_rows]
        msg = wx.grid.GridTableMessage(self,
            wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, num_rows)
        self.GetView().ProcessTableMessage(msg)
        print self.data

The methods gets called because I see less rows in my table. However, the number of rows is increased, even though it is the same code as for adding rows with the event message changed. Why?

I think you also need to pass the pos.

           msg = wx.grid.GridTableMessage(self,
              wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, pos, num_rows)

···

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