PyDeadObjectError(self.attrStr % self._name) ?
Jorgen Bodde
jorgen.maillist at gmail.com
Sat Feb 17 01:03:25 PST 2007
Ok I figured it out!
It is a wxGlade problem. I defined a menu like;
&Test----- ID = -1 ----- OnTest
And I noticed that wxGlade makes this code;
self.FmMain_menubar = wx.MenuBar()
self.SetMenuBar(self.FmMain_menubar)
wxglade_tmp_menu = wx.Menu()
wxglade_tmp_menu.Append(wx.NewId(), "&Test", "", wx.ITEM_NORMAL)
self.FmMain_menubar.Append(wxglade_tmp_menu, "&File")
HOWEVER, during event binding I see this;
self.Bind(wx.EVT_MENU, self.OnTest, id=-1)
And AFAIK you cannot bind to an ID -1. The menus behaved erratic,
sometimes they were ignored most of the times they resulted in a
crash.
wxGlade's solution would be binding to the event given to
wxglade_tmp_menu but I think that one is overwritten for every new
menu item.
I will try to post this as well on the wxGlade mailinglist. It took me
a day of confusion until I found out that ALL menus did not work with
an auto generated ID in wxGlade..
Regards,
- Jorgen
On 2/16/07, Jorgen Bodde <jorgen.maillist at gmail.com> wrote:
> Hi guys,
>
> I am pretty new to wxPython, but there is something I do not
> understand. This is the code I am using to create a dialog;
>
> def OnBackupItem(self, event): # wxGlade: ArchivisionFrm.<event_handler>
> dlg = ar_dlg.ArchiverDlg(self, -1)
> dlg.ShowModal()
> dlg.Destroy()
> event.Skip()
>
> Looks pretty ok, and it works in a handler for a wxButton. If I
> execute the same code from a menu handler, I get a dead object error:
>
> raise PyDeadObjectError(self.attrStr % self._name)
> wx._core.PyDeadObjectError: The C++ part of the ArchiverMgtDlg object
> has been deleted, attribute access no longer allowed.
>
> The wxFrame is generated by wxGlade, and the menu event seems to get
> fired, however I cannot instantiate a dialog from that menu handler.
>
> The code is here: http://www.xs4all.nl/~jorgb/dead_object.zip
>
> wxGlade project is included, if you fire up Archivision.py and select
> from the file menu -> Archivers .. the same code is executed as
> pressing the [Backup] button. One works, the other crashes.
>
> wxPython 2.8.0 Unicode Debug Build
>
> Does anyone have any idea? I was going along so well, but I am puzzled
> as I am not seeing what I am doing wrong..
>
> - Jorgen
>
More information about the wxpython-users
mailing list