[wxPython] Grid Delete Row

Robin

I have modified my code to attempt to modify the underlying data, but I get
an UnboundLocalError : local variable 'PipeGridData' referenced before
assignment at line 224. Any suggestions?

Boa code is attached.

<<wxFrame1.py>>

wxFrame1.py (9.53 KB)

···

-----Original Message-----
From: Robin Dunn [SMTP:robin@alldunn.com]
Sent: Thursday, 11 October 2001 05:43
To: wxpython-users@lists.wxwindows.org
Subject: Re: [wxPython] Grid Delete Row

> I am having some trouble in getting a grid to delete a specfic row. My
code
> seems only to delete the last row, whereas I want it to delete the row
where
> the cursor is.
>
> The following lines indicate where I'm having trouble:
> CurRow = self.grid1.GetGridCursorRow()
> msg = wxGridTableMessage(table, # the table
> wxGRIDTABLE_NOTIFY_ROWS_DELETED, # what was done
> CurRow,1) # position,
number
> of rows
> self.grid1.ProcessTableMessage(msg)
>
> Any clues would be appreciated.

Are you actually removing the data for that row from your table? Sending
the the table message to the grid only updates the number of rows the grid
expects to find in the table, updates the grid labels, attributes, etc.
and
then refreshes the grid which should cause the grid to fetch the data
values
from the table again for the rows that are visible.

If you are not using your own table then you don't need to do it this way,
just call grid.DeleteRows and it will handle updating the default table.

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

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

I have modified my code to attempt to modify the underlying data, but I

get

an UnboundLocalError : local variable 'PipeGridData' referenced before
assignment at line 224. Any suggestions?

Python 101.

Since PipeGridData is assigned to in the function, python assumes it is a
local variable and tries to optimize it. Since you really mean it to be a
global then you need to add the "global PipeGridData" statement before you
use it in the function.

···

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