[wxPython-users] Window pane buttons
Norberto Lopes
collector at mail.telepac.pt
Mon Feb 4 11:05:24 PST 2008
At Mon, 04 Feb 2008 10:50:43 -0800,
Robin Dunn wrote:
>
> Norberto Lopes wrote:
>
> > In my code I have this for the buttons:
> > - self.Bind(wx.EVT_BUTTON, self.item_add_session, self.add_session_button)
> > for the button in window_pane_3
> > - self.Bind(wx.EVT_BUTTON, self.item_add_person, self.add_person_button)
> > for the button in window_pane_4
> >
> > The thing is... When I press add_session_button (the button in
> > window_pane_3, item_add_person is called).
>
> You probably created the buttons with the same ID.
>
Correct.
> >
> > I can't find where I did the mistake, but this "workaround" works:
> >
> > - self.window_pane_3.Bind(wx.EVT_BUTTON, self.item_add_session)
> > - self.window_pane_4.Bind(wx.EVT_BUTTON, self.item_add_person).
>
> See http://wiki.wxpython.org/self.Bind_vs._self.button.Bind for why.
>
>
> >
> > This won't work if I want more buttons in each of the window_panes, so
> > how do I solve this?
>
> Give your buttons unique IDs. If you use wx.ID_ANY then wx will make
> them unique for you.
>
This was tricky to debug, because all my UI is generated by wxglade,
so it never hit me why it was calling the same thing over and over
again.
Thanks for the help.
> --
> 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