Troubles with GetSelectedRows()

Micha Reiser micha.reiser at famreiser.ath.cx
Sat Sep 2 14:47:32 PDT 2006


Hello

I Created a Grid with CreateGrid (in the real probramm I had a TableBase).

Now, when I try to detect the selected Row with GetSelectedRows() I receive
all the time an empty list?

I had attached an example Code.

I use python 2.4 and the newest wxpython...

Thx a lot

Micha
-------------- next part --------------
import wx
import wx.grid

def OnDClick(evt):
    if grid.IsSelection():
        rows = grid.GetSelectedRows()
        print rows
        grid.DeleteRows(rows[0], 1)


app = wx.PySimpleApp()
frame = wx.Frame(None, -1,"Hallo")
panel = wx.Panel(frame)

grid = wx.grid.Grid(panel, -1, size = frame.GetSize())
grid.CreateGrid(3,3)

for i in range(3):
    for x in range(3):
        grid.SetCellValue(i, x, str(i + x))

grid.Bind(wx.grid.EVT_GRID_CMD_CELL_LEFT_DCLICK, OnDClick)
grid.SetSelectionMode(wx.grid.Grid.SelectRows)
frame.Show()
app.MainLoop()


More information about the wxpython-users mailing list