Window pane buttons

I have a vertical window pane.

1 | 2

In 1 I have another window pane, this time a horizontal one, as:

3

···

_
4

In window_pane_3 and window_pane_4 I have a label, a tree_ctrl and a
button, each.

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).

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).

This won't work if I want more buttons in each of the window_panes, so
how do I solve this?

Thanks,
  Norberto

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 self.Bind vs. self.button.Bind - wxPyWiki 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.

···

At Mon, 04 Feb 2008 10:50:43 -0800, Robin Dunn wrote:

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

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org