Closing wxapp error

LB wrote:

In my application the main widget is a wxgrid for data input from user.
(python 2.3.4 ad wxpython 2.4)
As I want the grid getting focus at startup I create a wxframe activate
event as
EVT_ACTIVATE(self, self.OnWxFrame1Activate) and with this simple code:

    def OnWxFrame1Activate(self, event):
        self.grid1.SetFocus()
        self.grid1.SetGridCursor(0,0)
        event.Skip()

Well, it works but gives this error closing the application:

Traceback (most recent call last):
  File "C:\Documents and Settings\LB\pyACalc\dBCalc05d\dBCalcForm.py", line
441,
      in OnWxFrame1Activate s elf.grid1.SetFocus()
      File "C:\Python23\Lib\site-packages\wxPython\wx.py", line 1834, in
__getattr__
      raise wxPyDeadObjectError( self.attrStr % self._name )
      wxPython.wx.wxPyDeadObjectError: The C++ part of the wxGrid object has
been deleted,
      attribute access no longer allowed.

How can I avoid it and get the same behaviour at start up?

      def OnWxFrame1Activate(self, event):
          if event.GetActive():
              self.grid1.SetFocus()
              self.grid1.SetGridCursor(0,0)
          event.Skip()

···

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