[wxPython-users] Re: PyDeadObjectError(self.attrStr % self._name) ?

Jorgen Bodde jorgen.maillist at gmail.com
Tue Feb 20 08:03:15 PST 2007


Hi Robin,

Agreed. So the code generation on wxGlade needs some improvement on
the menu side. It really behaved weird giving random errors or even
unhandled menu events.

- Jorgen

On 2/19/07, Robin Dunn <robin at alldunn.com> wrote:
> Jorgen Bodde wrote:
> > 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.
>
> -1 is allowed, but it just means that the binding will match a menu
> event from any menu item.  IOW, -1 is a wildcard.
>
> >
> > 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.
>
> What it should be doing is something like this:
>
>          wxglade_tmp_menu = wx.Menu()
>          testItem = wxglade_tmp_menu.Append(wx.NewId(), "&Test", "",
> wx.ITEM_NORMAL)
>          self.FmMain_menubar.Append(wxglade_tmp_menu, "&File")
>
>          self.Bind(wx.EVT_MENU, self.OnTest, testItem)
>
> Or use a specific ID in the Append, and also in the Bind with the id
> parameter.
>
>
> --
> Robin Dunn
> Software Craftsman
> http://wxPython.org  Java give you jitters?  Relax with wxPython!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org
>
>




More information about the wxpython-users mailing list