[wxPython-users] Window pane buttons
Robin Dunn
robin at alldunn.com
Mon Feb 4 10:50:43 PST 2008
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.
>
> 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.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list